Sponsored Content
Top Forums UNIX for Advanced & Expert Users Problems with udev & mounting fat32 usb storage Post 302511093 by jjinno on Tuesday 5th of April 2011 08:50:21 PM
Old 04-05-2011
MySQL

Believe it or not, you have helped me significantly.

I admit my udev rules relied heavily on a "USB-Storage" partition existing:
Code:
ACTION=="add", KERNEL=="sd*[0-9]", DRIVERS=="usb-storage",  SYMLINK="usb/%k"
ACTION=="add", KERNEL=="sd*[0-9]", DRIVERS=="usb-storage", RUN+="/bin/mkdir -p /media/usb/%k"
ACTION=="add", KERNEL=="sd*[0-9]", DRIVERS=="usb-storage", RUN+="/bin/mount /dev/%k /media/usb/%k -o sync", OPTIONS="last_rule"

However, if I tried to change them to use the base Kernel name, then all partitioned USB drives were failing... vice versa, when using the partition...

So what I did was push this identification into a script called "usbplug" which does the mkdir, tests if the mount succeeds, and does the rm on an empty dir if necessary after failed mount attempt. This way I can try to mount "/dev/sdc" for a partitioned drive, it will fail, and nobody really cares. But additionally, "/dev/sdb" (a FAT32 non-partitioned disk) will work, as will "/dev/sdc1" (a FAT16 partitioned disk).

Now my rules look like the following (and yes, I got a bit carried away and added an auto-run option):
Code:
# Auto-mount USB storage (on add):
ACTION=="add", KERNEL=="sd*", DRIVERS=="usb-storage", NAME="usb-%k", SYMLINK="usb/%k"
ACTION=="add", KERNEL=="sd*", DRIVERS=="usb-storage", RUN+="/etc/udev/scripts/usbplug --mount /dev/usb-%k /media/usb/%k"
ACTION=="add", KERNEL=="sd*", DRIVERS=="usb-storage", RUN+="/etc/udev/scripts/usbplug --autorun /dev/usb-%k", OPTIONS="last_rule"

You will also note that the rule now uses a "NAME" to insure that all USB mounts are grep-able simply with "mount | grep -i usb"... this helps the script avoid looking at my OS partitions (var, root, etc).

Fun stuff.

I wonder why they can get away without a partition table altogether... seems wrong.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

mounting USB

Hi I was trying to mount my USB flashdrive on solaris 10 and I am getting the message saying that (I have already gone through the previous blogs in the forum) mount: Block device required. I have tried most of the possible ways. #rmformat(gives me the necessary information about my flash... (1 Reply)
Discussion started by: akhil1460
1 Replies

2. Solaris

FAT32 usb external hard drive - how to mount??

Hello ! What is the comand to mount and usb hard disk ? I have Solaris 10 installed! 10nx! (1 Reply)
Discussion started by: daniel.balasa
1 Replies

3. UNIX for Dummies Questions & Answers

Need help with mounting my USB

My previous post seems to be erased and I didn't get any help. I'm logged as root now but no mounting command seems to work, I've tried: Mount -t vfat /dev/sdc1 /mnt/USB Changing "sdc1" for hda1-7, and sdc1-7, and still nothing. Sometimes i get: "special device not found" and others "device... (4 Replies)
Discussion started by: Dax01
4 Replies

4. Solaris

Amazon S3 storage mounting.

We need to mount an amazon S3 share on windows as well as Solaris servers. Any help is appreciated. Thanks in advance. (5 Replies)
Discussion started by: uxadmin007
5 Replies

5. Solaris

Mounting USB HD

I am very new to Solaris. The machine I am working with is running Solaris 10. I have a 1.5 TB hard drive plugged into a USB dock plugged into the Solaris machine. I ran 'cfgadm -al' and can see that the usb0/1 is usb-storage that was not there before. How do i mount this drive and format... (3 Replies)
Discussion started by: mcdef
3 Replies

6. AIX

Mounting USB Mass Storage

Hi experts, recently i'm exploring USB with filesystem FAT32 mounting on my aix oslevel 6100-04-02-1007. I tried to google to get solutions but failed. Thus, i post it here hope to get solution. Appreciate :) This is my usb drives: (5 Replies)
Discussion started by: polar
5 Replies

7. Ubuntu

FAQ adding rules in udev for my usb 8G to autorun rsync

Hi, I would like to ask if someone knows and show/point me or simple help me how udev rules work in lucyd, upon my quest and search all the tuts i used is based on old udev since something i read the udev change in lucyd version.. I want to accomplised when i plug my usb 8Gb device and automount... (0 Replies)
Discussion started by: jao_madn
0 Replies

8. Shell Programming and Scripting

udev rules for mounting CDROM

Hi All, I need a simple udev rules in my server Centos 5.4. This rules needs to get trigger my script whenever the cdrom is attached to the server. Could you please provide your suggestion on it. Thanks, Kalai (0 Replies)
Discussion started by: kalpeer
0 Replies

9. Programming

Look-up USB mounting point

Hi all, I'm developing a short program to look-up for all devices connected to the computer. Using udev and libusb libraries I achieved some progress but I can not find the way to find the mount point. For instance, given a device that I can retrieve using libusb, I would like to know... (4 Replies)
Discussion started by: Carles Rabaneda
4 Replies

10. Shell Programming and Scripting

Fixed mount point for a USB cardreader (Raspberry Pi, UDEV)

Hey all! :) I'm trying to create a fixed mount point for an usb cardreader. I've found a script on a raspberry pi forum which does the following: usb stick is plugged in -> script checks the mount point for data -> script starts copying the files automatically -> script unmounts the... (0 Replies)
Discussion started by: Eomer
0 Replies
EHCI(4) 						   BSD Kernel Interfaces Manual 						   EHCI(4)

NAME
ehci -- USB Enhanced Host Controller driver SYNOPSIS
ehci* at cardbus? function ? ehci* at pci? dev ? function ? usb* at ehci? DESCRIPTION
The ehci driver provides support for the USB Enhanced Host Controller Interface, which is used by USB 2.0 controllers. EHCI controllers are peculiar in that they can only handle the USB 2.0 protocol. This means that they normally have one or more companion controllers (i.e., ohci(4) or uhci(4)) handling USB 1.x devices. Consequently each USB connector is electrically connected to two USB con- trollers. The handling of this is totally automatic, but can be noticed since USB 1.x and USB 2.0 devices plugged in to the same connector appear to connect to different USB busses. SEE ALSO
cardbus(4), ohci(4), pci(4), uhci(4), usb(4) HISTORY
The ehci driver appeared in NetBSD 1.6. BUGS
The support for hubs that are connected with high speed upstream and low or full speed downstream (i.e., for transaction translators) is lim- ited. BSD
Aug 10, 2008 BSD
All times are GMT -4. The time now is 05:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy