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
/varor/tmp. systemctlunits fail to restart andjournalctlshows 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
rma 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
rmto free space. Use RMAN,pg_archivecleanuporPURGE BINARY LOGSso 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 /anddf -i /show comfortable headroom (aim for below 80%).systemctl --failedis empty and application health checks pass.- Cloud Agent metrics (
CpuUtilization,MemoryUtilizationinoci_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=1Gin/etc/systemd/journald.confand give every application log a logrotate rule withmaxsize. - Alert on disk usage before it reaches 100%. The default
oci_computeagentmetrics 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.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get