LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-01-2005, 10:10 PM   #1
laan97ac
LQ Newbie
 
Registered: Aug 2005
Location: New Jersey
Distribution: Ubuntu 7.04
Posts: 23

Rep: Reputation: Disabled
Tricky automount of USB HDU - udev is tough!


Here is a tricky example of automounting an External USB HDU.

The USB HDU used to be NTSF but via mandriva diskdrake I changed it to ext3 (one partition 80 GB) in order to get read/write access. During format, diskdrake asks where to mount and I gave /mnt/sda1 as folder. But I am not sure it plays well with udev, read on:

During boot up, the system gives me the following when mounting partitions:
Mounting special device /mnt/sda1 failed, device not present (if not plugged in) But it should not mount at all if not plugged in. Is that not the whole point of udev?

The mount line /dev/sda1 is still present in media:/ and /etc/fstab even when unplugged

When plugged in, only root can write to it and that was not what I wanted – all users should write to it.

I must have somehow mounted it as a fixed harddrive and not a “portable” one for hotplugging.

While in diskdrake, I could not choose to mount as Supermount – only “No supermount.” System would accept setting it to supermount but when going out of the menu and back in, “No Supermount” would show up again.

Mount command (when unmounted)

[root@localhost laan97ac]# mount
/dev/hda5 on / type ext3 (rw,noatime)
none on /proc type proc (rw)
none on /proc/bus/usb type usbfs (rw)
none on /sys type sysfs (rw)
/dev/hda7 on /home type ext3 (rw,noatime)
/dev/hda1 on /mnt/windows type ntfs (ro,umask=0022,nls=iso8859-1)

fstab regardles of whether disk is plugged or unplugged:
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/hda5 / ext3 noatime 1 1
/dev/hda7 /home ext3 noatime 1 2
/dev/hdb /mnt/cdrom auto umask=0022,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
/dev/sda1 /mnt/sda1 ext3 noatime 0 0
/dev/hda1 /mnt/windows ntfs umask=0022,nls=iso8859-1,ro 0 0
none /proc proc defaults 0 0
/dev/hda6 swap swap defaults 0 0

I am running Mandriva 2006 on a new HP laptop. Mandriva 2006 runs udev and fstab-sync. I know that udev is supposed to create /mnt/sda1 on the fly as it is plugged in. I formatted the drive USB drive via diskdrake and as part of the formatting process it asks for where to mount. Now how can I format the drive via diskdrake and have it work via udev and fstab/sync?

Bottomline, how can I make this /dev/sda1 ex3 a drive that is automounted and setup via udev on the fly?
 
Old 12-01-2005, 11:19 PM   #2
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Instead of
/dev/sda1 /mnt/sda1 ext3 noatime 0 0

use
/dev/sda1 /mnt/sda1 ext3 noatime,rw,users,noauto 0 0

All you need to do is type mount /mnt/sda1 after you connect the USB device. I recommend you do not add line for USB storage devices in /etc/fstab because USB devices will use certain nodes if sd is not unloaded when you remove the USB device. It is best to setup sudo for certain users and have them mount it manually.
 
Old 12-02-2005, 05:40 AM   #3
laan97ac
LQ Newbie
 
Registered: Aug 2005
Location: New Jersey
Distribution: Ubuntu 7.04
Posts: 23

Original Poster
Rep: Reputation: Disabled
thanx,
Due to fstab-sync I cannot manually make changes to /etc/fstab.

How would I then disable fstab-sync?
 
Old 12-02-2005, 07:17 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
You have to decide which you want: mount to the device and mount point specified in /etc/fstab, or let udev create the mount point when the device is plugged in. If there is a mount point specified, and other files have not been edited/created to tell udev to use that mount point, you will get an error message during boot-up.

To use fstab to specify the mount point, you must edit /etc/sysconfig/hotplug to add this line: HOTPLUG_MOUNT_TYPE="fstab". You should also have these lines in that file: HOTPLUG_DO_MOUNT="yes" and HOTPLUG_MOUNT_SYNC="synchronous". That last one will slow things down a bit because writes to disk take place immediately. You could also use asynchronous, which is faster. But, if you shut down the device improperly, you risk loosing anything not written to disk at the time of disconnect.

If you want udev to automount the device and create the mount point, you don't need anything in fstab. When the device is mounted, it will show up in /etc/mtab.

