Extract from extremetech.com To start off, you'll need to be logged in as root to set this up and to set permissions. Verify that you have the needed kernel modules loaded. To find out what modules you have loaded, open a terminal window and type the following:
The output of lsmod will look like this:
By default, Red Hat loads usb-uhci and usbcore on startup. But you'll need to load an additional module called usb-storage in order to get a flash drive working. To do this, simply type:
Next, we'll need to define a mount point for the USB flash drive, which includes a directory for the mount point. So go to the /mnt sub-directory and create this sub-directory.
Now we need to edit a file called fstab, which lives in the /etc directory. This file defines storage devices and the location of their mount-points. Open the file using gedit, emacs or your text editor of choice. Its contents will look like this:
We need to add a line to this file that reads:
You can copy/paste the above line directly into your fstab file. The "sda1" represents the device name that the kernel gives the USB flash drive when it gets plugged in. Once you've added this line to the fstab file, save it and close your text editor. Now we're almost ready to plug in your USB flash drive. Open a second terminal window and type:
This command will poll the kernel's message log every three seconds, and displays the latest messages the kernel has spat out. This is a useful debug tool to make sure the USB flash drive has been enumerated, and assigned a device name. Generally, the device name will be:
Now, go ahead and plug your flash drive into the USB port. |
Up and Running
Once you've plugged the drive in, look at the terminal window where you're monitoring the kernel's event messages and verify that it has enumerated the USB device. You should see something like this:
Aug 26 17:06:09 localhost kernel: hub.c: new USB device 00:1f.2-1, assigned address 4
Aug 26 17:06:13 localhost /etc/hotplug/usb.agent: Setup usb-storage for USB product d7d/100/100
Aug 26 17:06:13 localhost /etc/hotplug/usb.agent: Setup nomadjukebox for USB product d7d/100/100
Aug 26 17:06:13 localhost /etc/hotplug/usb.agent: Module setup nomadjukebox for USB product d7d/100/100
Aug 26 17:06:13 localhost kernel: SCSI device sda: 121856 512-byte hdwr sectors (62 MB) Aug 26 17:06:13 localhost kernel: sda: Write Protect is off
Aug 26 17:06:13 localhost kernel: sda: sda1 Aug 26 17:06:13 localhost devlabel: devlabel service started/restarted
The key event here is that the device was assigned as /dev/sda1. You can now mount the volume by typing:
cd /mnt
mount usbstick
If all has gone well, a disk icon will appear on your KDE/Gnome desktop and double-clicking on it will open a window that reveals the contents of your USB flash drive.
There's also a way to automate this process, where you can mount your USB flash drive without having to type anything at a command line. In Gnome, when you right-click anywhere on the desktop, one of the menu choices you have is Scripts, which is a quick and easy way to execute Bash scripts without having to open a terminal window. By default, there are no scripts in the folder that this menu points to, but there is an option to open that folder. Once in the folder, create a new text file and open it in your favorite text editor (we use gedit) to write the following script.
You can simply copy/paste what we have here into your Bash script:
#!/bin/bash
modprobe usb-storage
cd /mnt
mount usbstick
We run the modprobe command just to make sure that the usb-storage module is loaded. If it's already loaded, there's no harm done, and if it wasn't already loaded, now it is.
Now save the script as something like mount usbstick, and copy it into the /root/.gnome2/nautilus-scripts sub-directory.
From Gnome/KDE, right-click on this script and go to the Permissions tab dialog. Set the script as executable by the appropriate groups/users, and click OK.
You'll want this script to be available to non-root users, so be sure to copy it to their respective sub-directories:
/home/username/.gnome2/nautilus-scripts
Now when you right-click on the desktop and go down to the Scripts menu choice, in the Scripts sub-menu you should see your mount usbstick script.
If you have your USB flash drive mounted as a volume, right-click on it, and the bottom menu choice should be Unmount Volume. Go ahead and unmount the volume and physically remove the USB flash drive.
Now go ahead and re-insert the flash drive into an available USB port. Next, right-click on the desktop, go into the Scripts sub-menu and execute your mount usbstick script. The drive icon for your flash drive should appear on your desktop, and you're ready to pull bits off of it or write bits to it to carry home.