|
|
|
Autofs, USB keys and Fedora Core 2 |
PDF
|
| Print |
|
E-mail
|
|
Written by Kanwar Ranbir Sandhu
|
|
Saturday, 11 September 2004 |
Instructions for auto mounting USB keys on a PC running Fedora Core 2/Gnome 2.6.
USB memory keys are a great replacement for the old 3.5"
floppy disk, but if mailing lists are any indication, not
everyone is having an easy time getting their USB memory keys
to work with their favourite Linux distribution. There
are various solutions from many different people, but they do
not always work and for no apparent reason.
After doing much searching, reading and experimenting to get
a USB memory key working in our office, I decided to write a
How-To. I hope that others find this useful and can
finally use their USB memory keys.
I have kept this How-To general and not specific to the
hardware I used. Although the type of hardware used can
affect the configuration, the general instructions provided
here should work with any USB memory key.
Finally, if you notice any mistakes in this How-To, do tell
us! Contact us and we will
promptly make the appropriate changes.
- Plug your USB memory key into a free USB port.
- Open the Hardware Browser application. You can find this in the Gnome menu under System Tools.
- You will be prompted to enter your root password. After you
enter the password, the Hardware Browser will take several seconds to
scan your system.
- When the scan is complete, you will be presented with a new window listing the hardware it found on your computer.
- Click on Hard Drives in the list on the left side of the window.
The important thing to note here is what the DEVICE is for your USB
memory key. Your USB memory key will be assigned a device
depending on how your hardware is configured. The device is
important and will be required later, so write it down.
- Close the Hardware Browser.
- Open a terminal window.
- You will have to be root to continue, so enter the following at
the prompt: su - root. After you have logged in as the root user,
your prompt will change accordingly. For example:
[ksandhu@laptop ksandhu]$ su - root
Password:{enter your password here}
[root@laptop root]#
You now have to edit some files under /etc to have the USB memory key
automatically mounted each time it is inserted, and unmounted when you
remove it.
- Create a new directory in /mnt named removable. For example:
[root@laptop root]$ mkdir /mnt/removable
The directory will be required for the auto mounting of your USB memory key to function properly.
- Using your favourite text editor, create a new file under the
/etc directory, and name it auto.removable. For example, I like
using vi:
[root@laptop root]# vi /etc/auto.removable
In
this new file, you will describe the filesystems that will be
automatically mounted using the autofs service. In this case, the
filesystem is the USB memory key in your USB port.
- With the file open in your text editor, type in the following:
usbkey -fstype=vfat,umask=000 :/dev/[your-usb-device]
Replace [your-usb-device] with the device ID you wrote down in Step
5. For example, on my system, the USB memory key is always
assigned /dev/sdb1. In my auto.removable file, I therefore use
/dev/sdb, like so:
usbkey -fstype=vfat,umask=000 :/dev/sdb
That is not a mistake. I intentionally use /dev/sdb because
/dev/sdb1 (as reported by the Hardware Browser) means the first
PARTITION on the /dev/sdb hard drive. Since this is a USB memory
key without any partitions, mounting /dev/sdb1 will not work. [Please
note that this is an overly simplified explanation.]
- Save the file and exit your editor.
- Now using your favourite text editor again, edit the file /etc/auto.master. For example:
[root@laptop root]# vi /etc/auto.master
This file should already exist on your Fedora Core 2 system. It
controls what gets mounted and where by referencing the files
specified. In this case, you will be refrencing the
/etc/auto.removable file you just created.
- With the file open in your text editor, type in the following:
/mnt/removable /etc/auto.removable --timeout=1
This will tell the autofs daemon to mount the filesystem specified in
/etc/auto.removable at the mount point /mnt/removable whenever it is
accessed, and to unmount the filesystem one second after non-use.
UPDATE: Roberto De Renzi contacted me and reported having problems with
this step on his system. He found that he needed to increase the
timeout value to above 5 seconds before his particular USB memory key
worked properly.
I haven't needed to increase the timeout value, but then again I
haven't tested this how to on every USB memory in existence! So,
if you experiences problems auto mounting your memory key, you may want
to consider increasing the timeout value.
Thanks Roberto!
- Save the file and exit the editor.
- Restart the autofs service. For example:
[root@laptop root]# service autofs restart
This will force the autofs service to restart and read the new parameters in /etc/auto.master.
- You should now be able to access your USB memory key. Try
changing directories to the USB memory key's mount point by doing the
following:
[root@laptop root]# cd /mnt/removable/usbkey
If the automatic mount was successful, you should be taken to the USB
memory key. Your prompt will change as well to signify the
directory change:
[root@laptop usbkey]#
You can now create files, directories, or do anything else that
you would normally do with your hard disks. Keep in mind that
when you change directories and are not accessing the USB memory key
for more than one second, it will be automatically unmounted by
autofs. Once it is unmounted, it is safe to remove the USB memory
key from the USB port. The USB memory key will also be accesible
by all users, so you do not have to login as root to use it.
I have not fully explained what each option in the files above mean or
do, nor have I provided alternative configuration options. I
highly recommend that you use this How-To as a basis for your own
custom setup.
USB memory keys are great removable storage devices. It
is unfortunate that sometimes it is a struggle to get them to
work with Linux desktops. I hope this How-To has
clarified some of the mystery around how to use them with
Fedora Core 2. Above all, have fun!
Resources
man Pages
- autofs
- auto.master
- mount
- automount
Web Sites |
|
Last Updated ( Saturday, 23 April 2005 )
|
|
|
|