3

I accidentally filled up my hard drive and I cannot recover from it.

I've deleted several Gigabyte of files, but the df command still shows that the disk is full, and even a simple echo hello > aFile results in the error write error: No space left on disk. Here is the command output of the relevant line of df

Filesystem Size Used Avail Use% Mounted on /dev/mapper/mint--vg-root 441G 421G 0 100% / 

From reading other similar questions/answers, I'm aware that Linux does not delete files that are part of active processes, even if they disappear from the file system. Most accepted solutions involve restarting the process holding the file open or rebooting the computer. I've rebooted several times after deleting files and I still have the same issue. Using all the inodes can result in a similar error but my inode use is 18%.

I'm also aware that the system reserves space for the root user and that df does not report this accurately. In my case, the difference between disk size and used is 20G. I can write files as root, but I don't know how to make use of this fact.

In case it's relevant, my system is set up to use KDE on Linux Mint. I only have one LUKS-encrypted ext4 partition.

The disk space being full stops the X server starting as the system cannot write to a lock file so I end up having three options:

  1. log in via TTY1 into a terminal,
  2. sudo startx which launches a Cinnamon graphical environment,
  3. Boot a live CD/USB.

What should I do to recover my disk space?

14
  • Boot in recovery mode/from LiveCD, e2fsck /dev/device, check again. Lastly, are you sure you're in the right directory? You could be trying to create a file in another directory which e.g. belongs to a full partition/mount point. Commented Dec 27, 2022 at 8:37
  • I will try a LiveCD in a few minutes. Yes, I'm sure I'm in the right directory. In addition, startx run as a normal user from TTY1 also cannot write to various files in /tmp Commented Dec 27, 2022 at 8:45
  • might be a long shot but have you tried trimming your disks with fstrim? For example run fstrim -av and see if there will be a difference in size Commented Dec 27, 2022 at 9:04
  • 2
    you can disable ext4 root reserve with tune2fs -m 0. alternatively set it to 1% instead of the default 5% to leave a (smaller) reserve for root. in the long term you'll just have to provide more storage space if you're that close to full capacity… that or use ncdu and similar to identify space hogs (log files, caches, ...) Commented Dec 27, 2022 at 9:40
  • 1
    @Mehmet 5% of 441G is around 22G, while 1% is only around 4.5GB, I second frostschutz's suggestion to reduce root's reserve to 1%. BTW, if you haven't already done so, you can probably regain a lot of space by deleting packages downloaded by your package manager. eg. Debian (etc) store downloaded .deb files in /var/cache/apt/archives. You can delete them with apt-get clean. Other distros will differ. Also, /var/cache and /var/log are good places to search for stuff that can be deleted. Also worth considering: switch to btrfs or zfs or some other fs with transparent compression. Commented Dec 27, 2022 at 10:58

1 Answer 1

1

A solution without tune2fs.

I'm also aware that the system reserves space for the root user […]. I can write files as root, but I don't know how to make use of this fact.

The default 5% does not mean "5% for root", it means "the last 5% for root, regardless of who uses the rest". So if root manages to use up at least some of these 5% then you need to remove enough files (root's or anyone's files) to actually raise the free space (available to root) above the threshold; only then a non-root user will see space left and be able to use it.

What you deleted apparently was not enough. Delete more.

Note if you delete regular users' files and root takes the reserved space again, and you delete some other regular users' files, then the root will be able to take the resulting free space as reserved space again. It doesn't matter root used the reserved space in the past and has freed nothing since.

I wrote "5%" because it's the default. The conclusions apply to any non-zero reserved space.

2
  • Note: a solution with tune2fs may be better in some cases, but I don't want to steal it from the user who mentioned it in comments. Hopefully the user will post an answer. Commented Dec 27, 2022 at 11:10
  • This is very helpful for understanding why deleting a significant amount of files wasn't enough to solve the issue. I used the tune2fs solution to regain some control but then cleared out even more files. Commented Dec 27, 2022 at 15:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.