Skip to the page

Linux · Scenario

Disk full on a MySQL server, but du finds only half

The interviewer asks

At 1 am, MySQL on a VM stops accepting writes. df says the data disk is 100% full. You run du over the whole disk and it adds up to only about 260 GB of the 500. A teammate says they deleted a huge log file an hour ago to free space. What's happening, and what do you do?

Then

Follow-ups the interviewer asks next

  1. Why can df and du disagree?
  2. How do you prove it?
  3. How do you get the space back without restarting MySQL in the middle of the night?
  4. Ten minutes after you free the space, the disk is filling again at about 2 GB a minute. Why?
  5. What else can make writes fail with "No space left on device" while df shows free space?
  6. What's the proper fix for these logs?
  7. Which alerts would have caught this earlier?
  8. Who do you tell, and what?
  9. Has a disk filled up on you? What was it?

The answer

What a strong answer covers

  • df asks the filesystem how many blocks are used; du walks directory entries. A file deleted while a process still holds it open has no name, so du can't see it, but its blocks stay used until the last file descriptor closes.
  • Proof: lsof +L1 (or lsof | grep deleted) shows mysqld holding /var/lib/mysql/general.log (deleted) with its size; ls -l /proc/<pid>/fd shows it too.
  • Space back without a restart: truncate through the open descriptor (: > /proc/<pid>/fd/<n>), or make MySQL close and reopen the file (FLUSH GENERAL LOGS, or switch the log off). A mysqld restart also frees it, but costs downtime and a cold buffer pool.
  • The twist: the general query log is still on and logs every statement, so it fills the disk again. Turn it off (SET GLOBAL general_log = 'OFF') and find out why it was on.
  • Other causes of ENOSPC with free blocks: inodes used up (df -i), ext4's reserved blocks (5% for root by default), or a different mount point filling (MySQL's tmpdir on the root disk).
  • Don't rm files a process is writing; rename and signal it, or truncate. Never delete binlogs or data files by hand (PURGE BINARY LOGS exists for binlogs).
  • Proper fix: general log off by default; logrotate with postrotate running mysqladmin flush-logs (or copytruncate for apps that can't reopen); binlog retention set (binlog_expire_logs_seconds); logs on a separate volume from data.
  • Alerts: disk usage with a growth forecast (Prometheus predict_linear on node_filesystem_avail_bytes) that pages a team, inode usage, and big deleted-but-open files.
  • Communicates: incident channel, the app owners (writes failed from 1:00 to …), and a short postmortem on the forgotten debug setting.

The red pen

Common traps

Avoid:deleting more files at random; deleting MySQL files by hand; restarting first without knowing the cause; not knowing that deleting an open file frees nothing.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview