A USB flash drive is a small storage device that you can plug into a USB port on a computer and copy files to it like any other drive. The capacity of such a device is much higher than a floppy disk and much more reliable as there are no moving parts. They are ideal for moving files between machines and backing up your work. You can even get flash drives built into cameras, MP3 players, phones and even watches.
Insert a USB flash drive into a free USB port on the machine. An icon will appear on the desktop. Double-click on the usb icon to open a window showing the files on your flash drive. Drag and drop files from the file manager to add and remove files.
When you are ready to remove the flash drive, close the folder window and right-click on the desktop icon. Select Unmount Volume and the icon should disappear. It is now safe to remove your flash drive.
Open a terminal window (right-click on the desktop and select Open Terminal), login as root and create a mount point for the new device
# mkdir -p /mnt/usb
Add the following line to your /etc/fstab file
/dev/sda1 /mnt/usb vfat noauto,user 0 0
You can now use your flash drive as described above. See the mount and fstab man pages for more information.
![]() | |
If you get errors when trying to Unmount Volume it is because the device is still in use somehow. This is usually because you have a terminal open in that folder, or you are editing a file on the flash drive. You can use the command /usr/sbin/lsof +D /mnt/usb to see which programs are still accessing the drive. |
If you follow the instructions above but don't get a Desktop icon then it is possible your distrobution is not using HAL and udev to detect new hardware. … which creates entries in your fstab file automatically.
If you plug in your USB flash drive then select the usb menu item but don't get an icon on the desktop, then it is possible that the hotplug program failed to load the drivers for your device correctly. Try unplugging the flash drive, waiting a few seconds, then replugging the drive and trying again.
Try opening a terminal window (right-click on desktop and select Open Terminal) then type dmesg. This shows you a list of messages from the kernel from when the machine was switched on and when drivers are loaded and unloaded on the machine. You should see lines similar to the following if the driver was loaded successfully,
Initializing USB Mass Storage driver... usb.c: registered new driver usb-storage scsi1 : SCSI emulation for USB Mass Storage devices Vendor: USB Card Model: Intelligent Stic Rev: 2.02 Type: Direct-Access ANSI SCSI revision: 02 Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0 SCSI device sda: 261056 512-byte hdwr sectors (134 MB) sda: Write Protect is off sda: sda1 WARNING: USB Mass Storage data integrity not assured USB Mass Storage device found at 4 USB Mass Storage support registered.
Here we have a PQI Intelligent Stick with 134MB of storage and the SCSI emulation has assigned the name sda1 to the device. If you have more than one USB mass storage device connected to your machine at the same time then the device name that is assigned will be different and you should create additional mount points and entries in the /etc/fstab file.
If you unplug the flash drive before you Unmount Volume then the machine may still think the drive is connected and may lockup trying to talk to it.
USB flash drives will only work on versions of Linux with a 2.4.x kernel or above.
Flash drives that use Windows software to encrypt the filesystem will not work in Linux. The filesystem must be a normal FAT16 or FAT32 file system to work on both Windows and Linux desktops. It is also possible to use an encrypted filesystem in Linux, see Using an Encrypted Filesystem for more details.
The instructions on this page will be out of date once the gnome-volume-manager is introduced to the desktop which should be about the end of 2004 and should automate the entire process.
Unofficial ISS Linux Web Pages Copyright 2003-2005 Paul Coates
http://linux.ncl.ac.uk/encrypt/
If your machine is stolen then the thief will be able to read your confidential data directly off the hard drive. You can protect your data by using an encrypted file system. This method of protection is useful for laptop users who carry around sensitive data and for encrypting your backup data.
First create a large file and attach it to a loopback device using encryption, you will need to load the loopback module cryptoloop and the encryption module blowfish first. Provide a password for this file, then make a filesystem on the loopback device. Mount the new filesystem as normal, copy over the files you want to store securely, then unmount the filesystem. Finally detach the file from the loopback device. You should probably sync to make sure the data is written back to disk immediately. The following creates a 650Mb file suitable for pressing onto a CDR using blowfish encryption.
# /sbin/modprobe cryptoloop # /sbin/modprobe blowfish # dd if=/dev/zero of=secure bs=1k count=665600 # losetup -e blowfish /dev/loop0 secure Password: # mkfs -t ext2 /dev/loop0 665600 # mount -t ext2 /dev/loop0 /mnt/loop ... # umount /dev/loop0 # losetup -d /dev/loop0 # sync
To access the encrypted filesystem again simply reattach the file to a loopback device and provide the password. Mount the filesystem then add, edit or remove files as required. When you are finished you can unmount then detach the file from the loopback device.
# losetup -e blowfish /dev/loop0 secure Password: # mount -t ext2 /dev/loop0 /mnt/loop ... # umount /dev/loop0 # losetup -d /dev/loop0 # sync
You can make a couple of bash aliases similar to the following to make mounting and unmounting the encrypted filesystem easier, just add them to your .bashrc file.
alias mntsec='losetup -e blowfish /dev/loop0 secure; mount -t ext2 /dev/loop0 /mnt/loop' alias umntsec='umount /dev/loop0; losetup -d /dev/loop0; sync'
You would use the aliases as follows,
# mntsec Password: ... # umntsec
If you enter the wrong password the mount will fail and you will have to detach the file using losetup -d /dev/loop0 and start again. You don't have to use blowfish for encryption but it is a good default if you know nothing about types of encryption. If you want to use a different type of encryption you can choose from the modules found in /lib/modules/…/kernel/crypto
Unofficial ISS Linux Web Pages Copyright (c) 2003-2005 Paul Coates