How to relocate /home to a new hdd?

no problems with 1TB drives ( this isn't large ;-))

Create a partion and format the new drive (I call it /dev/sdb1 now). With partition sizes over 300GB I prefer XFS.

Now logout from X, login at tty1 as root. Mount the new partition on /mnt/temp-home and copy your data:

mkdir -p /mnt/temp-home && mount /dev/sdb2 /mnt/temp-home
rsync -WaP /home/ /mnt/temp-home/

Now check twice, if /mnt/temp-home holds your data with the right permissions and ownership. You can move the foldername, if you want and delete your old home later:

mv /home /home_old

As root create the new mountpoint and a fstab-entry:

umount /mnt/temp-home
mkdir /home
chmod 0755 /home
cat >> /etc/fstab <<EOF
/dev/sdb1 /home           xfs     defaults        0       2
EOF
mount /home

your are done! Now login to X (gnome/kde/xfce..). and enjoy your new drive.

Don't forget to delete /home_old to free space!


I'm a little more conservative, because I've had to do this on larger systems, with data that . My method:

Create the new filesystem and mount it somewhere (say /mnt/new-home)

As root, use rsync to copy the data from the current location to the new location:

# rsync -avW --progress --delete /home/* /mnt/new-home

You can do that part with the system live and users logged in. In fact you can do it more than once -- subsequent runs should be faster since most of the data is already there, and the --delete flag will clean up files which have been removed. (man rsync will help you with the other flags I've selected.)

Now you need a maintenance window where you can kick everyone off the server. Boot to single user mode, re-mount /home and /mnt/new-home, and run the rsync command again. This rsync run should be fast since 99% of the work has already been done. (Or at least faster than running it for the first time, anyways -- I've had "single-user, last-pass" rsyncs run for up to four hours to do almost nothing...)

When that's done, change /etc/fstab so that the partition you've been using as new-home gets mounted as /home. You can also mount the old home partition as /home.old, or if it was just a directory in a larger partition, rename it to /home.old.

Reboot back to multiuser, and you should be done.

The reason why I don't use mv as recommended by ThorstenS is because I've had bad experiences where mv would crap out half-way through. By using rsync, if you make a dog's breakfast of new-home, you can always unmount it, newfs it, and you are back in business -- no data lost. And also I like to keep the old source around for a while just in case my brand new 1TB drive tosses itself in the first week. After a while you'll be happy with the new drive (or desperately need the space occupied by the old) and you can clean it up.

Your backups are good, right? :)