How to Fix “Low on Space in /run” Error on Ubuntu: A Sysadmin’s Guide


2 views

When you see warnings about low space in /run on Ubuntu (especially older versions like Precise), it typically indicates that temporary system files are consuming too much space. The /run directory is a tmpfs filesystem that stores volatile runtime data.

$ df -h | grep run
none             50M   40M   11M  79% /run
none            5.0M     0  5.0M   0% /run/lock
none            249M     0  249M   0% /run/shm

The default allocation for /run in older Ubuntu versions was often too small (typically 50MB). Modern services and frequent system operations can quickly fill this space.

First, identify what's consuming space:

$ sudo du -sh /run/*
4.0K    /run/acpid.socket
12M     /run/dbus
8.0K    /run/network
...

To temporarily clear space:

$ sudo service rsyslog restart  # Clears /run/rsyslogd.pid
$ sudo service dbus restart    # Clears DBus runtime files

Edit /etc/fstab to modify the tmpfs allocation:

proc            /proc       proc    defaults    0 0
/dev/sda1       /           ext3    defaults,errors=remount-ro,noatime    0 1
/dev/sda2       none        swap    sw          0 0
tmpfs           /run        tmpfs   defaults,size=100M    0 0

Then remount:

$ sudo mount -o remount /run

For systems with limited RAM, consider moving some runtime files to disk:

$ sudo mkdir -p /var/run/newlocation
$ sudo nano /etc/rc.local
# Add before 'exit 0':
mount --bind /var/run/newlocation /run/someservice

Create a cron job to monitor /run space:

#!/bin/bash
THRESHOLD=80
CURRENT=$(df /run --output=pcent | tail -1 | tr -d '% ')
if [ "$CURRENT" -gt "$THRESHOLD" ]; then
    logger -t RUNSPACE "Warning: /run is ${CURRENT}% full"
    # Add cleanup commands here
fi
  • Regularly clean old session files
  • Consider upgrading to a newer Ubuntu version with better defaults
  • Monitor systemd services (if available) for runaway processes

When your Ubuntu system shows high utilization in /run (79% in this case), it's typically because tmpfs mounts are consuming more memory than allocated. The /run directory is crucial for storing runtime data like PID files, sockets, and temporary system state information.

From the provided df -h output, we can see:

none             50M   40M   11M  79% /run
none            5.0M     0  5.0M   0% /run/lock
none            249M     0  249M   0% /run/shm

The key issue here is the default 50MB allocation for /run while /run/shm gets 249MB. Modern systems often need more space in /run.

Since /run is mounted as tmpfs (using RAM), we can adjust its size through fstab. First, check current mounts:

mount | grep run
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=50M)

To increase the size, edit /etc/fstab and add this line:

tmpfs   /run    tmpfs   rw,noexec,nosuid,size=200M 0 0

After modifying fstab, you'll need to:

sudo umount /run
sudo mount /run
sudo service dbus start  # Example service that might need restarting

Check the new allocation:

df -h /run

If services fail to start, examine journal logs:

journalctl -xe

For systems using systemd, you can create a configuration file:

# /etc/tmpfiles.d/run-size.conf
D /run 0755 root root -

1. The size parameter affects RAM usage
2. Don't set it larger than available RAM
3. Some services might need manual restart after changes
4. Consider cleaning old files in /run periodically

# Example cleanup script
find /run -type f -mtime +7 -delete