# head /dev/hda2 | file -
/dev/stdin: Linux/i386 swap file (new style) 1 (4K pages) size 66267 pages Label SWAP-hda2

or yet better :

# file -s /dev/hda2
/dev/hda2: Linux/i386 swap file (new style) 1 (4K pages) size 66267 pages Label SWAP-hda2



On Sun, 1 Apr 2007, Judah Milgram wrote:

Anyone know a fast way to test for presence/type of a file system on a
device from within a shell script?

Background: am doing encrypted swap, works fine, but it occurs to me a
little extra safety might not be bad... goal is to make sure there's no
file system on the partition before writing random bytes to it through
the device mapper.

(The disaster scenario is e.g. a typo or copying over the rc.swap to a
new machine and forgetting to change the swap partition device name)

Judah



--
Adam Sulmicki
http://www.eax.com      The Supreme Headquarters of the 32 bit registers

Reply via email to