mv while retaning permissions?

James Gray james at grayonline.id.au
Mon Sep 19 00:21:28 UTC 2005


On Sunday 18 September 2005 16:04, Senectus . wrote:
> I muffed up an upgrade and have decided to reinstall with a better
> installation philosophy. (ie /Home on it's own large drive (hda) / on
> a 30gig partition (hdb1) and /opt (with games etc ) on a 50 gig
> partition (hdb2).).
> I want to move my home directory over to the new drive and retain all
> the permissions then I gather I need to tell fstab that is where my
> home is..
> so my questions are:
> How do you move and retain permissions.

I usually use "tar" then once everything is copied over, verify the 
destination files before deleting (as root - so "sudo -H -s" first!):

cd /home ; tar -c ./ | tar -xv -C /path/to/new/home

This assumes you have the new drive already formatted and mounted ready move 
the files over.  The files you'll see scrolling up are being created in the 
destination.

> Apart from the fstab what else do I need to inform of my home drive moving?

Nothing except remounting the new home in /home - which as you know is done 
via fstab.

You can do this without rebooting as long as you drop to single-user mode[1] 
("sudo init 1") then unmount the existing /home.  If /home is part of another 
partition (like '/') then you should empty /home before mounting the new 
home.  If you've got the drive space to spare, I'd try this before 
permanently deleting anything:
sudo init 1
mv /home /home-old
mkdir /home
chmod 0755 /home   (just to be sure the permissions are right)
mount /dev/hda1 /home

Then cruise through the new /home and make sure it looks good - including 
hidden files/directories.  If that works then modify /etc/fstab, 
unmount /home and try remounting it using the info in /etc/fstab:

cd / ; unmount /dev/hda1 && mount /home

If all's well, make a coffee, clap your hands, crack a beer, eat chocolate, or 
do whatever you do to celebrate :)  Go back into runlevel 2 - "init 2" and 
finish the rest of your task.

HTH,

James

[1] - Yeh I know, you don't "HAVE" to be in runlevel 1, but it sure saves 
problems because you forgot that you had a session logged into tty2 or 
something which will prevent you from un-mounting /home! ;)
-- 
The streets were dark with something more than night.
  -- Raymond Chandler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20050919/5f172c19/attachment.sig>


More information about the ubuntu-users mailing list