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
lsusb(8)							Linux USB Utilities							  lsusb(8)

NAME
lsusb - list USB devices SYNOPSIS
lsusb [ options ] DESCRIPTION
lsusb is a utility for displaying information about USB buses in the system and the devices connected to them. OPTIONS
-v, --verbose Tells lsusb to be verbose and display detailed information about the devices shown. This includes configuration descriptors for the device's current speed. Class descriptors will be shown, when available, for USB device classes including hub, audio, HID, communi- cations, and chipcard. -s [[bus]:][devnum] Show only devices in specified bus and/or devnum. Both ID's are given in decimal and may be omitted. -d [vendor]:[product] Show only devices with the specified vendor and product ID. Both ID's are given in hexadecimal. -D device Do not scan the /dev/bus/usb directory, instead display only information about the device whose device file is given. The device file should be something like /dev/bus/usb/001/001. This option displays detailed information like the v option; you must be root to do this. -t Tells lsusb to dump the physical USB device hierarchy as a tree. This overrides the v option. -V, --version Print version information on standard output, then exit successfully. RETURN VALUE
If the specified device is not found, a non-zero exit code is returned. FILES
/var/lib/usbutils/usb.ids A list of all known USB ID's (vendors, products, classes, subclasses and protocols). SEE ALSO
lspci(8), usbview(8). AUTHOR
Thomas Sailer, <sailer@ife.ee.ethz.ch>. usbutils-007 6 May 2009 lsusb(8)
All times are GMT -4. The time now is 04:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy