Re: shellscript conditional to check for external disk



On Monday 23 June 2008 18:24:59 Roland Smith wrote:
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:

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.
That's what i thought, but since i wasnt entirely sure i let the otherwise perfectly working behavior convince me otherwise. Sorry for any confusion caused.
It seems that with the given Hardware combination fwohci runs into a bunch of errors and only creates the device nodes at the first time the drive is connected, but fails to destroy them upon disconnection. Reconnecting, mounting and writing to and from the device node produced no errors.
If i connect the drive via usb cable instead of the fw one, all goes as expected and umass creates and destroys the device nodes. I will investigate and start a new thread on it later, for now my workaround is a strip of Gaffa Tape over the Firewire port and the instruction to only use USB ;)

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.

I just didnt suspect just how irregular my device nodes are ;)

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.

Thats precisely why i didnt want to let devd do the mounting: doing it just-in-time minimises the window of opportunity for vicious plug-pullers.

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.

The Machine will run headless - I thought about sending a mail but i probably won't bother as by the time the backup and copy takes longer than a night, I should have received angry emails and snmp traps about filesystems way beyond their official capacity anyway ;)

regards,
Helge

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: RDC Failing from home to work???
    ... "Jeffrey Randow (MVP)" wrote: ... > disappear or is it saying you are logged off? ... > alternatives involve seeing a black screen then a disconnect. ...
    (microsoft.public.windowsxp.work_remotely)
  • Re: Visual Basic Menus/Classes
    ... When ever you mouse over one menu item, the mouseover property sets the ... others to disappear, and the one you selected to appear. ... The problem I am having is that the mouseover event doesn't go into ... effect until the cursor moves OFF the label. ...
    (comp.lang.basic.visual.misc)
  • Re: Problem with fields and labels in design
    ... How do I disconnect the label from the field in order to modify the ... don't seem to be able to ungroup. ...
    (microsoft.public.access.forms)
  • Re: timestamp from a command button
    ... re-opened the date disappear and the label is blank. ... RBrandt at Hunter dot com ...
    (microsoft.public.access.forms)
  • uhid0 problems
    ... If I reboot my system, ... will just disappear, and I will need to disconnect and then ... reconnect my device physically, ...
    (freebsd-current)

Loading