Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go


Move Home from Root

20190325 The use case here is a common scenario where a system has been set up with the users /home folders on the same partition as root which is /. As users store more data the partition can fill up, causing issues for the system.

Before continue with this procedure it is a good idea to backup your home folder, perhaps to a handy USB drive or to your cloud storage account.

Suppose we have the disk device /dev/sda1 mounted as / (see /etc/fstab). Another partition on that same disk (/dev/sda2) is available with plenty of free space. The goal is to migrate /home from /dev/sda1 to /dev/sda2.

We begin by synchronising the current /home across to /dev/sda2 after mounting the latter onto /mnt:

$ sudo mount /dev/sda2 /mnt
$ sudo rsync -avzh /home/ /mnt/
$ sudo umount /mnt

Obtain the new disk partition's universally unique identifier (UUID). This will be used in the /etc/fstab file to mount the partition by default onto /home:

$ sudo -i blkid | grep sda2
/dev/sda2: LABEL="mondo" UUID="c6aa7b6a-54a2-504e-8532-bd4f2d654896" TYPE="ext4" ...
Edit /etc/fstab to add the following line to the end of the file, save the file, mount and check that it is correctly mounted:
$ sudo gedit /etc/fstab
UUID=c6aa7b6a-54a2-504e-8532-bd4f2d654896 /home ext4 defaults,errors=remount-ro,noatime 0 0
$ sudo mount /home
$ cd
$ df -h .
Filesystem     Size  Used Avail Use% Mounted on
/dev/sda2      482G  1.5G  456G   1% /home

Determine all is okay, perhaps by logging out and back in, or by rebooting the machine and loging in and checking various files. Once everything is fine remove the old /home folder:

$ cd /
$ sudo umount /home
$ df -h home/
    Confirm it is the old disk device and not the new one.
$ sudo rm -rf home
$ sudo mount /home
$ df -h home/
    Confirm it is the new disk device.

Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. Creative Commons ShareAlike V4.