3

I randomly get this popup notification, where the filesystem root has varying disk space, and is always < 1GB. It seems that a lot of stuff is being downloaded to the root folder, like packages and stuff. Here is a picture of my filesystems:

filesys

As you can see, the root directory has only ~200MB remaining, while I delegated a lot of space (70GB) to /home, which still has a lot of free space. In my root directory, I only have 20 GB total. I then used baobab to take a look into what is eating up all the space, and /usr and /var in root eat up ~17GB.

I looked at what are in these folders, and it seems to be all the packages and desktop applications I install, like firefox, rstudio, python, nodejs, discord, mongodb, etc. Whereas in my home folder, I see more stuff like Downloads, Desktop, and folders I've created with mkdir.

Here is the output of df -h:

enter image description here

My questions are:

  1. How do I solve this?
  2. Why are all desktop apps and packages going to root, instead of home? Should they be doing this, or should I be downloading them in my home folder?
  3. What the purpose and difference between / and /home? What should be stored where?

And a linux beginner question: Since root is the top-level directory, isn't home a subdir of it? So why does do they show as different partitions like in here

enter image description here with seemingly disjoint storage spaces?

2
  • 2 questions I have is persistent journal active on your system and What is the output from ls - al /media/$USER
    – nobody
    May 16, 2021 at 17:47
  • @pastacompany welcome... it is a good practice to copy from your terminal and paste here over screenshotting and uploading here. May 19, 2021 at 18:26

3 Answers 3

3

Generally for a desktop system (so no servers like a webserver, fileserver, or databaserver) 20Gb should be enough for root so something is wrong. 1st thing related to tracking it down:

How do I solve this?

and

I then used baobab to take a look into what is eating up all the space, and /usr and /var in root eat up ~17GB.

Find the problem :) I would advice to 1st look at /var/log/ and see if there are large files there. If so the system is generating errors and probably the same error over and over again. Have a look at that file using less, more or tail and google the error if you find one. Then do > {file} on the file to empty it. It is safe to remove all files in here that END with a digit.


The other stuff:

Since root is the top-level directory, isn't home a subdir of it?

Yes and no. You can setup Ubuntu with partitions for EVERY directory in / so that includes /home/. If you do not make a partition for /home/ it is included in the root.

To elevate your problem you could remove /home/ as a partition. But that will not FIX the issue, it will just have more space in / (see https://askubuntu.com/a/117021/15811 )

Why are all desktop apps and packages going to root, instead of home? Should they be doing this, or should I be downloading them in my home folder?

That is normal. Linux has a dedicated place for every system related or system installed file. Binaries go to a bin/ directory. Is it is a system binary an "s" is added (like sbin/).

3

There is a very good GUI application to visualize where your space is being used. It's called Disk Space Analyzer and it's installed by default in Ubuntu. It makes it very simple to see what's consuming all the space. It may be helpful to you when you're a beginner. I'm fairly experienced and I use it because it's comfortable. :)

A 20GB root partition is a little tight for a modern desktop system, I'd say. Particularly when you're using cross-distro packages like Flatpak and Snap, because they need their own dependencies, so they're fairly large.

Unfortunately, fixing this is not as easy as it could've been if you had used LVM. It's an option in the installer and it allows you to move and resize "partitions" at a later point in time. To fix this, I would recommend copying your home to an external device and reinstalling Ubuntu. If you want to use your space efficiently, there's nothing wrong with having the home directory on your root, rather than as a dedicated partition.

Apps should not be stored in your home, for the primary reason that Ubuntu is a multi-user system, so you want installed apps available to all users, while your home should be private.

There are many good reasons why Linux users like to have different partitions for different parts of the system. One of them is that different filesystems have different qualities and you need different partitions in order to use different filesystems. For instance, if you download large files using bit torrent, you do not want your home to be on a BTRFS filesystem, because the continuous writes of large files will make it very slow over time. On the other hand, you may want to use BTRFS for your /etc because BTRFS allows snapshots and reverting to previous states, so if you make some bad configurations, you can just revert everything to a known good state.

In the specific case of /home, it's also good to be able to reinstall your OS without having to touch your home. In your case, that won't be possible, since you're going to need a new partition table if you want to resize your root filesystem.

2

Let’s address each of the questions individually:

How do I solve (the lack of available space)?
⇢ The most logical method would be to allocate more storage for your root. This may not be very simple to carry out, though, depending on how your partitions are laid out on the storage device.

Why are all desktop apps and packages going to root, instead of home? Should they be doing this, or should I be downloading them in my home folder?
⇢ The /home directory is for your files, not applications. In an ideal situation, you could back up just your /home directory and never worry about applications that are stored in other locations as they are all easily replaceable and/or ephemeral in nature.

What the purpose and difference between / and /home? What should be stored where?
/ is the starting point for all of the devices on your system, including storage. If you are more familiar with Windows, you can think of / as the “My Computer” root element in the Device Manager. /home — based on the output of df — is a storage location on a disk. Linux systems do not present partitions and storage devices as separate entities in the same manner as Windows does.

And …

Since root is the top-level directory, isn't home a subdir of it? So why does do they show as different partitions like in here?
⇢ This was touched on in the previous bit, but let’s go with a visual example. Imagine you have a computer with three hard drives and an NVMe device. In Windows, this would appear in File Explorer as C:, D:, E:, and F: (keeping things simple, ignoring drive letter assignments, RAID, storage pools, etc.). In Linux, this would be seen as:

/
…
  /dev
    /dev/nvme0n1p1
    /dev/nvme0n1p2
    /dev/nvme0n1p3
    /dev/sda1
    /dev/sdb1
    /dev/sdc1
    …

These device locations are not accessed by the user in this manner, though. We would instead have a boot partition, a root partition, a swap partition, and other mounted locations. It might look something like this:

/                       # On nvme0n1p2
/boot                   # On nvme0n1p1
/data                   # On sda1
/home                   # On nvme0n1p3
/home/victor/Torrents   # On sdb1
/home/victor/Videos     # On sdc1
…

Here we see that /data is on its own disk but appears as a top-level directory, a location just for torrents is on its own disk and part of your home directory, which itself primarily exists on the NVMe device. And a directory for videos is set up the same way as the torrent directory.

Essentially the way to look at the directory structure of your system is not as a hierarchical chain of files, but instead as dynamic, device-level APIs. You tell the computer that you want to write data to /home/victor/Documents/test.txt, and the system will know you want to send data to the NVMe storage device in a manner that allows for storage and retrieval. It will take care of that for you. You tell the computer to read data from /sys/class/power_supply/BAT0/status, and the system will know to query the battery in your notebook (if you have one) to see if it’s charging or not.

The concept takes a little while to grasp if you’ve used Windows for a long time but, when things begin to click, you begin to see a lot of simplification with this method of interacting with system hardware.

You must log in to answer this question.

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