0

Context I freshly installed some small VMs with Ubuntu server 20.04 with default installation settings. The applications I run on them already warned me about limited free disk space, which is odd, because I run the same applications on 18.04 and the VM disk size is the same as before.

I ran df -H and discovered some partitions of type tmpfs I had never seen before. Some researching and I discover they are ramdisk partitions.

The ram disk feature is nice, but my applications are already caching their data, so this feature is basically useless for my use case.

Workaround: My current workaround is simple: I'm not going to put running systems at risk by trying to remove the ram disk partitions, potentially causing system failures. I've already ordered a bigger hard disk for the host, then it will simply be a matter of cloning the disk and resizing some VMs and partitions.

Question My question is: should I want to install another Ubuntu server, how can I disable this ramdisk feature from the start?

1
  • I do not understand how disabling RAM disks could (noticeably) lower permanent disk space requirements. RAM disks reside in RAM, not on permanent disk. Only if you are short on RAM then RAM disks could be partially and temporarily moved to swap which resides on a permanent disk. --- It is the growth of Ubuntu size what takes more disk space in the newer version. To get smaller disk space requirement install Ubuntu Server or one of the flavours: ubuntu.com/download/flavours Also you can try to uninstall some unneeded packages. Nov 24, 2021 at 10:18

1 Answer 1

1

You are somewhat correct that the tmpfs results you are seeing in the output of df -h "a sort of RAM disk", but there's much more to these locations than meets the eye. Allow me to explain why they exist and whether they can be removed or not.

Each of these locations are actually API file systems and are critical to the operation of a systemd-based system. systemd mounts these locations during system initialisation literally before it does anything else.

Let's look at each of these, and why they exist:

/dev/shm

This exists pretty much only on Debian-based operating systems. /dev/shm is actually /run/shm on other distributions such as Fedora and SuSE. This tmpfs has the specific purpose of implementing POSIX shared memory on your operating system. Removing it will cause applications that use POSIX shared memory to fail.

This would be a bad thing.

/sys/fs/cgroup

This is where systemd and other daemons mount the various control group hierarchies that are available on your operating system. Removing it will stop the parts of your operating system, that depend from control groups, working.

This, too, would be a bad thing.

/tmp

As the name suggests, this is where applications expect to be able to put short-stay temporary files. Removing it will make a fair number of tools that use temporary files rather crashy.

Naturally, this would be a bad thing.

/run

This used to be /var/run and is where specialised types of temporary files that can potentially last until the next system bootstrap are placed. In /var/run you will find your PID files, the systemd non-persistent journal, UNIX-domain sockets, FIFOs, and other similar things. Removing it will make the systemd journal grow error logs as fast as your storage device can record them; break the vast majority of daemons that still, even today, use PID files; and wreck udev, the systemd "multi-seat" system, plus a whole bunch of other subsystems.

Do not do this unless you wish to see just how ungracefully an operating system can fail.

/dev

This is generally where you will find all of the device files for character and block devices are stored on Linux. A lot of programs and subsystems expect conventional names like /dev/tty, /dev/null, /dev/zero, /dev/console, /dev/fd/0, /dev/sda, and so forth to work. Removing this will break so much of the system that it would become effectively useless. This is a devtmpfs rather than a tmpfs, the difference being that the former is automatically populated and unpopulated with device file entries by the kernel itself, as devices are loaded/enabled and disabled/unloaded in the kernel.

While each of these locations do consume additional memory, the system is generally smart enough to know when these should exist in RAM and when they can be shuffled off to swap. Unless you are running a system with less than 768MB of total memory (RAM plus all swap files and — optionally — partitions), you should be fine.

I hope this answers your questions.

1
  • Thanks @Matigo If I remember correctly, with Ubuntu 16.04 and 18.04, when creating a "60 GB Ubuntu server VM" I would have roughly 45-50 GB available for applications and their data. With Ubuntu 20.04, the remaining space looks very different, around 25 GB are available on the primary partition. Now I know _why_ there are such partitions but I don't know how to prevent that if I were to install another VM. Are there any options I can choose during initial installation of the OS that allow me to maximize the available space on disk? Jan 23, 2021 at 12:36

You must log in to answer this question.

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