For that to happen, you need to edit/create /etc/udev/rules.d/10-local.rules to add a line like this: BUS="scsi" ID="1:0:0:0" DRIVER="sd" SYSFS(vendor)="Maxtor" SYSFS(model)="OneTouch II" NAME(all_partitions)="usbdisk%n"
That's my entry for my Maxtor external drive connected to the usb port. To find out what you need to put in that line, from the command line, run 'udevinfo -a -p /sys/block/sdb | tee udevinfo.txt' (where sdb is the device used on my system. change it to sda if that's where your device is connected). Then read the txt file; section BUS=scsi. Note: you cannot mix parameters from different sections of that file. All the entries in that line must come from the same section.

Now, with that file done, next edit /etc/sysconfig/hotplug: HOTPLUG_MOUNT_TYPE="subfs" to tell udev to create the mount point on the fly (instead of using fstab).

Then edit /etc/sysconfig/kernel and change this line: MODULES_LOADED_ON_BOOT="". Add the kernel modules you need between the quotes, separated by whitespace.
 
Old 12-02-2005, 07:19 AM   #5
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
You have to decide which you want: mount to the device and mount point specified in /etc/fstab, or let udev create the mount point when the device is plugged in. If there is a mount point specified, and other files have not been edited/created to tell udev to use that mount point, you will get an error message during boot-up.

To use fstab to specify the mount point, you must edit /etc/sysconfig/hotplug to add this line: HOTPLUG_MOUNT_TYPE="fstab". You should also have these lines in that file: HOTPLUG_DO_MOUNT="yes" and HOTPLUG_MOUNT_SYNC="synchronous". That last one will slow things down a bit because writes to disk take place immediately. You could also use asynchronous, which is faster. But, if you shut down the device improperly, you risk loosing anything not written to disk at the time of disconnect.

If you want udev to automount the device and create the mount point, you don't need anything in fstab. When the device is mounted, it will show up in /etc/mtab.

For that to happen, you need to edit/create /etc/udev/rules.d/10-local.rules to add a line like this: BUS="scsi" ID="1:0:0:0" DRIVER="sd" SYSFS(vendor)="Maxtor" SYSFS(model)="OneTouch II" NAME(all_partitions)="usbdisk%n"
That's my entry for my Maxtor external drive connected to the usb port. To find out what you need to put in that line, from the command line, run 'udevinfo -a -p /sys/block/sdb | tee udevinfo.txt' (where sdb is the device used on my system. change it to sda if that's where your device is connected). Then read the txt file; section BUS=scsi. Note: you cannot mix parameters from different sections of that file. All the entries in that line must come from the same section.

Now, with that file done, next edit /etc/sysconfig/hotplug: HOTPLUG_MOUNT_TYPE="subfs" to tell udev to create the mount point on the fly (instead of using fstab).

Then edit /etc/sysconfig/kernel and change this line: MODULES_LOADED_ON_BOOT="". Add the kernel modules you need between the quotes, separated by whitespace.

One last thing. When done, reboot to see if it works. Check /var/log/boot.msg and /var/log/messages to see what's going on during boot, device detection, and module loading.

Last edited by bigrigdriver; 12-02-2005 at 07:24 AM.
 
Old 12-02-2005, 08:00 AM   #6
laan97ac
LQ Newbie
 
Registered: Aug 2005
Location: New Jersey
Distribution: Ubuntu 7.04
Posts: 23

Original Poster
Rep: Reputation: Disabled
bigrigdriver,

thanx, I will try as soon as I get in front of the box.

YES, my goal is to let udev take care of mounting and setting up the device - again, with read/write access for all users

Only thing I am still unclear about is how I take the /dev/sda1 line away from my current /etc/fstab since it is now controlled by fstab-sync. I think I should remove that line so that udev can create it from now on whenever the device is plugged in?
I would like to keep fstab-sync, but now that I need to remove the line in order to let udev take care of (following your instructions) how do I delete /dev/sda1 from fstab?
 
Old 12-02-2005, 09:29 AM   #7
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Check the man page for fstab-sync. There is an option: fstab-sync --remove=UDI, where UDI is a HAL unigue device identifier. I don't know what that is, but supposedly you can use that command to edit /etc/fstab.
 
  


Reply



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
usb stick automount mfrangos79 Linux - Hardware 9 09-19-2005 09:55 AM
Udev usb issues exvor Linux - Software 1 06-25-2005 10:27 AM
USB automount delta_simon Linux - Software 2 04-09-2005 04:36 AM
udev and usb mouse ajvbun Fedora 1 11-30-2004 01:07 AM
udev, USB Flash Drives, and usb-mount talkingwires Debian 13 11-07-2004 12:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:28 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