[CentOS-docs] LUKS create_encrypted_fs

Sat Sep 25 23:02:53 UTC 2010
Jim Angstadt <jimajima9 at gmail.com>

Hi All,

This is my first post to centos-docs.  I've read several months of
archives, but, this may be too trivial.

Re: http://wiki.centos.org/TipsAndTricks/EncryptedFilesystem/Scripts

This line:

FREE_SPACE=$(df -m $SECRET_PATH |grep / | awk '{ print $4 }')

gave me a problem due to line wrapping in df.  For example:

$ df -m /home/ja/verify/
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                        589333    289168    269746  52% /

So, $4 is 52% rather than 269746.

The '/dev/mapper/VolGroup00-LogVol00' term is from a fresh install,
so, perhaps others have this same name.

This change worked for me:
FREE_SPACE=$(${DF} -m ${PATH} | ${GREP} / \
			| ${TR} "\n" ' ' | ${TR} -s ' ' | ${CUT} -d' ' -f4)

Note the reformating onto 1 line with TR.  The remainder could be what
I have, the original awk statement, or whatever.  Thanks for your
consideration.

JIm