System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

moving a directory to its own file system

Waqar Razi
Regular Advisor

moving a directory to its own file system

We have a situation to move a directory off the root file system (/abc) to its own file system. We are using tar to backup that directory and then after creating the file system, restore from tar backup to the new file system.

Can we use vfs snapshot for this scenario or some thing better than this approach.

Thanks in advance.
4 REPLIES
Nido
Trusted Contributor

Re: moving a directory to its own file system

Hello Waqar,

Why not use `cp -rp /abc /dest`

Once you copied all the files, remove it from the source.

There are other options available (like using find+cpio or tar )but this one is the easiest.

Thanks,
" Let Villagers Be Happy!! "
James R. Ferguson
Acclaimed Contributor

Re: moving a directory to its own file system

Hi Wagar:

You could snapshot the filesystem to obtain a "static" view of its contents.

Then:

# cd srcdir && pax -w . | ( cd dstdir && pax -r -pe )

this will recursively copy from the 'srcdir' to the 'dstdir'directory while preserving permissions and ownerships. Sparse files will be preserved as sparse too.

Regards!

...JRF...
Tingli
Esteemed Contributor

Re: moving a directory to its own file system

# mkdir /dest
# cd /abc
# mv * /dest/
# cd ../
# rmdir /abc
# mv dest abc
Viktor Balogh
Honored Contributor

Re: moving a directory to its own file system

i think Waqar would save the snapshot directly to the target FS... could work, why not?
****
Unix operates with beer.