LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 12-14-2006, 04:54 AM   #1
kamal.n2
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Rep: Reputation: 0
Modifying mount options (ro/rw etc.) during automount via udev


Hi all:

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.

Regards,
- Kamal N
 
Old 12-14-2006, 05:06 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
This doesn't mean anything, check with mount directly:

mount -t ntfs

edit:
to change options to a mounted system:

mount /mnt/windows -o remount,rw

Last edited by nx5000; 12-14-2006 at 05:08 AM.
 
Old 12-14-2006, 05:09 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
oops via udev you asked?
humm I think udev doesn't set mount options? So you have to put it in /etc/fstab
Like this:
/dev/hda1 /mnt/hda1 ntfs noauto,user,ro,uid=1000,gid=114,umask=007,nls=utf8 0 0
 
Old 12-14-2006, 05:45 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
Code:
udevinfo -q path -n /dev/hda1
/block/hda/hda1
jschiwal@hpamd64:~/Documents> udevinfo -q env -p /sys/block/hda/hda1
ID_TYPE=disk
ID_MODEL=FUJITSU_MHU2100AT
ID_SERIAL=NQ07T4825B7P
ID_REVISION=00000008
ID_BUS=ata
ID_PATH=pci-0000:00:08.0-ide-0:0
ID_FS_USAGE=filesystem
ID_FS_TYPE=ntfs
ID_FS_VERSION=3.1
ID_FS_UUID=4B1135F8699960E7
ID_FS_LABEL=
ID_FS_LABEL_SAFE=
This howto should help you write your rule and determine where to put it. Also read through the SuSE documentation on it.
http://reactivated.net/writing_udev_rules.html

Last edited by jschiwal; 12-14-2006 at 05:49 AM.
 
Old 12-14-2006, 06:11 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
This only sets permissions, which udev does right.
But here we're talking of mounting options if I understand correctly?
 
Old 12-14-2006, 06:14 AM   #6
kamal.n2
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nx5000
oops via udev you asked?
humm I think udev doesn't set mount options? So you have to put it in /etc/fstab
Like this:
/dev/hda1 /mnt/hda1 ntfs noauto,user,ro,uid=1000,gid=114,umask=007,nls=utf8 0 0
Thanks for your prompt reply, I did exactly that but instead of using /dev/sda1 (which is what the device is recognized as) I used /dev/disk/by-label/USB_Drive.

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.

Thanks,
- Kamal N
 
Old 12-14-2006, 06:25 AM   #7
kamal.n2
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nx5000
This only sets permissions, which udev does right.
But here we're talking of mounting options if I understand correctly?
Exactly. I am still not able to find any way to provide mount options to the mount command.

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.

Thanks,
- Kamal N
 
Old 12-14-2006, 06:46 AM   #8
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
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.

edit:
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)

Last edited by nx5000; 12-14-2006 at 06:48 AM.
 
Old 12-14-2006, 02:19 PM   #9
kamal.n2
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nx5000
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.

edit:
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)
Hi, I'm back again with some more information.
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...
<deviceinfo version="0.2">
<device>
<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>
</match>
</match>
</match>
</device>
</deviceinfo>

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...

Thanks again,
- Kamal N
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying the Boot Options sfzab SUSE / openSUSE 3 12-26-2005 08:05 PM
Modifying the Boot Options and the mbr file sfzab SUSE / openSUSE 5 12-23-2005 03:46 AM
Tricky automount of USB HDU - udev is tough! laan97ac Linux - Hardware 6 12-02-2005 09:29 AM
automount: mount(generic): failed to mount (null) (type iso9660) on /mnt/media/ vasudevadas Slackware 5 10-17-2005 03:05 PM
USB automount options JetJock Debian 1 06-15-2005 11:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 06:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration