Live Blog

Increasing Ramdisk tmpfs Partition on Ubuntu

Content Error or Suggest an Edit

Notice a grammatical error or technical inaccuracy? Let us know; we will give you credit!

Introduction

This live blog entry is specific to GridPane mostly, but can be use for other platforms that use Linux or specifically Ubuntu. You might have seen the following message when from monit which is deployed on GridPane servers.

[2025-01-14T15:13:07-0500] error    : 'run_ramdisk_usage' status failed (1) -- /run ramdisk warning | tmpfs           3.2G  3.1G  129M  97% /run

If you take a look at your mounted filesystems by running ‘df’ you will see /run is taking up 97% disk space.

❯ df -h                                                                                                                                                                                  
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           3.0G  2.9G  3.0G  97% /run
/dev/vda2       469G  211G  238G  47% /
tmpfs            16G  568K   16G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            16G  5.1M   16G   1% /tmp
/dev/vda1       511M  6.1M  505M   2% /boot/efi
tmpfs           3.2G  4.0K  3.2G   1% /run/user/0
tmpfs           3.2G  4.0K  3.2G   1% /run/user/1002

You can use the command du or ncdu (can be installed via apt-get install ncdu) to see the directories sizes to find out what is using the most space.

❯ du . --max-depth=1 -h                                                                                                                                                                 
0       ./needrestart
4.0K    ./redis
0       ./motd.d
0       ./nginx-proxy-cache
2.9G    ./nginx-cache
0       ./sshd
4.0K    ./netdata
4.0K    ./mysqld

As you can see, the nginx-cache folder is taking up a considerable amount of space. This is to be expected if you’re using Nginx fastcgi for PHP caching. The following nginx config within GridPane utilizes the /run folder.

fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=FASTCGICACHE:100m max_size=6045m inactive=7d;

The /var/run directory is a symlink to /run in this instance.

What is tmpfs?

The tmpfs filesystem is a temporary filesystem in Linux (including Ubuntu) that stores files in volatile memory (RAM) instead of on a persistent disk. It is often used for storing temporary files that do not need to be retained after a system reboot.

Files stored in tmpfs are faster to access compared to traditional disk storage since they reside in memory. However, since it uses RAM, the storage capacity is limited by the amount of available memory.

A common use of tmpfs is for directories like /tmp or /run, which typically hold temporary system or application files.

Resolution

The resolution is actually pretty straight forward, since it looks like we’re running out of space for Nginx fastcgi cache, we need to increase the /run tmpfs file system. You can run one command to extend the /run partition which is using tmpfs.

The following command, will change the size of the /run partition to 6G and remount it. No restart is required of the system or Nginx service.

Attention

Make sure that you have enough system memory to allow for a 6GB tmpfs partition, as it uses the systems memory. If there is no system memory available, then swap will be used which is slower.

mount -o remount,size=6G /run

You should then see an increase of the /run partition through df as seen below.

❯ df -h                                                                                                                                                                                  
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           6.0G  3.1G  3.0G  51% /run
/dev/vda2       469G  211G  238G  47% /
tmpfs            16G  568K   16G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            16G  5.1M   16G   1% /tmp
/dev/vda1       511M  6.1M  505M   2% /boot/efi
tmpfs           3.2G  4.0K  3.2G   1% /run/user/0
tmpfs           3.2G  4.0K  3.2G   1% /run/user/1002

0 Shares: