It's common to mount the entire Ubuntu system on one partition on one drive. It's very easy to set that up, simply format an ext4 filesystem for the entire disk, and away we go. How do you transition such a system to have /home on a second drive? The GUI tools don't support doing this, so what do you do? A big consideration is that while logged in you're using /home, and therefore can't delete that filesystem while it's in use.
The presumption is that you've already partitioned and formatted all the drives you'll use in the resulting system. See How to set-up a multi-drive SSD/HDD Ubuntu desktop system
Moving your home folder to another partition in Ubuntu is fairly straight-forward. You may want, as I do, to move /home to another drive, or you may want to set up multiple partitions on one drive, with /home as its own partition.
In this case we're focused on moving the /home partition to a new partion on a second drive. The instructions should work for other scenarios.
$ sudo su -
# cd /
# rsync -aXS /home/. /media/home/.
# mv home home_backup
# mkdir home
This assumes you'd mounted the new partition as /media/home. If not, substitute its mount point in the rsync command. Pay careful attention, because the trailing /. on each path is important to rsync.
What this does is
- duplicate everything in the existing /home into the new partition
- Rename the existing /home directory to something else
- Make a directory, /home, that will serve as the mount point for the new partition.
Now it's necessary to edit /etc/fstab to change the new partition mountpoint to /home. You may have this in /etc/fstab
UUID=7b9210d7-219f-4fc8-8501-677277a05f19 /home-tmp ext4 errors=remount-ro 0 2
Simply change /home-tmp (or whatever you have) to /home.
Then you run: mount -a and the mount point for the new partition will change to /home.
Except that - df -h still shows the new partition mounted as /home-tmp (or whatever you had it mounted as). What happened is that the partition is now mounted at both mountpoints. It's necessary to unmount the old mount:
# umount /home-tmp
At that point, the new partition will show in df -h as /home.
The old /home is still on the drive as /home_backup. We did that so that the GUI/X11 environment could still use any open files it had. But we need to log-out, then log-in, so our login session can start using the new /home partition. The rsync command will have ensured everything was copied, and when logged back in you should have the exact same user setup as before.
To remove the old files
$ sudo rm -rf /home_backup
Author: David Herron