Move separate /home partition to the default configuration /home folder
Go from a separate /home
partition in the HDD to the default configuration where /home
is a folder in /
, which is in the SSD
We will do this from a Live USB running Ubuntu 18.04 so that we can work with the /home
partition and mount it as /internal_home
.
Step 1: Boot from a Live USB Ubuntu
Select the Try Ubuntu without Installing option as we want to run Ubuntu from the USB, not the internal SSD.
Step 2: Find the uuid of the /home
and /
Partitions
Open a terminal by pressing Ctrl+Alt+T and enter:
sudo blkid > myUUIDs.txt
Keep the terminal open and go to Files (also known as Nautilus) and find the file myUUIDs.txt
and open it by double clicking so that you can easily copy and paste the UUIDs of your internal drives' /home
and /
partitions. You will need them later.
Step 3: Mount the /home
and /
Partitions
As this is just temporary, it does not matter what the mount points are. You can use Nautilus to click and mount them. However, the autogenerated mountpoints are hard to type. So we will use command line to create 2 mountpoints and mount the two partitions there.
First, make some temporary folders as mount points
sudo mkdir /internal_root
sudo mkdir /internal_home
Second, mount the two internal partitions
I assume:
-
1234-UUID-OF-SYSTEM-PARTITION
is your internal/
(root) partition and -
1234-UUID-OF-HOME-PARTITION
is your current home partition.
Copy and paste the correct UUIDs into the terminal from Step 2 above before using.
sudo mount --uuid 1234-UUID-OF-SYSTEM-PARTITION /internal_root
sudo mount --uuid 1234-UUID-OF-HOME-PARTITION /internal_home
Step 4: Copy the home folder from its own partition to SSD under /
Use the following command to copy everything in the old /home
partition to the new /home
folder. Note, you don't need to create the folder as it was created as a mountpoint for the partition.
sudo rsync -aXS --exclude='/*/.gvfs' /internal_home/. /internal_root/home/.
Step 5: Create a new mountpoint for the old home
We need a new pountpoint for the old home so that we can use it to store data I will call it oldhome
. Use the following command:
sudo mkdir //internal_root/oldhome
Note: I don't recommend mounting the old home under /media
. This folder is usually reserved for the system to autmetically mount partitions temporarily.
An alternate would be to create the oldhome
folder under the existing /mnt
folder with the command:
sudo mkdir //internal_root/mnt/oldhome
Step 6: Edit /etc/fstab
to mount the oldhome
automatically when Ubuntu starts
Use the following command to open /etc/fstab
in gedit with administrative privilages.
sudo -H gedit /internal_root/etc/fstab
Look for the line like line with the UUID of your home partition. See Step 2 for the UUID. Change it to look like this:
UUID=1234-UUID-OF-HOME-PARTITION /oldhome ext4 defaults 0 2
where 1234-UUID-OF-HOME-PARTITION
is the UUID number of the old /home
partition as found on Step 2. Note, in this file we don't include the /internal_root/
prefix as when we created the oldhome
folder.
Save the file and exit gedit
.
Step 7: Restart the computer and boot to the internal SSD
If all goes well your /home
is not in the default location in the SSD.
To access the /oldhome
partition with Nautilus you will need to go to Other Locations on the left margin and click on the Computer icon and navigate to oldhome
.
Hope this helps
I'll try to answer with no-live-boot-required method.
- Boot your PC and wait for grub-menu to appear
- When in grub menu select the "Default" option and press
e
key - Edit the line that starts with linux and append
init=/bin/bash
at the end - press CTRL+x
- after root prompt issue
mount -o remount,rw /
- make new directory for your new home:
mkdir /mnt/newhome
- mount old home:
mount /home
- mount new home:
mount /dev/ssd_partition /mnt/newhome
- copy all the data:
cp -rp /home/* /mnt/newhome/
- modify the
/etc/fstab
entry for /home mountpoint accordingly - reboot
- profit :)
This is a 1y old question but for those coming across...
I Think you miss to delete the old /home which it's still in the filesystem wasting space (have a look at the dimension of the / (root) partition)
so as explained in the other answers copy/sync all files in new partition
you do not need a live image
SYNC
- mount the new partition somewhere using the tool you prefer (I used gnome-disks with no root privileges.)
To make your life easy, give to the partition a lable other than a name so that disks will create a mount point using given lable in /media/username
- sync
sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/my_user/home/.
- add new partition in /etc/fstab but comment it out (# at the beginning) for step 5
# UUID=1234-YOUR-UID /home ext4 defaults 0 2
-
To make sure in which home folder I'm looking into, I usually create an empty file (this is optional)
$ touch /media/my_user/home/blahhhhh
Free the space no more required
-
reboot in safe mode and get a root shell (easy, just follow the messages on screen)
-
look into /home, you should not see file /home/blahhhhh
$ ls /home
because the new /home has not been mounted (line in fstab is commented ) instead the portion of / filesystem in available.
-
if you want to double check your new home partition has all files in it, mount it and look for file /home/blahhhhh
$ mkdir /new_home $ mount /dev/the_new_home_partition /new_home $ ls /new_home
*you may want to use /dev/dev_name instead the UUID: it is shorter to write.*
-
if your are happy... delete all files from old home
WARNING !!!!! be sure where you are, what are you doing... no way back
$ rm -fr /home/*
WARNING !!!!!
the new home candidate partition is still mounted at /new_home
-
edit /etc/fstab and un-comment (delete #) the entry for /home
UUID=1234-YOUR-UID /home ext4 defaults 0 2
8.reboot
-
check the space partition mounted on / (root)
Try to understand what you are doing... if you mistake, you loose everything...