By: +David Herron; Date: January 30, 2018
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 -
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
What this does is:
- duplicate everything in the existing
/homeinto the new partition
- Rename the existing
/homedirectory 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
UUID=7b9210d7-219f-4fc8-8501-677277a05f19 /home-tmp ext4 errors=remount-ro 0 2
/home-tmp (or whatever you have) to
Then you run:
mount -a and the mountpoint for the new partition will change to
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:
At that point the new partition will show in
df -h as
/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