Some device autoplugging magic in GNOME

I have found some more tricks for mounting hotpluggable devices in GNOME. So, here it is:

Get the volume’s udi (Remember to replace $device with /dev/sdb2 or whatever):
udi=`hal-find-by-property --key 'block.device' --string $device`

So now we have our udi with something like:
/org/freedesktop/Hal/devices/volume_uuid_31d943b3_b43c_4388_87db_3e2f30cf87d9

But that’s not helpful, we need to convert it:
udi=`echo $udi | sed -e "s#/#_#g"`

Now we have:
_org_freedesktop_Hal_devices_volume_uuid_31d943b3_b43c_4388_87db_3e2f30cf87d9

Cool, now we can do some gconftool-2 tricks:

Set the mount point:
gconftool-2 --type=string --set /system/storage/volumes/$udi/mount_point "foobar"

Set the mount options:
gconftool-2 --type=list --list-type=string --set /system/storage/volumes/$udi/mount_options "[exec dev]"

That’s it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s