Move home directory to a subdirectory on another partition

Over the web there are several guides about moving the home directory to a different partition.

I wanted to move /home to /dev/sdXY but not place /home on the root of /dev/sdXY as most of the guides tell how to do. I wanted it to be on /dev/sdX/home

On Debian Jessie 8 the following worked using double mounting, one regular and one using bind:

1. Boot using a live USB or CD, so the real system is not running. Preferably the Debian Live USB distro.

2. Mount your partitions and move the whole /home including subdirectories to the new partition, using graphical interface with copy pase, cp -R or rsync:

mkdir -p /mnt/source
mkdir -p /mnt/target

mount /dev/sdXY /mnt/source
mount /dev/sdXY /mnt/target

cp -r /mnt/source/home /mnt/target

Run blkid and try to find out which UUID belongs to the partition where the home dir now resides. You may also use cfdisk or gparted to find the relations between UUID:s and sdXY

Make a dir where to mount the whole partition, mkdir /mnt/storage for example.

Edit fstab so it mounts your new partition there and also makes a bind mount to /home, it could look like this:

# storage on /dev/sdXY
UUID=place-your-uuid-here       /mnt/storage     ext4    defaults    0 0

# bind the home dir on the storage partition to home
/mnt/storage/home/              /home                 none    bind    0 0

Reboot and test, if it fails you may revert.

This is a personal note. Last updated: 2015-09-02 14:50:41.







Don't forget to pay my friend a visit too. Joakim