On Thu, Aug 14, 2008 at 02:45:43PM -0700, MHR wrote:
On Thu, Aug 14, 2008 at 2:36 PM, Nifty Cluster Mitch niftycluster@niftyegg.com wrote:
$ cat /tmp/checkspace #!/bin/bash df -Pkl > /tmp/checkingdiskspce echo -e "\nInput is:" cat /tmp/checkingdiskspce echo -e "\nAdding up the bits" cat /tmp/checkingdiskspce | awk '/^/dev// { used += $3/1024 } END { printf("%d Mb Used\n", used)} '
This is simpler (and does not involve as many execs & forks) as:
awk '/^/dev// { used += $3/1024 } END { printf("%d Mb Used\n", used)} ' /tmp/checkingdiskspce
True, yet if the goal is "df | awk" with no tmp file at all the final edit and cleanup is cleaner. If the goal is to present the result of "df" combined with a bottom line summary your line may be better.
I did notice in this discussion that no one looked at inode counts. A filesystem might be "full" for want of an inode.... I cannot recall if ext[23] will allocate additional inodes dynamically like xfs will. Since xfs will allocate them but not delete then a run-away could cause a lot to be allocated on xfs confusing space use.
Other interesting system admin topics not addressed includes sparse files. For some knowing about sparse files is important for backup tools. Also allocation block size mismatch to average file sizes. Lots of small byte count files on a large allocation block causes book keeping confusion. Some tiny files never allocate a block as the inode can contain some data on some filesystems.
Just looked at the mk2fs man page the -N, -i and -I flags answer my question about dynamic inode allocation (Answer=no).