Move home folder to second drive

Moving HOME from command line

To avoid side effects while working in a graphical, environment we should perform all actions to move HOME from a terminal with Ctrl+Alt+F1.

Temporarily mount the new partition:

sudo mkdir /mnt/tmp
sudo mount /dev/sdb1 /mnt/tmp

assuming /sdb1 is the new partition for HOME

Copy HOME to the new location:

sudo rsync -avx /home/ /mnt/tmp

We then may mount the new partition as HOME with

sudo mount /dev/sdb1 /home

to make sure all data are present. Easiest is to delete the old /home at this point (you could do this later but then you will have to boot a live system to see the old home):

sudo umount /home  #unmount the new home first!
rm -rf /home/*  #deletes the old home

Make HOME permanent

We need to know the UUID of the new partition for the fstab entry seen from:

sudo blkid

Note or copy/paste the correct UUID to edit your fstab with

sudo nano /etc/fstab   #or any other editor

and add the following line at the end:

UUID=<noted number from above>    /home    ext4    defaults   0  2

Take care to choose the appropriate filesystem here, e.g. ext3 if ext3 formatted

Reboot

After a reboot, your /home resides on the new drive having plenty of space.


If you want to just move your home directory i.e /home/your-username then simply copy your home directory to other partition and then use System->Administration->Users & Groups to open user settings dialog. Click on the keys icon to authenticate your self

alt text

After that select the user that you want to change and click properties, go to advanced tab

alt text

change the home directory to new directory i.e the directory that you copied to other partition.


The official detailed procedure is here on the Ubuntu help wiki


Find the UUID of the Partition

sudo blkid

Set up Fstab

sudo -H gedit /etc/fstab 

and add these lines into it

UUID=????????   /media/home    ext4    defaults    0  2 

and replace the ???????? with the UUID number of the intended /home partition.

Save and close the fstab file, then type the following command:

sudo mkdir /media/home

Copy /home to the new partition

sudo rsync -aXS --progress --exclude='/*/.gvfs' /home/. /media/home/.

Check copying worked

sudo diff -r /home /media/home -x ".gvfs/*"

Note: You can also expect to see some errors about files not found. These are due to symbolic links that point to places that don't presently exist (but will do after you have rebooted). You can ignore these - but check out anything else.

Preparing fstab for the switch

sudo -H gedit /etc/fstab

and now edit the lines you added earlier, changing the /media/home part to simply say /home so that it looks like this:

UUID=????????   /home   ext4    defaults     0  2 

Moving /home into /old_home

cd / && sudo mv /home /old_home && sudo mkdir /home

Reboot or Remount all

Reboot or remount all with this:

sudo mount -a