Home / OCI

OCIRunbookIntermediate

Sev1: OCI Linux instance root filesystem is 100% full and services are down

Root at 100% stops databases, web servers, SSH logins and the Cloud Agent. Free space safely, find what filled the disk, grow the boot volume online and stop it happening again.

Deepak Bhardwaj6 min read

Applies toOCI Compute VM and bare metal instances; Oracle Linux 7/8/9, Ubuntu 22.04/24.04; paravirtualized and iSCSI boot volumes; OCI CLI 3.x

Symptoms

  • Applications fail with No space left on device, databases stop accepting writes, and web servers return 500s.
  • SSH logins hang or drop straight after authentication, because the shell cannot write to /var or /tmp.
  • systemctl units fail to restart and journalctl shows write errors.
  • Oracle Cloud Agent plugins stop reporting, so metrics for the instance go flat in Monitoring.

1. Get a shell (2 minutes)

Try SSH first. If the login hangs, use the serial console connection from the console (Compute > Instances > instance > Console connection) or Bastion. Run Command needs the Cloud Agent, which may also be failing on a full disk.

Once in, confirm it is space and not inodes:

df -hT /
df -i /

Use% at 100% means blocks. IUse% at 100% means millions of small files (session files, mail queue, cache directories). Both stop writes, but you clean them up differently.

2. Free enough space to stabilise

You need a few hundred MB to get services and logins working again. Do the safe, quick wins first.

# systemd journal: keep the last 200 MB
sudo journalctl --vacuum-size=200M

# package caches
sudo dnf clean all          # Oracle Linux 8/9
sudo yum clean all          # Oracle Linux 7
sudo apt-get clean          # Ubuntu

# old rotated and compressed logs
sudo find /var/log -type f \( -name "*.gz" -o -name "*.[0-9]" -o -name "*-[0-9]*" \) -mtime +3 -print -delete

Then look for files that were deleted but are still held open. This is the most common reason du and df disagree:

sudo lsof -nP +L1 | awk 'NR==1 || $7 > 104857600'   # open, deleted, larger than 100 MB

Warning

Do not rm a log file that a process still writes to. The space is not released until the process closes it. Truncate it instead, or restart the process that holds it.

# truncate a live log in place
sudo truncate -s 0 /var/log/myapp/app.log

# release a deleted-but-open file without restarting (PID and FD from lsof)
sudo truncate -s 0 /proc/<PID>/fd/<FD>

3. Find what filled the disk

Stay on the root filesystem (-x) so you do not walk NFS or block volume mounts:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -15
sudo du -xh --max-depth=2 /var 2>/dev/null | sort -h | tail -15
sudo find / -xdev -type f -size +1G -printf '%s\t%p\n' 2>/dev/null | sort -n | tail -20

For inode exhaustion, count files per directory:

sudo find / -xdev -type f 2>/dev/null | cut -d/ -f2-3 | sort | uniq -c | sort -n | tail -15
What you find Likely cause Fix
/var/log/<app> tens of GB Debug logging left on, or no logrotate rule Truncate, add a logrotate rule, lower the log level
/var/log/journal large No SystemMaxUse in journald Vacuum and set SystemMaxUse=
/var/lib/docker or /var/lib/containers Old images, stopped containers, container logs docker system prune / podman system prune after checking
Core dumps in /var/lib/systemd/coredump or /var/crash Crash loop in a service Fix the crash, then remove the dumps
Database files on / Data, archive logs or dumps written to the boot volume Move to a block volume; clear archived logs with the database tool, never rm
Huge /tmp or home directory Ad hoc exports or backups Move to Object Storage or a block volume
lsof +L1 shows big deleted files Log deleted while open Restart or truncate through /proc

Caution

Do not delete database archive logs, redo logs, WAL or binlogs with rm to free space. Use RMAN, pg_archivecleanup or PURGE BINARY LOGS so the database knows they are gone. Otherwise you can break recovery and replication.

4. Grow the boot volume online

If the data is legitimate, add space. Boot volumes can be resized while the instance runs. Take a backup first if you can afford the minutes.

INSTANCE=ocid1.instance.oc1..xxxx
COMP=ocid1.compartment.oc1..xxxx
AD=$(oci compute instance get --instance-id $INSTANCE --query 'data."availability-domain"' --raw-output)

BV=$(oci compute boot-volume-attachment list --compartment-id $COMP \
  --availability-domain $AD --instance-id $INSTANCE \
  --query 'data[0]."boot-volume-id"' --raw-output)

oci bv boot-volume get --boot-volume-id $BV --query 'data."size-in-gbs"'
oci bv boot-volume update --boot-volume-id $BV --size-in-gbs 200 --wait-for-state AVAILABLE

Sizes can only go up. Check the current limits for your tenancy before you choose a size.

Now get the OS to see the new size. On a paravirtualized boot volume, rescan the device:

lsblk
sudo dd iflag=direct if=/dev/oracleoci/oraclevda of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/$(readlink /dev/oracleoci/oraclevda | cut -d'/' -f2)/device/rescan

For an iSCSI-attached boot volume, the console shows the rescan commands after the resize. Then extend the partition and filesystem. On Oracle Linux platform images:

sudo /usr/libexec/oci-growfs -y
df -h /

On other images use growpart and then xfs_growfs / (XFS) or resize2fs (ext4), plus lvextend -r if root is on LVM.

5. Recover services

sudo systemctl --failed
sudo systemctl restart <service>
sudo systemctl status oracle-cloud-agent      # name may vary by image; check systemctl list-units | grep -i agent

Databases on a full disk may need crash recovery on start. Check their logs before you send traffic back.

Verify

  • df -h / and df -i / show comfortable headroom (aim for below 80%).
  • systemctl --failed is empty and application health checks pass.
  • Cloud Agent metrics (CpuUtilization, MemoryUtilization in oci_computeagent) are reporting again.

Prevent it next time

  • Put application data, database files and container storage on block volumes, not the boot volume.
  • Set SystemMaxUse=1G in /etc/systemd/journald.conf and give every application log a logrotate rule with maxsize.
  • Alert on disk usage before it reaches 100%. The default oci_computeagent metrics cover disk I/O, not free space. Check Metrics Explorer for what your agent version publishes, or post usage as a custom metric from cron (oci monitoring metric-data post) and alarm on it at 85%.
  • Attach a boot volume backup policy, so you always have a recent restore point before you make emergency changes.
  • Review core dump settings (/etc/systemd/coredump.conf) on hosts that run crash-prone services.