Do you have an external hard drive that always mounts in /media/disk or some totally unuseful location? Here I’m going to try to explain the best way I found to have my partitions mounted exactly where I want them.
Basically GNOME handles all this stuff (removable media) with gnome-volume-manager, which uses HAL to grab information, and you can configure it with gnome-volume-properties. All the work is actually done by gnome-mount which can be configured with GConf.
In my case I have an external hard drive with two partitions, I want to have them mounted in /media/external-1 and /media/external-2.
The best way to do that is configuring HAL. There is very handy tool that allows you to see all the information available through HAL, that is hal-device. With that tool I’m able to see the following:
0: udi = '/org/freedesktop/Hal/devices/volume_uuid_2D11_15EE' volume.mount_point = '' (string) volume.label = '' (string) volume.uuid = '2D11-15EE' (string) block.device = '/dev/sda1' (string) 1: udi = '/org/freedesktop/Hal/devices/volume_uuid_31d943b3_b43c_4388_87db_3e2f30cf87d9' volume.mount_point = '' (string) volume.label = '' (string) volume.uuid = '31d943b3-b43c-4388-87db-3e2f30cf87d9' (string) block.device = '/dev/sda2' (string)
I have found my two parttions, the important thing is the uuid (2D11-15EE, 31d943b3-b43c-4388-87db-3e2f30cf87d9), the best thing to do is to choose a label for each partition and then the mount point will be determined automatically
To do that I have to add a HAL’s user policy file:
<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> <match key="block.is_volume" bool="true"> <match key="volume.uuid" string="2D11-15EE"> <merge key="volume.label" type="string">external-1</merge> </match> <match key="volume.uuid" string="31d943b3-b43c-4388-87db-3e2f30cf87d9"> <merge key="volume.label" type="string">external-2</merge> </match> </match> </device> </deviceinfo>
That’s it, now each time I plug in my hard drive the two partitions are auto mounted exactly where I want them🙂
But wait, I don’t like that noexec mount option that appears by default in my external-2 partition. In order to fix that I can configure gnome-mount to change the defaults, or I can set the options I want.
First I need my complete UDI:
Then I set the proper GConf key:
gconftool-2 --type string -s /system/storage/volumes/_org_freedesktop_Hal_devices_volume_uuid_31d943b3_b43c_4388_87db_3e2f30cf87d9/mount_options "[exec]"
Yes, I know the key is huge, it’s sopposed to be “only” the volume’s UUID (31d943b3_b43c_4388_87db_3e2f30cf87d9) but I guess they forgot to allow the fancy way.
In order to have the right mount point I could have done the following instead, but with this the volumes will appear with no label.
gconftool-2 --type string -s /system/storage/volumes/_org_freedesktop_Hal_devices_volume_uuid_32d943b3_b43c_4388_87db_3e2f30cf87d9/mount_point "external-2"
I hope you find this useful.