Good thought - but mount -vf seems to believe anything you tell it, e.g:

mite:ROOT:/etc/rc.d$ file -s /dev/hda1
/dev/hda1: Linux/i386 swap file (new style) 1 (4K pages) size 34129 pages
mite:ROOT:/etc/rc.d$ mount -vf -t ext2 /dev/hda1 /mnt/hd
/dev/hda1 on /mnt/hd type ext2 (rw)

I think the basic idea is good, though - why not just try and mount it
for real and see if it succeeds. Stand by ...

Judah



Rob Sherwood <[EMAIL PROTECTED]> wrote:

> On Sun, Apr 01, 2007 at 12:08:40PM -0400, 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)
> 
> Stab-in-dark:
> 
> mount -vf /dev/XXX|& parse the output
> 

Reply via email to