Modifying mount options (ro/rw etc.) during automount via udev
I know this is not the forum for this question but I tried posting my question in Suse/Novell but nobody responded.. so I'm posting it again here...
The question is: how can I change the mount options when an external harddisk is mounted automatically via udev scripts. I tried browsing through the udev rules in the etc directory but I couldn't figure it out.
The reason I want to do this is because opensuse 10.2 is mounting my external USB drive NTFS partition in rw mode that I don't want.
From the dmesg output...
NTFS driver 2.1.27 [Flags: R/W MODULE].
NTFS volume version 3.1.
it seems the stock ntfs module is compiled with Read-Write support which is not very stable yet. Therefore I want to change the mount options to Readonly.
I have another related question: when I get the icon for the external harddisk. There is an option to unmount it but not eject. How can I have an option to eject (i.e. poweroff the external drive/pen drive). Windows provides me that.
Many thanks in advance.
- Kamal N
This doesn't mean anything, check with mount directly:
mount -t ntfs
to change options to a mounted system:
mount /mnt/windows -o remount,rw
oops via udev you asked?
humm I think udev doesn't set mount options? So you have to put it in /etc/fstab
/dev/hda1 /mnt/hda1 ntfs noauto,user,ro,uid=1000,gid=114,umask=007,nls=utf8 0 0
You could add a rule that contains a "MODE=555" entry.
"udevinfo -q env -p $(udevinfo -q path -n /dev/sda1)" after plugging in the drive ( use the correct device in your case ) will print out information that you can use to uniquely identify the device.
This only sets permissions, which udev does right.
But here we're talking of mounting options if I understand correctly?
I added the following...
/dev/disk/by-label/<my_disk_label> /media/usbdisk ntfs ro,noauto,users,<other options> 0 0
As the real device name (/dev/sda1) may change a later time, I wanted a solution which is permanent. I browsed through the udev rules and I could find the rules to create symlinks pointing to the real device node by disk-volume-name and other such persistent ids.
Though this has solved 99% of what I wanted, there is a small annoyance though. After doing the above change, when I inserted my disk I got an icon "usbdisk" on my gnome desktop.
The problem is when I unmounted via right-clicking "usbdisk" I got another icon for this same disk labeld "USB Drive" which is the volume label of my disk.
I guess this is done by gnome-volume-manager which was doing the initial r/w mount.
So definetly I don't want two icons pointing to the same volume and I'd be looking out to configure gnome-volume-manager to mount the drive as read-only.
- Kamal N
But I guess it's not possible... It's not udev which is doing the mount but it only creates the device nodes and symlinks to it. One has to use autofs for automatic mount and there you can specify the mount options.
But I think Suse is using gnome-volume-manager instead of autofs to automount. I will now look how can I change the mount options using gnome-volume-manager.
- Kamal N
No clue for gnome.. sorry
I particularly don't like autofs because it is kernel based. It happened to me several time (when I was using Mandrake) that the kernel would lock up because I removed the disk manually or the network share was unavailable.
your right about /by-label/ stuff, I should also do it :)
(btw, I am using pmount for removable medias, it can integrate with hal to automount)
The mount was indeed happening through gnome-volume-manager which listens to events from HAL.
I could even find the documentation to provide mount options to "high-in-stack" software (i.e. gnome-mount-manager) but it seems it is not honoring these flags.
I added my own policy in HAL which looks like below...
<match key="block.is_volume" bool="true">
<match key="volume.fsusage" string="filesystem">
<match key="volume.fstype" string="ntfs">
<merge key="volume.policy.desired_mount_point" type="string">kamal_usbdisk</merge>
<merge key="volume.policy.mount_option.ro" type="bool">true</merge>
<merge key="storage.policy.mount_option.ro" type="bool">true</merge>
<merge key="storage.policy.default.mount_option.ro" type="bool">true</merge>
To confirm my policy is loaded and working, I also changed the desired_mount_point which worked. But the drive is still mounted as read-write.
Any ideas... as you use pmount.. which actually is embedded inside gnome-volume-manager, you might give me some clue...
- Kamal N
|All times are GMT -5. The time now is 10:14 PM.|