Ubuntu – Moving /home to an existing directory

fstabhome-directorymountpartitioning

Although I've found numerous guides and questions already I still don’t seem to be able to get this to work.

Situation: I’m trying to move the home folders of 2 users to an already mounted disk. The home folders are now on the hard disk mounted as /. This is an SSD so it’s not really the safest way of storing data (including mbox files) so I’m trying to move everything to my RAID 1 disc already mounted at /media/dataB.

There are already some other folders and files located at this drive, so this differs from the guides and Ubuntu documentation I’ve found. The guides seem to focus on an entirely new partition.

Problem: I’ve been able to copy the home folder to the new partition as described in the guides using rsync. So the data is already at the correct disc. The problem is in mounting the directory as /home using fstab.

I’ve tried mounting /media/dataB/home as /home but this gives an error at boot. Can someone see what I’m doing wrong here or help me with the correct way of mounting /home at /media/dataB/home?

Additional info:

fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID=06b46ce6-fb4c-4483-889f-00c07d28c5d4 /               ext4    errors=remoun$
UUID=473ec3ce-dd2d-41a6-aad0-7ce5eb176473 none            swap    sw           $
/dev/sdb1       /media/dataC    ext4    defaults        0       2
/dev/sdc1       /media/dataA    ext4    defaults        0       2
/dev/sdd1       /media/dataB    ext4    defaults        0       2

Blkid

/dev/sda1: UUID="06b46ce6-fb4c-4483-889f-00c07d28c5d4" TYPE="ext4"
/dev/sda5: UUID="473ec3ce-dd2d-41a6-aad0-7ce5eb176473" TYPE="swap"
/dev/sdb1: UUID="c317e2c3-7a12-4bbc-bf10-bf7b988ca934" TYPE="ext4"
/dev/sdc1: UUID="7217a19a-e6c2-4e36-b584-aad1ae2ef622" TYPE="ext4"
/dev/sdd1: UUID="ecebe9eb-3838-42f4-8c53-9b391b6ca9c2" TYPE="ext4"

Best Answer

It should be perfectly possible to mount the directory using the bind option but it's not necessary anyway. Just make /home a symlink to /media/dataB/home:

sudo mkdir /media/dataB/home
sudo cp -rp /home/* /media/dataB/home/
sudo rm -r /home
sudo ln -s /media/dataB/home /home

Make sure you have a backup of the data, just in case.

Related Question