LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   getting udev to mount a slow usb sdhc card on boot... (https://www.linuxquestions.org/questions/linux-hardware-18/getting-udev-to-mount-a-slow-usb-sdhc-card-on-boot-642992/)

stardotstar 05-18-2008 01:44 AM

getting udev to mount a slow usb sdhc card on boot...
 
Hi all,

I have built a Gentoo install for my EeePC and am very happy with it overall; everything I need working except a small udev boot issue:

on boot I want the main root to be on the internal sdhc /dev/sda2 and boot is at /dev/sda1 - these are found and work fine from grub and the boot proceeds normally. However conscious of space I have elected to put /home and /tmp on an 8GB SDHC that inserts into the internal slot.

Depending on what other usb disks are inserted this disk gets a different /dev/sd? and therefore I wrote a simple 10local.rule udev rule.

Code:

mineeepc ~ # cat /etc/udev/rules.d/10-local.rules
SUBSYSTEMS=="usb", ATTRS{serial}=="146030377350", KERNEL=="sd?", NAME="%k", SYMLINK="sdhc"
SUBSYSTEMS=="usb", ATTRS{serial}=="146030377350", KERNEL=="sd?1", NAME="%k", SYMLINK="sdhc1"
SUBSYSTEMS=="usb", ATTRS{serial}=="146030377350", KERNEL=="sd?2", NAME="%k", SYMLINK="sdhc2"
SUBSYSTEMS=="usb", ATTRS{serial}=="146030377350", KERNEL=="sd?3", NAME="%k", SYMLINK="sdhc3"

SUBSYSTEMS=="usb", ATTRS{serial}=="100", ATTRS{manufacturer}=="Myson Century, Inc.", ATTRS{product}=="USB Mass Storage Device", KERNEL=="sd?2", NAME="%k", SYMLINK="bindport"

# mount block device when added
#SUBSYSTEMS=="block", ACTION=="add", RUN+="/usr/local/bin/mount-device.sh /dev/%k"
mineeepc ~ #

This creates a working instance like this:
Code:

mineeepc ~ # ls -l /dev/sdh*
lrwxrwxrwx 1 root root 3 May  9 08:42 /dev/sdhc -> sdb
lrwxrwxrwx 1 root root 4 May  9 08:42 /dev/sdhc1 -> sdb1
lrwxrwxrwx 1 root root 4 May  9 08:42 /dev/sdhc2 -> sdb2
lrwxrwxrwx 1 root root 4 May  9 08:42 /dev/sdhc3 -> sdb3
mineeepc ~ #

However when booting the system reports that local filesystems failed to mount at around the time that the udev rules are initially processed.

Once the boot process has completed I can log in as root and execute

mount /home
mount /tmp

and all is well giving me the mtab that I need:
Code:

mineeepc log # cat /etc/mtab
/dev/sda2 / ext2 rw,noatime 0 0
proc /proc proc rw,nosuid,nodev,noexec 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0
udev /dev tmpfs rw,nosuid 0 0
devpts /dev/pts devpts rw,nosuid,noexec 0 0
shm /dev/shm tmpfs rw,noexec,nosuid,nodev 0 0
usbfs /proc/bus/usb usbfs rw,noexec,nosuid,devmode=0664,devgid=85 0 0
/dev/sdc2 /mnt/usbhdd ext2 rw,noatime 0 0
/mnt/usbhdd/maint/bindport /usr/portage none rw,bind,noatime 0 0
/mnt/usbhdd/maint/bindlport /usr/local/portage none rw,bind,noatime 0 0
/mnt/usbhdd/maint/bindvartmp /var/tmp none rw,bind,noatime 0 0

So how do I make sure that the internal card is ready and/or able to be mounted during boot by udev - or should I get it to delay the mounting of home and tmp till later in the process to give the usb bus time to catch up with the disk??

Help appreciated guys!

aus9 05-21-2008 07:35 AM

until you get a better reply I suggest a work a round

1) boot process with init and all that stuff wants to find and mount the root system

2) so why not create back on your internal drive..../home and /tmp and refix your /etc/fstab to point to those files.

the part A....in /etc/rc.local with already root created folders (say)
/home2
/tmp2

/bin/mount -t /dev/sd1 /home2
/bin/mount -t /dev/sd2 /tmp2

note when you look at /var/log/syslog....your usb system is not available for quite a while so by running it in rc.local you give it the max time to settle

3) if that fails still keep internal fstab etc and manually mount on boot up

4) I am sure you have your reasons for choosing gentoo but consider dsl or puppy pls as they are better suited to run on small footprints (puppy small footprints get it?)

stardotstar 05-22-2008 05:51 AM

Great answer; thank you.

1) true; very relevant in this context
2) very true - mount bind them after booting with a script?
3) good fallback - might even work better as a bind mount with the basics there as fallback.
4) yeah I just like gentoo and thought of it as a challenge to cram it onto the lil 'puter 'cause that is the linux I like to use day to day.
Portage is all mount bind to an external disk and it seems to be working pretty well for me.

Thanks again for the help; I will try these suggestions.

Will

jschiwal 05-22-2008 06:10 AM

Would it help to simply use "UUID=" instead of the device entry in /etc/fstab. You can use "udevinfo -q env -n <device node>" and take the number from the FS_UUID line. This will alleviate the problem with the device node being different. It may solve the your other problem as well. This is a lot easier than mounting from a udev rule.

stardotstar 05-24-2008 06:36 PM

I must investigate this approach; thank you for the suggestion.

Will

jakemagee 05-06-2009 12:42 AM

Has anyone found a solution to this problem?

I have the same issue trying to mount a usb key and a sdcard on boot. It appears that the issue might have to do with the "Mounting USB device filesystem (usbfs)" being executed after fstab has been parsed. It looks like the usb devices are not ready somehow.

I did try editing localmount to move usbfs ahead of fstab, however this did not fix the issue.

Is there not a standard way to mount usb devices on boot with fstab?

jakemagee 12-01-2009 09:06 PM

Ok, so I finally got around to looking at the issue again.

The solution is to add rootdelay=X to the kernel boot parameters (X in seconds). This is in the kernel docs, kernel-parameters. Add enough time to allow the usb devices to come up (this was the issue).


All times are GMT -5. The time now is 10:30 AM.