|
|
|
486
   
Group: Forum Members
Last Login: 14/03/2008 12:19:59
Posts: 789,
Visits: 738
|
|
The new Linux Kernel 2.6.10 has a new trick up its sleeve: AutoFS. This, in conjunction with some small user programs, enables a new may of mounting temporary storage items like CDs, USB keys, etc.
It works like this: Suppose your USB Key mounts a /dev/sda1, instead of having an entry in your fstab file, you have it in a file relating to autofs. You have a base directory usually called /misc though you can make it anything you like. Let's say you set /dev/sda1 to mount at /misc/sda1. Now under /mnt where you normally put your mount points, you set up a link to /misc/sda1 at /mnt/usbkey . Every time you plug in your USB key and click the link at /mnt/usbkey, your USB key gets mounted. When you close the file explorer (Konqueror, Nautilus, etc) and have no terminals open at that directory, /dev/sda1 (or /misc/sda1) automatically umounts, making it safe for you to remove the USB key!
Better still you can set up a link to /misc/sda1 on your desktop. Click on it, the USB key is mounted and a file manager opens. Close the file manager, or even select another directory within it, and the USB key unmounts. How smooth can you get?#
On Gentoo, the system I am using, this is one of the options you can use for mounting removable devices. I love it, sure beats the hell out of Supermount!
Reliable, too!

ASUS M2N32WS Pro — 2*1024Mb Corsair Value Select RAM — AM2 4200+ — XFX GeForce 7600GT Fatal1ty — 500Gb WD5000AAKS SATA Drive — PCLinuxOS
|
|
|
|
|
386
   
Group: Forum Members
Last Login: 23/10/2008 17:20:37
Posts: 514,
Visits: 382
|
|
Very interesting. I'm still firmly on 2.4 at the mo as that is where slackware is at, but this is useful for future reference. You wrote:
'you have it in a file relating to autofs.'
What is the name of the file please. I have access to 2.6 through Knoppix & quite fancy checking this out.
Once again the swimming pools of life had been tainted by the incontinent toddlers of fate
|
|
|
|
|
486
   
Group: Forum Members
Last Login: 14/03/2008 12:19:59
Posts: 789,
Visits: 738
|
|
You have to realise here that not all distros use the same file system, though /etc/fstab is pretty standard!
In Gentoo, the file /etc/autofs/auto.master contains a list of automated mount points, I have only one, and the line reads:
/misc /etc/autofs/auto.misc --timeout=1
This means that the mount points are under /misc, the file that holds the config for them is /etc/autofs/misc, and the timeout is 1 second. You'll see what that means later.
One of my lines in auto.misc is:
cflash -fstype=auto,rw,uid=0,gid=100,fmask=0117,dmask=0007,nosuid,nodev \ :/dev/usbstorage/compactflash
What this means is that if a device appears at /dev/usbstorage/compactflash (which I have set up in udev as a link to /dev/sda1 when I plug a particular USB CF adaptor in), then clicking on a shortcut pointing to /misc/cflash (it has to be a shortcut because the directory does not yet exist) results in the device being mounted at /misc/cflash (now it does!!) and your default File Manager opens there. (The bit in the middle relates to permissions etc and to be honest I just copied it from sample files don't ask me to explain it!!) Now provided the subdirectory tree under /misc/cflash is hidden and you point to another directory, or close your File Manager, and do not have /misc/cflash open in any terminals, etc., the device will unmount following the timeout period.
Autofs is not just for plug in devices. You could use it to mount your Windows partition(s), network, CDs, etc.
Of course, if you are still in kernel2.4, I have to explain udev. Under udev, you can set up unique devices under /dev for different hardwares. If you plug in two USB storage devices, they appear as /dev/sda1 and /dev/sdb1. Which way round? Depends on the order you plug them in!

ASUS M2N32WS Pro — 2*1024Mb Corsair Value Select RAM — AM2 4200+ — XFX GeForce 7600GT Fatal1ty — 500Gb WD5000AAKS SATA Drive — PCLinuxOS
|
|
|
|
|
486
   
Group: Forum Members
Last Login: 14/03/2008 12:19:59
Posts: 789,
Visits: 738
|
|
(continued)
Under udev you can have a file or a directory at /etc/udev/rules.d if you have a directory then each file within it will be used in character order. Once a match has been found the search stops. I have a file called:
/etc/udev/rules.d/10-local.rules
and it contains the lines
#Compact Flash Card Reader BUS="usb", SYSFS{idProduct}="0700", SYSFS{idVendor}="05e3", NAME="%k", \ SYMLINK="usbstorage/compactflash"
Here %k means "the standard name". So when I plug in the compact flash card reader, as well as /dev/sda1 appearing, a link to it appears at /dev/usbstorage/compactflash ! That way I can mount it at its unique device name, so that each device gets its own permanent mountpoint. I can actually swap the words NAME and SYMLINK in that line and for practical purposes the outcome will be the same.
You may not think it is important that two different USB Storage devices get their own mount points, but suppose they were printers? One HP, one Epson. Then /dev/usb/lp0 and /dev/usb/lp1 or whatever would be allocated according to the order they are plugged in. If you use udev to ensure that one is always /dev/printer/hp and /dev/printer/epson, you can be sure that the right driver will always be linked to the right printer.
Like a lot of Linux configuration files, you only have to follow instructions, rather than understand them, and there is some helpful stuff on the net.
With udev, your distro should set up good defaults that give similar results to the old devfs (kernel 2.4) system, so you can leave it as it is, or you can set up each device to its own unique mount point. Gentoo uses a file called 50-udev.rules to hold its "fallback positions".
Daniel Drake (aka "dsd", a kernel developer does patches for Gentoo and has contributed stuff to iron out problems between udev and firewire) has a nice page on the net about how to work udev. It is definitely one of the things that makes the 2.6 kernel, especially as it becomes more stable, a worthwhile upgrade.
I doubt whether Knoppix is using 'autofs4', it really needs to be part of a permanent setup, (so I also doubt whether it can harness the power of udev) also it needs kernel 2.6.10 and Knoppix is on 2.6.9. There are older versions of autofs but they don't work properly! By the time kernel 2.6 is up in the high numbers, expect a complete revolution in device handling, compared to 2.4.

ASUS M2N32WS Pro — 2*1024Mb Corsair Value Select RAM — AM2 4200+ — XFX GeForce 7600GT Fatal1ty — 500Gb WD5000AAKS SATA Drive — PCLinuxOS
|
|
|
|
|
186
   
Group: Forum Members
Last Login: 29/01/2005 03:36:00
Posts: 3,
Visits: 1
|
|
| Anyone who uses any kind of automount is asking for trouble, and on a direct internet connection you might as well ask for "Welcome" to be tatooed below your buttocks.
|
|
|
|
|
486
   
Group: Forum Members
Last Login: 14/03/2008 12:19:59
Posts: 789,
Visits: 738
|
|
AUTOFS does not automatically mount as such. It mounts specified devices when asked, subject to a similiar permissions control as in /etc/fstab. What is smooth is the way it automatically unmounts!

ASUS M2N32WS Pro — 2*1024Mb Corsair Value Select RAM — AM2 4200+ — XFX GeForce 7600GT Fatal1ty — 500Gb WD5000AAKS SATA Drive — PCLinuxOS
|
|
|
|