shellscript conditional to check for external disk

Roland Smith rsmith at xs4all.nl
Sun Jun 22 09:20:22 UTC 2008


On Sat, Jun 21, 2008 at 06:06:17PM -0500, Tim Daneliuk wrote:
> > Use glabel(8) to give the device an unique label. There is no telling
> > which device /dev/da0s1d is pointing to! After labeling you can check
> > for /dev/<fstype>/<yourlabel>, which should be unique.
> > 
> > Make sure to unmount the drive at the end of the backup script, or
> > you'll get a kernel panic when staff pulls the plug on a mounted device.
> > 
> > Roland
> 
> A variant of this approach that is filesystem independent would be
> to simply write an identifying zero-length file in the root of
> the removable backup drive:
> 
> mount /mountpoint /dev/device
> cd /mountpoint && touch ThisIsABackupDrive
>
> Your backup script can just look for the presence of the file
> "ThisIsABackupDrive" whenever it is checking to see whether the drive
> is mounted.

The problem is that there can be several device nodes for USB disks,
each with up to four slices times six usable partitions. How
are you going to pick the right one? You'd have to try them all.
 
> Since this is done at the filename level rather than in the disk
> metadata, your script doesn't care/have to change if the removable
> drive is formatted NTFS, FAT32, ufs, etc. I use such disks myself for
> the exact reason you do, but I keep them FAT32 because pretty much
> everything can read this filesystem. Of course, FAT32 cannot preserve
> the file naming and permissions semantics of ufs, so I just make by
> backups into a tarball and then copy the tarball to the removable
> drive.

Glabel(8) supports UFS, FAT12, FAT16, FAT32, ISO9660, ext2fs, reiserfs
and ntfs.

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080622/c963c002/attachment.pgp


More information about the freebsd-questions mailing list