HOW TO MAKE A UDEV RULE (for my flash drive) ------------------------ Where is my flash drive? Well it's plugged into a socket on your machine of course! Access to it is listed in a few places. First and most basic is in /dev and usually as a /dev/sd? Could be /dev/sda, /dev/sdb, /dev/sda1, /dev/sdb1, etc. ~> #one way to find out would be to use the ls command. First with the drive out: ~> ls /dev/sd* /dev/sda /dev/sdc1 /dev/sdd /dev/sdf /dev/sdh /dev/sdh2 /dev/sdc /dev/sdc3 /dev/sde /dev/sdg /dev/sdh1 /dev/sdh3 ~> #and then with it plugged in: ~> ls /dev/sd* /dev/sda /dev/sdb1 /dev/sdc1 /dev/sdd /dev/sdf /dev/sdh /dev/sdh2 /dev/sdb /dev/sdc /dev/sdc3 /dev/sde /dev/sdg /dev/sdh1 /dev/sdh3 ~> #there, do you see it? sdb and sdb1 are new. Ok so there is a beginning. ------------------------- Mounting the flash drive: Now, to be able to access it like a hard drive we have to create a "mount point" in our file system and then "mount" the flash drive file structure there. ---------- Old school We used to do that like this: (real quick and basic) We used to use /mnt as the base for all "external" drives but nowadays flash, cd and dvd r/rw's etc are usually "mounted" to /media , I suppose because they usually contain some sort of entertainment... <:| /mnt/myflash <-- old /media/myflash <-- new So first we make the directory: mkdir /media/myflash Then (after plugging in the drive) mount the drive on that: ~> mount -t vfat /dev/sdb1 /media/flash1 -o user,defaults #mount ~> ls /media/flash1 #list CS1300.ZIP gvim72.exe UNZIP.EXE ~> umount /media/flash1 #unmount or ~> umount /dev/sdb1 #unmount ~> ls /media/flash1 #list ---------------- Dynamic mounting Nowadays we usually just plug the darn thing in and all of the above steps are performed automatically. Even the making of the mountpoint which is usually named according to the device "label". A label on a msdos formatted flash drive is a word no longer than 11 characters stored on the device as one means of identificationo. So if a device "label" is "mydrive" the mountpoint would be: /media/mydrive Along with that a "Gnome File Browser" will appear - open and showing the device you just plugged in. To unmount the that device you can do as above or in the file browser right click the "name" and select eject. This will not only umount the device but also kill connection to the /dev directory. The listing /dev/sdb will disappear. Alternately in the file browser you can right click the device and select the "Safely Remove Drive" option which will umount the device but leave it listed on /dev/sdx. Well at least it did for my newer drive, for this older one it says "Unable to stop drive , This file cannot be stopped". But I can manually umount it and the file browser window will show the change but a listing of all the drives will then show where I can click on the one for the flash drive and it will mount the drive again. ----------------------- Changing the label name If there is no label, the device name in the browser and at the /media/flash mountpoint might be a really crummy string. My new one had no label and the resulting listing in the browser had a newline in it. So I looked for ways to remedy that and the following is what I came up with: #### excerpt from: /home/hlenderk/linux/rename_flash_automount) I learned of two tools to re-name a label for a flash drive formatted to the msdos file type: mlabel and dosfslabel mlabel - will only assign in upper case and can be tricky. dosfslabel - assigned name will only work if mlabel has not been used to re-label the device or mlabel reports the existing label as being empty. I think that if you do not have mlabel (from mtools) intalled just install dosfslabel and work with that... Anyhow It seems the best thing to do for re-labeling a flash drive is this: - with the flash drive in and still showing in gnome file browser - delete label with mlabel (if it has been used before this time) - assign desired label with dosfslabel - test it out... ~> mlabel -i /dev/sdb1 -s :: Volume has no label # If needed do this: ~> mlabel -i /dev/sdb1 :: Volume label is FLASH_256 Enter the new volume label : Delete volume label (y/n): y # assign the new label: ~> dosfslabel /dev/sdb1 flash_256 # check it out: ~> dosfslabel /dev/sdb1 flash_256 # eject and re-insert drive and behold: - gnome browser shows new name: flash_256 - mountpint is: /media/flash_256 - mount -l shows the label [flash_256] - everybody's happy:) ####################### --------------------------------------- look at the label via the mount command: media> mount -l | grep sdb1 /dev/sdb1 on /media/short type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) [flash_256] When My flash was unlabeled automount gave it this mount point: /media/3B69-1AFD Now after renaming it gives it: /media/flash_256 --------------------------------------------------------------------- Making udev Rules I have no clue yet. For getting udev info on a device here are some lines to try: ----- http://www.reactivated.net/writing_udev_rules.html udevadm info -a -p /sys/block/sdb ----- http://tolecnal.net/2007/04/writing-udev-rules/ udevadm info -q all -p /sys/block/sdb ----- http://hackaday.com/2009/09/18/how-to-write-udev-rules/ udevadm info -a -p $(udevadm info -q path -n /dev/sdd1)