Request for comments: Is this how to create named links for USB volumes/partitions?

Peter Valdemar Mørch swp5jhu02 at sneakemail.com
Tue Jul 11 02:27:50 PDT 2006


Hi,

Since the sequence of inserting a USB disk/key determines what device 
designation it gets (e.g. /dev/sda or /dev/sdb), I wanted to create 
links to these dynamic device names for the contained volumes, so they 
get predeterimined names, and I can reference them symbolically 
regardless of what sequence they happened to be inserted in today.

Is this the easiest way? Is there a better/easier one? Could this info 
be posted somewhere so I could have found it? Would it be ok for me to 
create http://www.freedesktop.org/wiki/Software/Hal/NamedUSBVolumes and 
link to that from the main page?

I created /etc/hal/fdi/policy/devLinks.fdi like so:
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->

<deviceinfo version="0.2">
   <device>
     <match key="block.is_volume" bool="true">
       <append key="info.callouts.add" type="strlist">devLinks.pl</append>
       <append key="info.callouts.remove" 
type="strlist">devLinks.pl</append>
     </match>
   </device>
</deviceinfo>

/usr/share/hal/scripts/devLinks.pl now reads a config file 
/etc/devLinks/devLinks.conf where I specify mappings between UDI and 
device "name".

So when I insert a disk with two volumes in it and I want them called 
"greenUsbKeyVol1" and "greenUsbKeyVol2", /dev/devLinks/greenUsbKeyVol1 
is created as a link to /dev/sdc1 (or whatever) and likewise for 
greenUsbKeyVol2.

Links to my devLinks.pl, devLinks.fdi and devLinks.conf can be found here:
http://www.morch.com/misc/devLinks/

Sincerely,

Peter

-- 
Peter Valdemar Mørch
http://www.morch.com


More information about the hal mailing list