Welcome to the forum!
First things first… Did you already create a new partition for /home
on the other drive? If not, do so, and after you’ve created and formatted it, use lsblk
to get the UUID
of the partition. Alternatively, you can also set a LABEL
in the filesystem upon creation, and use the LABEL
in /etc/fstab
, instead of the UUID
. So long as the identifier for the partition is unique and persistent, which unfortunately the /dev/sd[alphabetic_char]
designations are not if you have more than one hard drive. Either way, write down the UUID
, as you’re going to need it.
Now, as for the move itself… Normally, you would do this from within single-user maintenance mode, which means that you must be completely logged out as an unprivileged user, and that no processes may be using the system beyond what is needed to have a root shell running.
sudo telinit 1
Edit: Better is to use…
sudo systemctl isolate rescue.target
… instead of telinit
.
The system will now switch to a different, character-mode-only environment. Depending on the security settings, you may need to enter the root password, or you may be presented with a root prompt immediately after issuing the above command.
Now the move process begins… < insert scary music >
First, you need to mount the new partition that is to become your home. Mount it at /mnt
─ that’s exactly the sort of thing /mnt
exists for. Replace /dev/sdb1
in the example below by the actual drive and partition, and replace the filesystem ─ ext4
in the example below ─ by the one you’ve formatted the partition with ─ note: it must be a Linux-native filesystem (like e.g. ext4
, xfs
or btrfs
) and not ntfs
or something similar.
mount -t ext4 -o sync /dev/sdb1 /mnt
Now, we’ll move over the contents of your current /home
to the new partition…
mv /home/* /mnt/ && sync
Depending on the bus speed and drive speed, the above process may take some time. When the moving has ended, the command prompt will return.
Now, we will edit /etc/fstab
. This is what you needed that UUID
for.
nano /etc/fstab
If you already had /home
on a separate partition before this move, then comment out the entry for that partition by putting a #
in front of the line.
Add the following line to the file, substituting the fake UUID
below by the one that you wrote down, and ext4
by the filesystem of your choice…
UUID=some-really-long-string /home ext4 auto,nouser,defaults,nodev,relatime 0 0
Save the file with Ctrl+O ─ confirm the overwrite ─ and exit the editor with Ctrl+X.
Now, all you need to do is reboot, and the new partition will be mounted at /home
…
systemctl reboot
Good luck!