0

I have 2 drives on my machine, but one is unused. I would like to use the unused drive for the home partition (as in moving my current home directory into the unused drive). Is this possible without reinstallation and if so how do I go about doing it?

  • 2
    To move /home uses rsync- Be sure to use parameters to preserve ownership & permissions https://help.ubuntu.com/community/Partitioning/Home/Moving I prefer to keep /home inside my / since on SSD. But had (until new larger SSD) all data in a separate /mnt/data partition on HDD. HDD now is mostly for backup and test installs. https://askubuntu.com/questions/1013677/storing-data-on-second-hdd-mounting & https://askubuntu.com/questions/1058756/installing-all-applications-on-a-ssd-disk-and-putting-all-files-on-hdd-disk – oldfred Feb 01 '21 at 21:55
  • 1
    Why do that and not put the directories on that 2nd partition? the method to do that is already provided by the desktop. /home itself benefits from a speedy ssd if 1 of the 2 is an ssd. see ./config/users-dir.dirs. Oh and moving /home/ to a NTFS will destroy your system. Only use ext. – Rinzwind Feb 01 '21 at 23:37

1 Answers1

1

During this process, you should avoid using directory /home by any application, so it's best to not login from GUI, but from the text console (available after pressing Ctrl+Alt+F3 key).

Perform everything with root permissions (run sudo -i first).

Create a partition on the unused drive (using fdisk) and format it (create a filesystem) using mkfs.

Rename directory /home to /old_home. Create a new, empty directory /home, with the same owner and permissions as /old_home.

Mount the new partition you just formatted under /home, For example if the new partition is /dev/sdb1, use the command mount /dev/sdb1 /home.

Copy everything from /old_home to /home, preserving ownership, permissions etc. (you may use rsync for that as mentioned in the comment above: rsync -a /old_home/ /home/).

Edit /etc/fstab file so that your new /home will be automatically mounted when the system reboots. Your /etc/fstab currently contains a line for the drive you are already using, it might be something like this (I'm making this one up now, yours may be different):

/dev/sda1 / ext4 defaults 0 1

Add a similar line for your new partition that says for example:

/dev/sdb1 /home ext4 defaults 0 2

(if your file has something else instead of "defaults" just copy these parameters to the new line).

Reboot your system (shutdown -r now) and after reboot check if everything is working properly (ie. everything that should be under /home is there). If yes, then delete the /old_home directory - it's not needed anymore.

raj
  • 10,353
  • Answer is woefully incomplete if you do not include details on how to copy the old home preserving all permissions. Using device descriptors in fstab is outdated and may not reliably work on modern systems. – vanadium Feb 02 '21 at 08:16