2011-01-10 05:22:27

by Dan Carpenter

[permalink] [raw]
Subject: ext3: deleting files doesn't free up space

I filled up my partition last night.
I deleted 5 gigs of movies.
The "Used" number went down to 125G.
The "Free" number stayed at 0.
I rebooted the system but it's still the same.

$ echo foo > foo
bash: echo: write error: No space left on device

$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 136236548 130363620 0 100% /media/old_sys

$ mount | grep old
/dev/sda1 on /media/old_sys type ext3 (rw,nosuid,nodev)
/media/old_sys/home on /home type none (rw,bind)

This is with 2.6.37-rc5+. Is there a way to debug this?

regards,
dan carpenter


2011-01-10 06:07:49

by Nick Dokos

[permalink] [raw]
Subject: Re: ext3: deleting files doesn't free up space

> I filled up my partition last night.
> I deleted 5 gigs of movies.
> The "Used" number went down to 125G.
> The "Free" number stayed at 0.
> I rebooted the system but it's still the same.
>
> $ echo foo > foo
> bash: echo: write error: No space left on device
>
> $ df .
> Filesystem 1K-blocks Used Available Use% Mounted on
> /dev/sda1 136236548 130363620 0 100% /media/old_sys
>
> $ mount | grep old
> /dev/sda1 on /media/old_sys type ext3 (rw,nosuid,nodev)
> /media/old_sys/home on /home type none (rw,bind)
>
> This is with 2.6.37-rc5+. Is there a way to debug this?
>

I don't think there is anything to debug. ext3 reserves by default 5% of
the space for root's use. You will see "Available" go positive when
"Used" is reduced to below 0.95*136236548 blocks = 129424720 blocks
roughly. You can check your numbers by running

dumpe2fs -h /dev/sda1

and checking the "Block count" and "Reserved block count" fields.

You should be able to write to the filesystem as root though, as long
as Used < Total number of blocks. And you can adjust the reserved space
with ``tune2fs -m <N>''.

See e.g https://wiki.archlinux.org/index.php/Ext3_Filesystem_Tips
(the first hit from a Google search for "ext3 reserved").

Nick

2011-01-10 06:15:56

by Daniel K.

[permalink] [raw]
Subject: Re: ext3: deleting files doesn't free up space

Dan Carpenter wrote:
> I filled up my partition last night.
> I deleted 5 gigs of movies.
> The "Used" number went down to 125G.
> The "Free" number stayed at 0.
> I rebooted the system but it's still the same.
>
> $ echo foo > foo
> bash: echo: write error: No space left on device
>
> $ df .
> Filesystem 1K-blocks Used Available Use% Mounted on
> /dev/sda1 136236548 130363620 0 100% /media/old_sys

Check out the -m option to tune2fs, which sets the reserved-blocks-percentage for the FS - the percentage of blocks reserved to the super user, which is 5% by default.

Presumably, root has filled the partition completely, and 5G worth of deleted user data is not enough to get under the 5% limit to allow for new data to be written by users.

As this partition is used for /home you might as well turn the feature off, as root should not need to have space reserved in that area of the filesystem.

tune2fs -m 0 /dev/sda1

should give regular users access to the reserved blocks.


Daniel K.

2011-01-10 07:48:12

by Rogier Wolff

[permalink] [raw]
Subject: Re: ext3: deleting files doesn't free up space

On Mon, Jan 10, 2011 at 08:22:25AM +0300, Dan Carpenter wrote:
> I filled up my partition last night.
> I deleted 5 gigs of movies.
> The "Used" number went down to 125G.
> The "Free" number stayed at 0.
> I rebooted the system but it's still the same.

Hi Dan,

The system keeps at least 5 or 10% of the total space free so that it
will always be able to find a reasonably unfragmented spot for a new
big file. That same 5 or 10% CAN be written by the root-user in
emergencies. But "root" should know it can affect the peformance of
his filesystem. Anyway, because you're still using part of the 5 - 10%
reserved-for-performance reasons, "df" will report the user-available
space as zero.

Roger.

--
** [email protected] ** http://www.BitWizard.nl/ ** +31-15-2600998 **
** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement.
Does it sit on the couch all day? Is it unemployed? Please be specific!
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