Moving items from /home partition to / partition

I have Ubuntu on two partitions. A 30GB partition that is supposed to hold the root, and a 240GB partition that holds the home. Currently, my root is full.

I have realized that making two partitions was a mistake, I should should have put everything together in the 240GB partition, considering that both partitions are SSDs. How can I move everything into one partition without losing my /home data already there?

From what I understand, I have to copy my /home data to a USB. Then I have to wipe the 240GB partition from a live USB, and move the data from the 30GB partition onto the 240GB partition. Afterwards, I boot from the 240GB partition, and recopy /home from the USB. Is this correct? I don't want to mess it up and lose my data or installation.

Home partition

Root partition

Root contents


Solution 1:

I have realized that making two partitions was a mistake

Not necessarily. Your choice of 30 GB for root and a separate home partition in principle is a good one. 30 GB is more than sufficient for a root partition (or perhaps just sufficient if you install plenty of snap packages or flatpak packages).

Just make sure that you control what gets stored in your root partition. That your 30 Gb root is full, is as such not normal. Maybe you have plenty of old kernels, or very large log files, or some large files lingering in /var/tmp.

Alternatively, to merge these partitions also is an option. It is a more simple setup, and there is less risk your / fills if you guard the free space overall. However, in that case, a fresh reinstall involves wiping the entire partition.

Your plan sounds good. Copy your entire /home to am USB drive formatted with a linux file system, preserving all file permissions: use rsync for that.

Then, from a live CD, you can 1) Erase the partition that was mounted to /home 2) Expand the / partition to fill the entire space 3) edit the fstab file that lives under /etc to remove the line that refers to /home and 4) copy all contents of your /home from the USB back to the /home on the root partition (again use rsync).

If done correctly, your system should boot as if nothing happened.

If it fails, just reinstall and copy your data back. Then you will be left with some needs to configure and install the software you use.

The most important in this entire story is to have good and up to date backups of your personal data. Once you have that, don't fear: nothing can go fundamentally wrong.