6

In bash (and over ssh) running rm FILENAME gives the error: rm: cannot remove 'FILENAME': Disk quota exceeded. I've seen the other posts (and everyting down the first page of google) on this topic and have tried:

echo "" > FILENAME
cp /dev/null FILENAME
cat /dev/null >FILENAME

and all give the same error. This has happened to me once before and one of the things above fixed it, but for whatever reason that isn't working this time. Is there some sort of more powerful method to remove or write 0 bytes to a file?

I don't have sudo access on the system. This is on a unix system.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
  • Is it possible that even by writing zero bytes to your file you might still be over the quota? – scrowler Sep 16 '15 at 00:58
  • @RobbieAverill I didn't think it was possible to be _that much_ at the limit, but that probably is a possibility –  Sep 16 '15 at 01:00
  • @JoshGribbon of course it is. Easy example that you have 5gb of data stored, your sysadmin changes your limit from 10gb to 2gb. You now have to delete 3gb of files to be *at* your limit again, but by the sounds of it the system won't let you delete anything because it in turns needs to write something somewhere. – scrowler Sep 16 '15 at 01:04
  • @dfeuer Sorry, I added the OS. And I'm kinda new to asking questions on SO. After searching again it seems most of these type of questions were on superuser, should I delete this and ask it there? –  Sep 16 '15 at 01:05
  • @JoshGribbon it's likely to be migrated for you – scrowler Sep 16 '15 at 01:05
  • 4
    may be your rm is aliased – YOU Sep 16 '15 at 01:06
  • @RobbieAverill I'm guessing that the quota wasn't changed, but I must just be right at the limit. I was `scp`ing some pdfs in when I reached the limit –  Sep 16 '15 at 01:06
  • @YOU `type rm` returns `rm is /bin/rm`. From a quick search at least that would seem to mean it's not aliased –  Sep 16 '15 at 01:09
  • As @YOU suggests, it's possible your shell is playing games behind your back. Try `/bin/rm`. Also, "Unix" is not specific enough. Is it Fedora Linux version X, CentOS version y, Ubuntu version z, NixOS, FreeBSD n, NetBSD m, ....? –  Sep 16 '15 at 01:11
  • @dfeuer `bin/rm` had the same error. Its a system hosted by my university, that's all the info I could find on it. I'm on ubuntu if that helps but what what I understand all the commands would be run on the university's machines –  Sep 16 '15 at 01:16
  • try `uname -a` for more system info. also try force delete by `rm -f FILENAME` or may try deleting everything in temp directory `rm -rf /tmp/*`, with under your user priviledge (not root or sudo) – YOU Sep 16 '15 at 01:37
  • @YOU `uname -a` gives: `Linux gump 3.2.0-51-generic #77-Ubuntu SMP Wed Jul 24 20:18:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux ` so it looks like it's Ubuntu. `rm -f` had the same disk quote problem, and `rm -rf /tmp/*` gave `Operation not permitted` –  Sep 16 '15 at 01:50
  • try `find . -name "FILENAME" -delete` if your find support delete option. – YOU Sep 16 '15 at 01:58
  • 1
    also if your FILENAME is 0 bytes or less than a block in file system, then echo, cp, cat won't make it better, try finding bigger files that can delete and use those. – YOU Sep 16 '15 at 02:01
  • @YOU didn't know about the other site, I'll try there, thanks! –  Sep 16 '15 at 02:02
  • The accepted answer of [this post](https://superuser.com/questions/546219/rm-filename-not-removed-disc-quota-exceeded) worked for me. – fredq Nov 08 '18 at 15:04

4 Answers4

2

Something is trying to write to your disk. This error usually occurs with network disks.

Try opening a text file, delete contents and save it. Using this command to re-check disk space:

df -h
Mathieu
  • 2,679
  • 1
  • 20
  • 25
Thoan
  • 31
  • 2
1

I had the same problem, and none of the usually suggested solutions, the ones you list, worked.

But I realized that it was possible to delete the smallest files < 1kb. I just had to find enough small files to be able again to clean up large ones with rm.

0

For me, I solve the problem by overwriting some exsisted small files on the disk. Specifically, python will do. Once the disk has some free space (say 1M), rm will recover.

-3

Go into the directory with FILENAME and run the command

find . -name "FILENAME" -exec $(which rm) -rf {} \;
user1717828
  • 3,512
  • 6
  • 23
  • 32
  • 5
    Curious. How is that any different to the straightforward `/bin/rm FILENAME` that has been stated as not working? – roaima Sep 23 '15 at 13:33
  • 1
    @roaima I've found that running `rm` through `find` gives me different errors when stuff like this happens (usually when I mess up environmental variables in bash by running a wild script or the like). I see the community doesn't approve of the suggested solution, but I will wait until Josh tries it and gives feedback before deleting it. – user1717828 Sep 23 '15 at 14:05
  • @user1717828 While `rm` may be aliased, `/bin/rm` is not and your command is trictly equivalent to `/bin/rm` as noted by roaima. – xhienne Sep 10 '17 at 17:49