How to mount USB drive at boot time

Jonathan Ryshpan jonrysh at pacbell.net
Mon Aug 6 03:19:21 PDT 2007


I have a USB drive that is usually, though not always, connected to my
desktop system.
o If it is connected to the system at boot time, the device path should be
created and the drive should be mounted immediately, i.e. BEFORE any
user logs in.
o If it is not connected at boot time, there should be no serious problem.
o If the drive is connected to a running system (on which it had not been
previously connected), the device path should be created, and it should
be mounted by root.
o Root should be able to unmount the drive, when it is mounted.

I have been advised to add the following files to get the drive to be
mounted at boot time.  Unfortunately, this doesn't work.  

The HAL documentation seems to indicate that the rule is only invoked
when the drive is connected or disconnected and not at boot time.  Is
this correct?  If so, how can the rule be caused to be invoked if the
drive is found to be connected to the system at boot time?

===> The rule
Place the following file into /usr/share/hal/fdi/policy/20thirdparty. 

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->

<deviceinfo version="0.2">

  <device>
    <match key="volume.uuid" string="[volume-id]">
        <append key="info.callouts.add" type="strlist">mountscript</append>
    </match>
  </device>

</deviceinfo>
--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

===> The Script
In /usr/lib/hal/scripts, place the script "mountscript" used above.

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
#!/bin/sh
gnome-mount -h $HAL_PROP_INFO_UDI
--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

Thanks - jon




More information about the hal mailing list