0

I've got dual boot Ubuntu 20.04 in my computer and some days ago I'm frequently getting the "free up disk space" advice in my root partition (20GB).

When I check the disk usage, I can see /usr directory is using 7.2GB /var is using 6.1GB and /opt is using 1.1GB.

When I installed Ubuntu I didn't know how much space assign to root and home partitions so I followed tutorials and I've done 20GB to the first one and 130GB to the second one, now I have 92% usage on root and 13% on home, so I want to either give the root partition more of the space that home partition is not using or, in the other hand, move the /usr (/var and /opt too) inside the /home directory, in order to get /home/usr; home/var and home/opt structure.

I've just seen this post How to move /usr to a new partition? that is the unique available with sort of the same problem, but I don't want to create a new partition for usr, so I just copied the directory but I'm afraid to go on with the next steps.

I don't want to risk my OS with simply directly moving the directory due it seems dangerous from another forums; and clearly I don't want to preserve a copy in "/" because I need to free up space there.

I've already cleaned up older kernel versions and useless installed packages following other posts, but it isn't enough; currently I cannot go on with any Live CD solution since I don't have usb stick with me.

¿What could I do?

7
  • 2
    do? fix the issue that is filling up your /. 20Gb could be more than enough... start with /var/log/ and check for large files there. If so examine the last 100 lines and fix the error it shows, and then do sudo > {logfile} to empty it. "move the /usr (/var and /opt too) inside the /home directory" No, just no. More than likely to kill your system if you do.
    – Rinzwind
    Sep 18, 2022 at 20:03
  • 2
    and the normal method is to shrink /home and enlarge / using a live session gparted.
    – Rinzwind
    Sep 18, 2022 at 20:05
  • 1
    See How to resize partitions?. Moving /usr to inside the /home/ sounds like a very bad idea. Ubuntu may not boot after such a move, as Linux as a very strict and well defined directory structure for its system directories.
    – user68186
    Sep 18, 2022 at 20:12
  • 3
    You don't! FYI, the minimum requirements for Ubuntu Desktop are 25GB. And that's often not enough. 20 GB is insufficient. Don't follow advice or "tutorials" from sources that aren't knowledgeable or authoritative. I suggest that you reinstall. You don't need a separate home partition and it's not useful for most people. Use the default installation options which install the system to a single partition, and you'll never have this problem.
    – Nmath
    Sep 18, 2022 at 20:24
  • /var/log just freed me up 200MB... Just not enough. What else could I do? Sep 18, 2022 at 21:49

1 Answer 1

0

The fundamental solution would be to resize your partitions.

Still, several parts of the system could be moved to a separate partition and then replaced by a symbolic link. The symbolic links ensure that the conventional Filesystem Hierarchy Standard is preserved.

This is not as strange as it may sound. Historically, linux systems booted from very small partitions. Links were used to point to system files stored on separate partitions. For example, the entire /usr directory was mounted at a different partition. However, /usr in particular should nowadays not be moved because essential binaries (/bin) and libraries (/lib) have been moved to /usr/bin.

The separate partition should be formatted with a file system that supports linux permissions and be automatically mounted at boot. Your /home partition fulfills these conditions. The move should be done such that all file properties and permissions are preserved.

In principle, any files that are not used early in the boot process could be moved. You could very likely replace /opt by a symlink. Also /tmp and /var/tmp can be replaced by a symlink. Also /snap or /var/lib/flatpak likely can be replaced by a symlink, and probably others, but you will need to test this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .