ServerHandbook live check: run log ------------------------------------------------------------------------------ Check scripts/live/checks/no-space-left-on-device-ubuntu.mjs (sha256 ff7f3fd4257a895c2497ca00c2c3357d416ce29027d74ddd6acda3bf9ac9dc93) Ran at 2026-11-19T17:18:17Z (66 s) Result PASS, all 28 claims held Tested on System Ubuntu 26.04.1 LTS Kernel 7.0.0-43-generic Package coreutils 9.5-1ubuntu2+0.0.0~ubuntu25 Package util-linux 2.41.3-3ubuntu2.2 Package e2fsprogs 1.47.2-3ubuntu4 Package findutils 4.10.0-3build2 Package lsof 4.99.4+dfsg-2build2 Package systemd 259.9-0ubuntu0.1 Setup A fresh Ubuntu 26.04 server (a VM from Ubuntu’s cloud image, ext4 root filesystem), reached over SSH as the sudo user deploy. A big file in /var/tmp fills the disk for normal users; a small service keeps a deleted 1 GB log open; a small tmpfs (2000 inodes) stands in for a folder full of session files. Every version above was read from the server at run time. Passwords used on the throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test ------------------------------------------------------------------------------ What the steps changed on the server (recorded before the first step and after the last) Packages added (0) Packages upgraded (0) Packages removed (0) Services enabled at boot (0) Services disabled (0) Listening sockets opened (0) Listening sockets closed (0) Files added in /etc (0) Files changed in /etc (0) Files removed from /etc (0) Disk used on / (includes logs written during the run): -21681.1 MB ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Claims (28), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 26.04 server box (web-server) starts 2. ok (setup) the root filesystem is ext4 | ext4 3. ok (setup) nothing is left for normal users (Avail 0) | 0 4. ok cp: error copying '/etc/services' to '/home/deploy/services.copy': No space left on device | cp: error copying '/etc/services' to '/home/deploy/services.copy': No space left on device 5. ok df -h /: Use% 100%, Avail 0 | Filesystem Size Used Avail Use% Mounted on | /dev/vda1 24G 24G 0 100% / 6. ok tune2fs: Reserved block count: 0 (no reserve for root on the cloud image) | Block count: 6263035 | Reserved block count: 0 | Block size: 4096 | 0 7. ok du -x on /: /var is the biggest folder (after the total) | 6.1M /etc | 1.8G /usr | 22G /var | 24G / 8. ok du -x on /var: /var/tmp holds almost all of /var (the same size) | 70M /var/lib | 22G /var | 22G /var/tmp 9. ok find -size +100M: /var/tmp/build-cache/layer.tar | -rw-r--r-- 1 root root 133M Mar 18 2026 /usr/lib/x86_64-linux-gnu/libLLVM.so.21.1 | -rw-r--r-- 1 root root 22G Nov 19 17:18 /var/tmp/build-cache/layer.tar 10. ok journalctl --disk-usage: "Archived and active journals take up …" | Archived and active journals take up 20.9M in the file system. 11. ok the big file is removed 12. ok df -h /: space is free again | Filesystem Size Used Avail Use% Mounted on | /dev/vda1 24G 2.0G 22G 9% / 13. ok cp works again | -rw-r--r-- 1 deploy deploy 12990 Nov 19 17:19 /home/deploy/services.copy 14. ok a 1.0G log file | -rw-r--r-- 1 root root 1.0G Nov 19 17:19 /var/log/demo-app.log 15. ok after rm, df frees nothing: the space stays used (Avail changes by less than 50 MB) | 21660540928 → 21660536832 | Filesystem Size Used Avail Use% Mounted on | /dev/vda1 24G 3.0G 21G 13% / 16. ok lsof +L1: python3 holds /var/log/demo-app.log (deleted), 1073741824 bytes, NLINK 0 | COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME | systemd 1 root 235u REG 0,1 20 0 1029 /memfd:systemd-udevd (deleted) | python3 3677 root 3w REG 253,1 1073741824 0 101564 /var/log/demo-app.log (deleted) 17. ok restart the service that holds it 18. ok the restart frees the 1 GB (and the new process opens a new 1 GB file) | 21660536832 → 21660520448 19. ok lsof +L1: no deleted demo-app.log any more | 0 20. ok touch: cannot touch '/srv/cache/static/new.css': No space left on device | touch: cannot touch '/srv/cache/static/new.css': No space left on device 21. ok df -h: most of the space is still free (Use% under 10%) | Filesystem Size Used Avail Use% Mounted on | tmpfs 64M 4.0K 64M 1% /srv/cache 22. ok df -i: IUse% 100%, IFree 0 | Filesystem Inodes IUsed IFree IUse% Mounted on | tmpfs 2000 2000 0 100% /srv/cache 23. ok the files per folder: /srv/cache/sessions holds almost all of them | 1 /srv/cache/static | 1996 /srv/cache/sessions 24. ok the session files are deleted 25. ok df -i: IUse% back to 1% | Filesystem Inodes IUsed IFree IUse% Mounted on | tmpfs 2000 4 1996 1% /srv/cache 26. ok touch works again | new.css site.css 27. ok (more than 1 GB free for normal users at the end of the steps) | 22734249984 28. ok (tested on) the box reports its OS, kernel and the version of 6 package(s) | PRETTY_NAME="Ubuntu 26.04.1 LTS" | VIRT=none | KERNEL=7.0.0-43-generic | PKG coreutils 9.5-1ubuntu2+0.0.0~ubuntu25 | PKG e2fsprogs 1.47.2-3ubuntu4 | PKG findutils 4.10.0-3build2 | PKG lsof 4.99.4+dfsg-2build2 | PKG systemd 259.9-0ubuntu0.1 | PKG util-linux 2.41.3-3ubuntu2.2 ------------------------------------------------------------------------------ Commands and what they printed (23) ------------------------------------------------------------------------------ $ cp /etc/services ~/services.copy cp: error copying '/etc/services' to '/home/deploy/services.copy': No space left on device $ df -h / Filesystem Size Used Avail Use% Mounted on /dev/vda1 24G 24G 0 100% / $ sudo tune2fs -l $(findmnt -no SOURCE /) | grep -E '^(Block count|Reserved block count|Block size):' Block count: 6263035 Reserved block count: 0 Block size: 4096 $ sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 4 6.1M /etc 1.8G /usr 22G /var 24G / $ sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h | tail -n 3 70M /var/lib 22G /var 22G /var/tmp $ sudo find / -xdev -type f -size +100M -exec ls -lh {} + 2>/dev/null -rw-r--r-- 1 root root 133M Mar 18 2026 /usr/lib/x86_64-linux-gnu/libLLVM.so.21.1 -rw-r--r-- 1 root root 22G Nov 19 17:18 /var/tmp/build-cache/layer.tar $ sudo journalctl --disk-usage Archived and active journals take up 20.9M in the file system. $ sudo rm /var/tmp/build-cache/layer.tar $ df -h / Filesystem Size Used Avail Use% Mounted on /dev/vda1 24G 2.0G 22G 9% / $ cp /etc/services ~/services.copy && ls -l ~/services.copy -rw-r--r-- 1 deploy deploy 12990 Nov 19 17:19 /home/deploy/services.copy $ ls -lh /var/log/demo-app.log -rw-r--r-- 1 root root 1.0G Nov 19 17:19 /var/log/demo-app.log $ sudo rm /var/log/demo-app.log $ df -h / Filesystem Size Used Avail Use% Mounted on /dev/vda1 24G 3.0G 21G 13% / $ sudo lsof -nP +L1 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME systemd 1 root 235u REG 0,1 20 0 1029 /memfd:systemd-udevd (deleted) python3 3677 root 3w REG 253,1 1073741824 0 101564 /var/log/demo-app.log (deleted) $ sudo systemctl restart demo-app $ sudo lsof -nP +L1 | grep -c 'demo-app.log (deleted)' 0 $ touch /srv/cache/static/new.css touch: cannot touch '/srv/cache/static/new.css': No space left on device $ df -h /srv/cache Filesystem Size Used Avail Use% Mounted on tmpfs 64M 4.0K 64M 1% /srv/cache $ df -i /srv/cache Filesystem Inodes IUsed IFree IUse% Mounted on tmpfs 2000 2000 0 100% /srv/cache $ sudo find /srv/cache -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -n | tail -n 3 1 /srv/cache/static 1996 /srv/cache/sessions $ find /srv/cache/sessions -type f -name 'sess_*' -delete $ df -i /srv/cache Filesystem Inodes IUsed IFree IUse% Mounted on tmpfs 2000 4 1996 1% /srv/cache $ touch /srv/cache/static/new.css && ls /srv/cache/static new.css site.css ------------------------------------------------------------------------------ The check's source (scripts/live/checks/no-space-left-on-device-ubuntu.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB fix: "No space left on device" on Ubuntu. Break → see → fix → prove (plan04 §1): * 1. the root filesystem is full for normal users (a big file in /var/tmp; root's 5% reserve still free, so sudo * keeps working): cp fails; df -h; the reserve (tune2fs); du -x down the tree; find big files; free it * 2. df says full but du cannot find it: a service holds a deleted log open (lsof +L1); restart frees it * 3. inodes run out: a small filesystem (tmpfs, 2000 inodes) full of session files: touch fails while df -h shows * free space; df -i; count files per folder; delete them * Runs on the local VM (fallocate makes the big files at once, nothing is written). */ import { bareBox, reportBox } from '../lib.mjs' const RELEASE = process.env.LIVE_BOX_RELEASE || '24.04' const tee = (path, body) => `sudo tee ${path} > /dev/null <<'EOF'\n${body}\nEOF` const APP_UNIT = `[Unit] Description=Demo app that keeps its log open [Service] ExecStart=/usr/bin/python3 -c "import os, time; f = open('/var/log/demo-app.log', 'ab'); os.posix_fallocate(f.fileno(), 0, 1 << 30); time.sleep(10**9)" [Install] WantedBy=multi-user.target` /** df's "Avail" column for / in bytes (what a normal user may still write) */ const avail = (L, path = '/') => Number(L(`df -B1 --output=avail ${path} | tail -n 1`).trim()) const check = (ctx) => bareBox(ctx, async ({ sudoUser }) => { const { run, L } = sudoUser() // ── hidden: a full disk, as a reader finds it ────────────────────────────────────────── const fs = L('findmnt -no FSTYPE /') ctx.check('(setup) the root filesystem is ext4', /(^|\n)ext4$/.test(fs), fs) // journald frees its archived files when the disk fills (24.04 freed ~6 MB right after every fill): clear them first, // so the full disk stays full L('sudo journalctl --rotate && sudo journalctl --vacuum-size=1 >/dev/null 2>&1') L('sudo mkdir -p /var/tmp/build-cache') L(`sudo fallocate -l $(df -B1 --output=avail / | tail -n 1) /var/tmp/build-cache/layer.tar`) // whatever frees a little space after the fill (journald trims its own files on 24.04) is taken again just before const topUp = () => L('a=$(df -B1 --output=avail / | tail -n 1); [ "$a" -gt 0 ] && sudo fallocate -o $(stat -c %s /var/tmp/build-cache/layer.tar) -l $a /var/tmp/build-cache/layer.tar; true') topUp() const a0 = avail(L) ctx.check('(setup) nothing is left for normal users (Avail 0)', a0 === 0, String(a0)) // ── 1. the error, and which filesystem ────────────────────────────────────────────────── topUp() const e1 = run('cp /etc/services ~/services.copy', { id: 'cp' }) ctx.check("cp: error copying '/etc/services' to '/home/deploy/services.copy': No space left on device", /cp: error copying '\/etc\/services' to '\/home\/deploy\/services\.copy': No space left on device/.test(e1.out) && e1.exit !== 0, e1.out) L('rm -f ~/services.copy') const d1 = run('df -h /', { id: 'df-full' }) ctx.check('df -h /: Use% 100%, Avail 0', /\s0\s+100%\s+\/$/m.test(d1.out), d1.out) const r1 = run("sudo tune2fs -l $(findmnt -no SOURCE /) | grep -E '^(Block count|Reserved block count|Block size):'", { id: 'reserved' }) const n = (k) => Number((r1.out.match(new RegExp(`^${k}:\\s+(\\d+)`, 'm')) ?? [])[1]) const pct = n('Reserved block count') / n('Block count') // Ubuntu's cloud image is made with no reserve for root (seen 2026-11-19): root is out of space too ctx.check('tune2fs: Reserved block count: 0 (no reserve for root on the cloud image)', n('Reserved block count') === 0 && n('Block count') > 0, `${r1.out}\n${pct}`) // ── 2. find what fills it ─────────────────────────────────────────────────────────────── const u1 = run('sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 4', { id: 'du-root' }) ctx.check('du -x on /: /var is the biggest folder (after the total)', /\s\/var\n\S+\s+\/$/.test(u1.out), u1.out) const u2 = run('sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h | tail -n 3', { id: 'du-var' }) // /var and /var/tmp are the same size, so their order is not fixed: both lines, same size const sz = (p) => (u2.out.match(new RegExp(`^(\\S+)\\s+${p}$`, 'm')) ?? [])[1] ctx.check('du -x on /var: /var/tmp holds almost all of /var (the same size)', Boolean(sz('/var/tmp')) && sz('/var/tmp') === sz('/var'), u2.out) const f1 = run("sudo find / -xdev -type f -size +100M -exec ls -lh {} + 2>/dev/null", { id: 'find-big' }) ctx.check('find -size +100M: /var/tmp/build-cache/layer.tar', /\/var\/tmp\/build-cache\/layer\.tar$/m.test(f1.out), f1.out) const j1 = run('sudo journalctl --disk-usage', { id: 'journal-usage' }) ctx.check('journalctl --disk-usage: "Archived and active journals take up …"', /Archived and active journals take up \S+ in the file system\./.test(j1.out), j1.out) const rm1 = run('sudo rm /var/tmp/build-cache/layer.tar', { id: 'rm-big' }) ctx.check('the big file is removed', rm1.exit === 0, rm1.out) const d2 = run('df -h /', { id: 'df-freed' }) ctx.check('df -h /: space is free again', avail(L) > 1e9 && !/100%/.test(d2.out), d2.out) const e2 = run('cp /etc/services ~/services.copy && ls -l ~/services.copy', { id: 'cp-ok' }) ctx.check('cp works again', /services\.copy$/.test(e2.out), e2.out) L('rm -f ~/services.copy') // ── 3. deleted, but still open ────────────────────────────────────────────────────────── L(tee('/etc/systemd/system/demo-app.service', APP_UNIT)) L('sudo systemctl daemon-reload && sudo systemctl start demo-app && sleep 2') const before = avail(L) const lg = run('ls -lh /var/log/demo-app.log', { id: 'open-ls' }) ctx.check('a 1.0G log file', /\s1\.0G\s.*\/var\/log\/demo-app\.log$/.test(lg.out), lg.out) run('sudo rm /var/log/demo-app.log', { id: 'open-rm' }) L('sync; sleep 1') const after = avail(L) const d3 = run('df -h /', { id: 'df-open' }) ctx.check('after rm, df frees nothing: the space stays used (Avail changes by less than 50 MB)', Math.abs(after - before) < 50e6, `${before} → ${after}\n${d3.out}`) const l1 = run('sudo lsof -nP +L1', { id: 'lsof' }) ctx.check('lsof +L1: python3 holds /var/log/demo-app.log (deleted), 1073741824 bytes, NLINK 0', /^python3\s+\d+\s+root\s+\S+\s+REG\s+\S+\s+1073741824\s+0\s+\d+\s+\/var\/log\/demo-app\.log \(deleted\)$/m.test(l1.out), l1.out) const rs = run('sudo systemctl restart demo-app', { id: 'open-restart' }) ctx.check('restart the service that holds it', rs.exit === 0, rs.out) L('sync; sleep 1') const freed = avail(L) ctx.check('the restart frees the 1 GB (and the new process opens a new 1 GB file)', freed > after - 50e6 && L('ls /var/log/demo-app.log') === '/var/log/demo-app.log', `${after} → ${freed}`) const l2 = run("sudo lsof -nP +L1 | grep -c 'demo-app.log (deleted)'", { id: 'lsof-after' }) ctx.check('lsof +L1: no deleted demo-app.log any more', /^0$/.test(l2.out), l2.out) L('sudo systemctl stop demo-app && sudo rm -f /var/log/demo-app.log /etc/systemd/system/demo-app.service && sudo systemctl daemon-reload') // ── 4. out of inodes ──────────────────────────────────────────────────────────────────── L('sudo mkdir -p /srv/cache && sudo mount -t tmpfs -o size=64M,nr_inodes=2000,mode=1777 tmpfs /srv/cache') L("mkdir -p /srv/cache/sessions /srv/cache/static && echo 'body{}' > /srv/cache/static/site.css") L("cd /srv/cache/sessions && i=0; while touch sess_$i 2>/dev/null; do i=$((i+1)); done; echo $i") const t1 = run('touch /srv/cache/static/new.css', { id: 'inode-touch' }) ctx.check("touch: cannot touch '/srv/cache/static/new.css': No space left on device", /cannot touch '\/srv\/cache\/static\/new\.css': No space left on device/.test(t1.out), t1.out) const i1 = run('df -h /srv/cache', { id: 'inode-df-h' }) ctx.check('df -h: most of the space is still free (Use% under 10%)', /\s([0-9])%\s+\/srv\/cache$/m.test(i1.out), i1.out) const i2 = run('df -i /srv/cache', { id: 'inode-df-i' }) ctx.check('df -i: IUse% 100%, IFree 0', /\s0\s+100%\s+\/srv\/cache$/m.test(i2.out), i2.out) const i3 = run("sudo find /srv/cache -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -n | tail -n 3", { id: 'inode-count' }) ctx.check('the files per folder: /srv/cache/sessions holds almost all of them', /^\s*19\d\d \/srv\/cache\/sessions$/m.test(i3.out), i3.out) const i4 = run("find /srv/cache/sessions -type f -name 'sess_*' -delete", { id: 'inode-delete' }) ctx.check('the session files are deleted', i4.exit === 0, i4.out) const i5 = run('df -i /srv/cache', { id: 'inode-df-i-after' }) ctx.check('df -i: IUse% back to 1%', /\s1%\s+\/srv\/cache$/m.test(i5.out), i5.out) const t2 = run('touch /srv/cache/static/new.css && ls /srv/cache/static', { id: 'inode-touch-ok' }) ctx.check('touch works again', /new\.css/.test(t2.out), t2.out) L('sudo umount /srv/cache && sudo rmdir /srv/cache') // ── end state ─────────────────────────────────────────────────────────────────────────── const e = avail(L) ctx.check('(more than 1 GB free for normal users at the end of the steps)', e > 1e9, String(e)) ctx.stepsDone() reportBox( ctx, L, `A fresh Ubuntu ${RELEASE} server (${process.env.LIVE_VPS ? 'a rented cloud server, rebuilt to the provider’s stock image' : 'a VM from Ubuntu’s cloud image'}, ext4 root filesystem), reached over SSH as the sudo user deploy. A big file in /var/tmp fills the disk for normal users; a small service keeps a deleted 1 GB log open; a small tmpfs (2000 inodes) stands in for a folder full of session files.`, ['coreutils', 'util-linux', 'e2fsprogs', 'findutils', 'lsof', 'systemd'], ) }) export default check