HetznerDocs

Search documentation

Find a Hetzner dedicated Linux topic

Running disk space and RAM usage

df answers “how full are the filesystems?” du answers “which folder is fat?” free answers “how much RAM and swap are used?” Together they tell you whether the dedicated server is healthy.

Two meters: a disk tank that is partly full, and a RAM bar split into used, cache, and available
Picture: df is the disk tank (watch Use%). free is RAM. Trust available more than free — Linux uses leftover RAM as cache on purpose.

Disk space right now

Free space per filesystem

df -hdf -hTdf -h / /boot /var

What you should see

Filesystem      Size  Used Avail Use% Mounted on/dev/mapper/vg0-root   49G  6.2G   41G  14% //dev/md1              974M  112M  795M  13% /boot/dev/mapper/vg0-var   410G   38G  351G  10% /vartmpfs                  63G     0   63G   0% /dev/shm

Read Use%. Above about 80% on / or /var, start cleaning or expanding LVM. 100% can stop apt, logs, and databases. df -hT adds the filesystem type column (ext4, xfs, btrfs) — what those names mean: Partitioning.

Inodes (number of files), not just bytes

df -i

What you should see

Filesystem       Inodes  IUsed   IFree IUse% Mounted on/dev/mapper/vg0-root  3276800  48210 3228590    2% //dev/mapper/vg0-var  27262976 191002 27071974    1% /var

What is using the space

Largest folders

du -h --max-depth=1 / 2>/dev/null | sort -hdu -sh /var/* /home/* /root 2>/dev/nulldu -sh /var/log /var/lib /var/cache

What you should see

1.2G	/usr3.8G	/var6.2G	/38G	/var/lib412M	/var/log88M	/var/cache

Biggest files under /var

find /var -xdev -type f -printf '%s %p' 2>/dev/null | sort -n | tail

What you should see

89123456 /var/log/journal/….journal210445312 /var/lib/mysql/ibdata1

ncdu is a nicer interactive view:

Interactive disk usage

apt install -y ncduncdu /

What you should see

ncdu 1.19 ~ Use the arrow keys to drill down, d to delete, q to quit--- / ----------------------------------------------------------    38.1 GiB [##########] /var     1.2 GiB [          ] /usr    88.0 MiB [          ] /boot

RAM and swap

Human-readable memory

free -hfree -mwatch -n 1 free -h

What you should see

               total        used        free      shared  buff/cache   availableMem:           125Gi        4.1Gi        98Gi        12Mi        23Gi        120GiSwap:          8.0Gi          0B       8.0Gi
ColumnMeaning
totalPhysical RAM the OS sees
usedIn use (includes cache depending on view)
availableWhat new programs can still get — trust this more than “free”
buff/cacheLinux using spare RAM as disk cache. This is normal.
swapOverflow on disk. Some swap use is OK. Constant heavy swap is slow.

Who is eating RAM

ps aux --sort=-%mem | headapt install -y htophtop

What you should see

USER  PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMANDmysql 882  1.2  3.1 2.1g  3.8g ?    Ssl  Apr12   4:11 mysqldroot    1  0.0  0.0  167m  12m ?    Ss   Apr12   0:08 systemd

In htop, F6 sorts. Watch MEM% and CPU%. Press q to quit. top is always there if htop is not installed.

Classic top and vmstat

topvmstat 1 5cat /proc/meminfo

What you should see

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 0  0      0 103809024 412 24117248    0    0     3    12  110  220  1  0 98  0  0

Is the disk busy?

I/O snapshot

apt install -y sysstatiostat -xz 1 5iotop -o

What you should see

Device            r/s     w/s     %utilnvme0n1          12.0     4.1      3.2nvme1n1          11.8     4.0      3.1

High %util on a disk in iostat means that device is saturated. On RAID1 both members should look similar. If one disk is much slower, check SMART.

Logs filling the disk

Journal and log sizes

journalctl --disk-usagedu -sh /var/logls -lhS /var/log | headjournalctl --vacuum-time=7d

What you should see

Archived and active journals take up 412.0M in the file system.412M	/var/log-rw-r----- 1 root systemd-journal 128M Apr 14 10:22 journalVacuuming done, freed 0B of archived journals from /var/log/journal.