Discussion:
blocks used by a filesystem
Robert Citek
2013-01-30 18:44:26 UTC
Permalink
I want to know the number of blocks used by a filesystem on partition
${part_slash}. Here's one way:

e2fsck -n ${part_slash} 2> /dev/null | grep blocks | cut -d, -f3 | cut -d/ -f1

However, I suspect that I will have difficulty understanding what that
does in 6 months. Anyone have a more elegant and readable suggestion?

Regards,
- Robert
--
--
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: ***@googlegroups.com
To subscribe: cwelug-***@googlegroups.com
To unsubscribe: cwelug-***@googlegroups.com
More options: http://groups.google.com/group/cwelug
---
You received this message because you are subscribed to the Google Groups "Central West End Linux Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cwelug+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Robert Citek
2013-01-30 23:51:01 UTC
Permalink
On Wed, Jan 30, 2013 at 2:18 PM, Andrew Freiberger
tune2fs ${part_slash} |grep -i block
will give you lots of good info w/out the fsck.
Agreed, tune2fs gives lots of good information. For the number of used blocks:

maxblocks=$(tune2fs -l /dev/sda1 | grep '^Block count' | cut -d: -f2)
freeblocks=$(tune2fs -l /dev/sda1 | grep '^Free blocks' | cut -d: -f2)
echo $(($maxblocks-$freeblocks))

It's definitely more verbose than the one-liner, although I'm not sure
that it's any more readable.

Sure would be nice if tune2fs output its data in some structured
format, e.g. JSON.

Regards,
- Robert
--
--
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: ***@googlegroups.com
To subscribe: cwelug-***@googlegroups.com
To unsubscribe: cwelug-***@googlegroups.com
More options: http://groups.google.com/group/cwelug
---
You received this message because you are subscribed to the Google Groups "Central West End Linux Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cwelug+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...