Stephane Cerveau
2011-Feb-07 14:45 UTC
Compute the real total size of a partition formated in EXT3
Dear All, In order to have a real percentage of freespace for a user interface, I'm trying to compute the size available on a 4GB USB key formatted in Ext3. Indeed after format, when I ask df to give a summary of size, it tells that there is 75MB already used. I would like to know the meaning of this 75MB ( is it the journal??) and especially how I can compute this when I want, whithout parsing the partition and the size of the file(s). /dev/sda1 3.7G 71.5MB 3.4G 2% /mnt/internal Best regards. St?phane Cerveau Software Engineer scerveau at awox.com<mailto:scerveau at awox.com> Phone: +33 4 99 53 27 39 93, Pierre Duhem 34000 Montpellier FRANCE Phone: +33 4 67 47 10 00 Fax: +33 4 67 47 10 15 cid:069332510 at 17112008-1528 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/ext3-users/attachments/20110207/932643bd/attachment.htm> -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 16426 bytes Desc: image001.jpg URL: <http://listman.redhat.com/archives/ext3-users/attachments/20110207/932643bd/attachment.jpg>
Andreas Dilger
2011-Feb-07 16:30 UTC
Compute the real total size of a partition formated in EXT3
On 2011-02-07, at 06:45, Stephane Cerveau wrote:> In order to have a real percentage of freespace for a user interface, I?m trying to compute the size available on a 4GB USB key formatted in Ext3. Indeed after format, when I ask df to give a summary of size, it tells that there is 75MB already used. > I would like to know the meaning of this 75MB ( is it the journal??) and especially how I can compute this when I want, whithout parsing the partition and the size of the file(s). > /dev/sda1 3.7G 71.5MB 3.4G 2% /mnt/internalThere are several different things that add up to this overhead. The journal is a significant factor for smaller filesystems, but there are also inode tables, allocation bitmaps, reserved space, and a few other things. If you are using a very small embedded filesystem that doesn't need a lot of performance, you can reduce the size of the journal at format time with options like "-J size=4", and disable resizing with "-O ^resize_inode", which also removes some overhead. The amount of reserved space can be reduced with "-m <percentage>" (default 5%), though this can lead to significant file fragmentation and permanent performance impact. Finally, depending on your workload/usage pattern, the number of the inodes in the filesystem can be reduced using "-i <ratio>". As for computing the available size, you can't really do better than what statfs() returns. Cheers, Andreas