On Mon, Jun 23, 2008 at 05:25:58PM +0000, Helge Rohde wrote:
> On Saturday 21 June 2008 22:47:31 Roland Smith wrote:
> > On Sat, Jun 21, 2008 at 09:44:09PM +0000, Helge Rohde wrote:
> > > Hello List,
> > >
> > > I need to write a backup script, and one of the required actions would be
> > > a copy of the backup to an external firewire drive. I would like to make
> > > this as easy as possible for the local staff, so i'd like to check
> > > whether the drive is attached, if necessary mount it, copy over the
> > > backup  and unmount it again, so that the local staff can swap the
> > > external disks when they're not used.
> > >
> > > Is there a canonical way to achieve what i want? I played with the idea
> > > of simply checking for /dev/da0s1d's existance, but that won't disappear
> > > on disconnect, so that would leave the  is a possibility that although

Such devices should disappear on disconnect.

> > > da0 is in /dev, it might not be connected.
> >
> > 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.

Let me rephrase that. You should actually use the file system's utility
to set a label. This works for UFS (newfs, tunefs), msdosfs (newfs_msdos),
ISO9660 (mkisofs) and ntfs.

> > 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
> 
> Okay, it obviosly makes sense to use glabel instead of the device node. Will 
> the glabel appear/disappear depending on whether the drive is connected?

Yes, just like regular device nodes.

> Is it possible to have more then one physical drive with the same glabel(As i 
> plan to utilize two identical Firewire disks) ?

You can label both drives the same. I don't know what will happen it you
try to connect them both at the same time. I guess that the creation of
the second label will fail.

> Either way, i still need a way to check whether a drive is attached or not. 

Simple. Check for the device node.

> Mounting( and unmounting!) will be done from the periodic backup
> scripts.
>
> I am not sure how devd could help me with that, besides maybe write/delete a 
> zero-byte file somewhere and have the periodic script check for its 
> existence. 

It can't completely. It should be able to detect your labeled device and
mount it somewhere. But you _have_ to unmount _before_ the device node
disappears, lest you get the aforementioned panic.

It's easier to have the backup script test if the labeled device node
exists.

Do not forget to print a message (after the script has unmounted the
drive) for the operators that the backup is finished and that the device
may be disconnected.
 
> Thank you all for your help,

You're welcome!

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)

Attachment: pgpErwAj4m0h2.pgp
Description: PGP signature

Reply via email to