Quoting Brendan Halpin (brendan.halpin at ul.ie):
> Say I want to move /usr/local to a new partition: what's the least
> error-prone way of doing the copy?
Covered to death at "Copying Directory Trees" on
http://linuxmafia.com/kb/Admin .
If using GNU cp (standard on Linux but not most other Unixen):
Make sure the new location (directory) exists, has correct ownership and
permissions. If you're going to move files of diverse ownership, su to
root. Mount the new location to a temporary mount.
> cp to the new location,
# cp -ax olddirectory newdirectory
(The "x" is mostly needed to avoid picking up /proc when moving files
closer to the system root, but it's a good habit to get into.)
Compare trees to make sure you didn't mess up, umount the temporary
destination mount, and only then....
> delete old,
umount old if it's on its own partition.
> edit fstab, mount new partition?
Do the mount by executing "mount -a" and then verifying that the Right
Thing happens.
If using GNU tar (standard on Linux but not most other Unixen):
Make sure the new location (directory) exists, has correct ownership and
permissions. If you're going to move files of diverse ownership, su to
root. Mount the new location to a temporary mount.
> tar /usr/local,
# (cd olddirectory && 'tar Sczpf - . ) | (cd newdirectory && tar Sxvzpf -)
Proceed as above.
--
Cheers, The cynics among us might say: "We laugh,
Rick Moen monkeyboys -- Linux IS the mainstream UNIX now!
rick at linuxmafia.com MuaHaHaHa!" but that would be rude. -- Jim Dennis
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!