Today I reached the limit of the predefined partition size of my work-notebook. In order to fix this I separated the
/home directory to it's own partition. Here is how I did it 🤓
# Creating a New Partition
Open up the Disks app of ubuntu in order to create a new partition.
Make sure you set it to be of type
Give it enough space so your home directory can grow.
Leave the app open, since we will need the partition UUID later on.
First we create a backup of the current
sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
Now we can securely setup the newly created partition.
sudo vim /etc/fstab
Add the following entry and replace
????? with the UUID of your newly created partition.
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings) UUID=????? /media/home ext4 defaults 0 2
As you can see, we have set the mount-directory for the partition to
/media/home. This is because we first need to copy the files of your
/home directory to a secure location before we can securely use
/home as mount-point for our new partition.
To mount the partition under the given mount-point, we need to execute the following.
sudo mount -a
As mentioned before, we need to copy all the files to the new partition before we can securely use
/home as mount-point. In order to do so, we can use the
sudo rsync -aXS --progress --exclude='/*/.gvfs' /home/. /media/home/.
You can interrupt the command as often as you need.
rsyncwill simply start where it left if executed again 👍
# Switching from
Now that we have stored all the files within
/media/home, we can update the
/etc/fstab to use
/home as mount-point for the partition.
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings) UUID=????? /home ext4 defaults 0 2
Do not restart your system just yet!
Create a backup of your home directory and create a replacement with the following command.
cd / && sudo mv /home /old_home && sudo mkdir /home
Now we are ready to mount the new partition at
/home. Run the following to do so.
sudo mount -a
Done! You should now have your home directory within your newly crated partition 💪
# Last steps
Once you are sure that the new setup is working and that all your files are available within the new partition, you can remove the
sudo rm -r /old_home
You can also remove the
/media/home directory with the following.
sudo rm -r /media/home
Now you are really done! 🥳
# Official Documentation
Here is a link to the official ubuntu documentation to learn more about the topic.