Using a USB flash drive with Linux
USB Flash drives are one of the coolest new tools available these days. And they're getting so cheap, it's easy to carry one around with you anywhere. Finally it looks like the USB flash drive will kill off the floppy once and for all – except for the lack of native Linux support.
I carry my files back and forth from the office to home with a 32MB USB flash drive. But transporting files from my Linux test machine at work typically involves two steps: 1. Copy the bits onto a Windows machine via Samba 2. Write those bits to my USB flash drive using the Wintel machine. Now this is not really an arduous process, but wouldn't it be nice to use that flash drive directly in the Linux system? Well I recently figured out how to do that, and I thought I'd share my experience with you. This tip was put together on a box running Red Hat 9, but the same procedure should yield the same results on any Linux distro. Getting Started 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: lsmod | more The output of lsmod will look like this: Module Size Used by Not tainted nls_cp437 5116 0 (autoclean) vfat 13004 0 (autoclean) fat 38808 0 (autoclean) [vfat] nls_iso8859-1 3516 0 (autoclean) udf 98400 0 (autoclean) ide-scsi 12208 0 soundcore 6404 6 (autoclean) [snd] sd_mod 13516 0 (autoclean) lp 8996 0 (autoclean) parport 37056 0 (autoclean) [lp] autofs 13268 0 (autoclean) (unused) e100 60644 1 ipt_REJECT 3928 6 (autoclean) iptable_filter 2412 1 (autoclean) ip_tables 15096 2 [ipt_REJECT iptable_filter] sg 36524 0 (autoclean) sr_mod 18136 0 (autoclean) scsi_mod 107160 4 [ide-scsi sd_mod sg sr_mod] ide-cd 35708 0 cdrom 33728 0 [sr_mod ide-cd] keybdev 2944 0 (unused) mousedev 5492 1 hid 22148 0 (unused) input 5856 0 [keybdev mousedev hid] usb-uhci 26348 0 (unused) usbcore 78784 1 [hid usb-uhci] ext3 70784 2 jbd 51892 2 [ext3] 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: modprobe usb-storage 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. cd /mnt mkdir /usbstick 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: LABEL=/ / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 /dev/hda3 swap swap defaults 0 0 /dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0 /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0 We need to add a line to this file that reads: /dev/sda1 /mnt/usbstick vfat user,noauto,umask=0 0 0 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: tail -s 3 -f /var/log/messages 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: /dev/sda1 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. Unfortunately this info is not from me. I wish I could provide so much info in a row, but I'm still far from being a guru. My source is here : http://www.extremetech.com/article2/...1256768,00.asp Enjoy ! |
nice explanation...its nice when people figure stuff out and they post a howto for what they have done just in case someone else needs the same info some day...there are a few threads like this, but this one is nice and detailed...nice job! :D
|
It's probably not exactly the same thing, but with Mandrake 9.1, I was able to plug in a smartcard using the usb smartcard reader for my digital camera, and was able to read/write to it immediately without any fiddling. Pretty nifty stuff, but from the looks of it, the usb flash drives are different.
|
Is there a way to automate it even more, so all I want is that as I plug the USB mass-storage device an icon pops on my desktop and clicking that I can access the device.
I have configured USB to work and I can mount the device by hand and use it, but it would be neat if the icon appeared/disappeared as i plug/unplug my USB device(s). |
one thing you can do is use autofs instead of adding that line to /etc/fstab
autofs is a means to automatically mount (or try to) devices when you first access them. It also handles unmounting when your all done (through a configurable idle timer) I have this in my /etc/auto.misc: Code:
usb-key -fstype=vfat /auto/usb-key Code:
cd ~/desktop #(or whatever your window manager uses) |
Maybe I didn't make myself clear enough..
The following scene is my goal: No USB attached -> no /dev/sda1 (or similar) icon on the desktop Attach USB -> /dev/sda1 icon appears on the desktop Remove USB -> /dev/sda1 icon disappears from the desktop I've seen this happen in SuSE, but I'm running Debian now and don't have the SuSE live-eval cd anymore. (Though I could download it, but I'm low on disk space right now..) hmm.. I now realize that the previous post was not a reply to my post, but to the first post instead. Sorry. But since I've gotten this far in writing, I'll go all the way to the end. A far more intellectual approach would also recognize the device I've attached.. Instead of just giving me a mass-storage icon for my USB Flash, it would give a video camera icon for my camcorder. They both are accessed as usb-mass-storage devices. Since all the information can be found (ie. with usbview or cdrecord -scanbus or directly from /proc/bus/usb/devices or from kernel log), some intelligence could be applied. I know I could hack some script for this, but it would be ugly and something I wouldn't bare to share with others. But I think the SuSE guys already have a decent solution, I'll try to find that out. (Or wait that someone posts it here :D ) |
OK, here's a question: what if my system doesn't have a device "/dev/sda1" (or similar) on it? how do i put it in?
I just bought a brand spankin' new Canon 300D camera and would like to direct-connect to my box with Mandrake 9.1. I have never used any other USB devices, so this is all new. Everything else is no problem, but i don't have a device to mount from and have no idea how to get one. help! |
I'd add a little bit more explanation about the /dev/sda1, such as, /dev/sdX1, in that X can be any letter depending on what scsi devices (N+1) you may already have connected to your box.
|
thanks for all the info membrax.... I'm having a little bit of a problem though...
I did all you said in your instructions, but somehow i keep getting this output after typing the tail command and plugging in the drive: Oct 2 12:35:35 Solilofia kernel: SCSI device sda: 256000 512-byte hdwr sectors (131 MB) Oct 2 12:35:35 Solilofia kernel: sda: Write Protect is off Oct 2 12:35:35 Solilofia kernel: sda: sda1 sda2 sda3 sda4 Oct 2 12:35:35 Solilofia kernel: SCSI error: host 1 id 0 lun 0 return code = 8000002 Oct 2 12:35:35 Solilofia kernel: ^ISense class 7, sense error 0, extended sense 0 I suppose the information before the error is what I'm supposed to get, but what does this error mean? After trying to mount, I get this: mount: wrong fs type, bad option, bad superblock on /dev/sda1, or too many mounted file systems After that, I ran an fdisk -l command and I got this: Device Boot Start End Blocks Id System /dev/sda1 ? 7679804 9857553 272218546+ 20 Unknown Partition 1 has different physical/logical beginnings (non-Linux?): phys=(356, 97, 46) logical=(7679803, 4, 9) Partition 1 has different physical/logical endings: phys=(357, 116, 40) logical=(9857552, 1, 1) Partition 1 does not end on cylinder boundary. In this case, what do I need to do? Thanks in advance for your help. |
So is there no ultra-sapient linux guru that knows what these errors mean?
|
.... nevermind I already made it work... it turned out to be that my system didn't recognize it as ¨sda1¨ but just as ¨sda¨.... trial and error is a real bitch, but it works.
|
I have now a few hours experience with linux, mandrake 9, that's all. but I would like to use my usb memory stick as well as my firewire external harddrive without any command line stuff. can it be done the "drag and drop" and "doubleclick" way??
|
probably not. but if you are going to be using linux, the sooner you get your feet wet on the command line, the better off you'll be. Otherwise, you'll be a helpless newbie forever, quite frankly
|
saposmak, I'm having the same trouble now that you had apparently. I tried altering the fstab file to just reading /dev/sda (as well as sda1, sda2...), but I still can't get it to work. What did you do to fix it?
Thanks. |
Windows doesn't seem to require usb devices to have valid partition tables because it treates them kind of like floppies. Linux does require a valid partition table because it treats them like hard-drives. The manufacturers seem to only support the windows world. After partitioning my usb drive properly, both windows and linux were happy. Being able to mount a device as /dev/sda probably indicates it has a bogus partition table - and you may find even though its mounted - it size or other parameters may be incorrect.
See my web-page for details - and for more info on how to deal with buggy usb chip implementations - which can also cause you grief... http://users.actrix.co.nz/michael/usbmount.html |
:Pengy:
hi i've followed all of the instructions given QUOTE]We need to add a line to this file that reads:[/QUOTE] etc yet my USB stick still doesn't work. I get an error saying cannot mount usbstick as it is not a valid block drive. Whats the problem? I'm running Mandrake 9.1 (Bamboo) on an Acer Aspire 1353XC Laptop. Please reply ASAP! cheers, Brad. |
Please post the results of 'tail -s 3 -f /var/log/messages' when you plugged in the device. Also post the results of 'lsusb -v'.
Thanks. |
I'm getting that same 'not a valid block device' message.
Bought a Sandisk Cruzer Mini 128 today. Stuck it in my W2Kmachine - poof - it was available and I threw a file on it. Decided to try it on my Red Hat 8 machine, but first... check LQ for threads. Found this thread. Stepped through the steps. Tried /dev/sda1, sda, sdb1, sdc1, etc etc... This was from that tail command: Jan 12 21:12:26 localhost su(pam_unix)[2268]: session opened for user root by (uid=500) Jan 12 21:13:13 localhost kernel: Initializing USB Mass Storage driver... Jan 12 21:13:13 localhost kernel: usb.c: registered new driver usb-storage Jan 12 21:13:13 localhost kernel: USB Mass Storage support registered. This happened when I did the 'insmod usb-storage', and got the same thing earlier when I used 'modprobe usb-storage'. When I stick the drive in the usb slot, nothing happens. Here's that lsusb -v: Code:
[root@localhost /]# lsusb -v Code:
[root@localhost /]# fdisk -l mount: /dev/sda1 is not a valid block device And, like I said, I also went through the whole process for sdb, sdc, sdd... The little light on the end of the little 'drive' never comes on in the linux machine. How can I determine which device is associated with the thing?? Thanks for any additional info. |
oops... never mind!!!
I guess I didn't connect up the usb ports on the front of this machine. It works in the ports on the back... Sorry about that... Should've checked on that before posting. the dufus. |
oops... never mind!!!
Well, I plugged the stupid thing into the back usb port and got the light on the device, but nothing works to get it to mount or to be available. As a matter of fact the computer completely locked up a couple of times. :scratch: I undid everything in the original steps, rebooted, started over... now the dang light doesn't even come on when I plug it in. Well, that's enough for me for one wasted 4 hour session. |
Well, I'm having a similar problem. I have the Sandisk Cruzer Mini 256 and I'm having problems connecting it to my Redhat Linux 9 system. The usb-storage module loads fine, but the system locks solid each time I connect the cruzer. When I first tried to connect the stick (pre reading this howto), it did the same thing. I checked /var/log/messages and nothing is in there that might give a clue. The last entry before my last reboot was that the USB Storage module was successfully loaded. Any thoughts?
Alex |
Interesting enough, I have 2 memory sticks. One is a PNY Attache 128 Meg, the other is a SanDisk Cruzer mini, 256 Meg.
The PNY works just fine, with this tutorial. However, I can't seem to get the Cruzer working. I wonder if it has to do with it being a Cruzer, or the capacity. Anyone know? I'm running RH AS 3. |
Please post the results of 'tail -s 3 -f /var/log/messages' when you plugged in the device. Also post the results of 'lsusb -v' .
Thanks. |
:eek:
Quote:
|
Nice info on USB drives as i just purchased one a few days ago. All the info i needed is right here.
'nbd' did raise a question that didnt seem to get answered, and i was wondering about the same thing. refering to the fact that is is possible for auto mounting when you plug in the device and un-mounting when you unplug the device. "No USB attached -> no /dev/sda1 (or similar) icon on the desktop Attach USB -> /dev/sda1 icon appears on the desktop Remove USB -> /dev/sda1 icon disappears from the desktop" --nbd I am sure you can put a small script somewhere that does this for you since my system already loads 'usb-storage' module automaically once the device is plugged in. Right now all i have to do is 'mount -t vfat /dev/sda1 /mnt/usbkey' As stated above, i was wondering if the process could be furthur automated by having the key auto mount / unmount as you plugin the usb-key. I'm Using Slackware 9.1. |
Red Hat 9
Comapq Armada M700 Sandisk Cruzer Mini I plug in the flash drive and messages returns the following: Feb 7 21:59:52 JimNote kernel: hub.c: new USB device 00:07.2-1, assigned address 8 Feb 7 21:59:55 JimNote /etc/hotplug/usb.agent: Setup usb-storage for USB product 781/7101/102 Feb 7 21:59:58 JimNote devlabel: devlabel service started/restarted /etc/fstab has the following: LABEL=/ / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 /dev/hda5 swap swap defaults 0 0 /dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0 /dev/sde1 /mnt/usbstick vfat user,noauto,umask=0 0 0 I try to mount it: [jim@JimNote mnt]$ mount /mnt/usbstick mount: mount point /mnt/usbstick does not exist [jim@JimNote mnt]$ What am I doing wrong? |
I got it... I needed to
mkdir /mnt/usbstick and I changed fstab from e1 back to a1. :) |
Here is the tail output and the lsusb -v output. The error I get when trying to mount the thumbdrive is:
root@slacker:/home/chuck# mount /mnt/thumb mount: /dev/sda1 is not a valid block device fstab looks like: root@slacker:/home/chuck# cat /etc/fstab /dev/hda2 swap swap defaults 0 0 /dev/hda1 / ext3 defaults 1 1 /dev/hdb1 /mnt/nt ntfs noexec,auto,user,rw,uid=1000 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0 /dev/dvd /mnt/dvd iso9660 noauto,users,ro 0 0 /dev/fd0 /mnt/floppy auto noauto,owner 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 proc /proc proc defaults 0 0 /dev/sda1 /mnt/thumb vfat user,noauto,umask=0 0 0 Feb 8 09:00:57 slacker kernel: usb 1-1: USB disconnect, address 2 Feb 8 09:01:05 slacker kernel: hub 1-0:1.0: new USB device on port 1, assigned address 3 Feb 8 09:01:05 slacker kernel: usb 1-1: Product: JUMPDRIVE Feb 8 09:01:05 slacker kernel: usb 1-1: Manufacturer: LEXAR MEDIA Feb 8 09:01:05 slacker kernel: usb 1-1: SerialNumber: L137142325060 Feb 8 09:01:06 slacker modprobe: FATAL: Module usb_storage already in kernel. Feb 8 09:01:06 slacker kernel: scsi1 : SCSI emulation for USB Mass Storage devi ces Feb 8 09:01:06 slacker scsi.agent[1501]: bogus sysfs DEVPATH=/devices/pci0000:0 0/0000:00:1f.2/usb1/1-1/1-1:1.0/host1/1:0:0:0 Feb 8 09:01:06 slacker kernel: Vendor: LEXAR Model: JUMPDRIVE Rev : 1.11 Feb 8 09:01:06 slacker kernel: Type: Direct-Access ANS I SCSI revision: 02 Unknown line at line 1809 Duplicate HUT Usage Spec at line 2650 Bus 002 Device 001: ID 0000:0000 Virtual Hub Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 9 Hub bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0000 Virtual idProduct 0x0000 Hub bcdDevice 2.06 iManufacturer 3 Linux 2.6.1 uhci_hcd iProduct 2 UHCI Host Controller iSerial 1 0000:00:1f.4 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x40 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type none wMaxPacketSize 2 bInterval 255 Language IDs: (length=4) 0409 English(US) Bus 001 Device 003: ID 05dc:0080 Lexar Media, Inc. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 Interface bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x05dc Lexar Media, Inc. idProduct 0x0080 bcdDevice 0.01 iManufacturer 1 LEXAR MEDIA iProduct 2 JUMPDRIVE iSerial 3 L137142325060 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 MaxPower 90mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 8 Mass Storage bInterfaceSubClass 6 SCSI bInterfaceProtocol 80 Bulk (Zip) iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type none wMaxPacketSize 64 bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 2 Transfer Type Bulk Synch Type none wMaxPacketSize 64 bInterval 0 Language IDs: (length=4) 0409 English(US) Bus 001 Device 001: ID 0000:0000 Virtual Hub Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 9 Hub bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0000 Virtual idProduct 0x0000 Hub bcdDevice 2.06 iManufacturer 3 Linux 2.6.1 uhci_hcd iProduct 2 UHCI Host Controller iSerial 1 0000:00:1f.2 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x40 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type none wMaxPacketSize 2 bInterval 255 Language IDs: (length=4) 0409 English(US) Thanks for any info to help make this thumbdrive work! |
Usb key setup problem
Hi there,
I followed the instructions and here's what happened at the point where i plug in the usb key(i am using fedora core 1)... root$ tail -s 3 -f /var/log/messages Feb 8 22:48:23 localhost kernel: emu10k1: Audigy rev 4 model 0x1007 found, IO at 0xdf00-0xdf3f, IRQ 5 Feb 8 22:48:23 localhost kernel: ac97_codec: AC97 Audio codec, id: 0x8384:0x7609 (SigmaTel STAC9721/23) Feb 8 22:48:23 localhost modprobe: modprobe: Can't locate module sound-service-0-0 Feb 8 22:49:44 localhost kernel: Initializing USB Mass Storage driver... Feb 8 22:49:44 localhost kernel: usb.c: registered new driver usb-storage Feb 8 22:49:44 localhost kernel: USB Mass Storage support registered. Feb 8 22:51:37 localhost kernel: hub.c: new USB device 00:1d.7-6, assigned address 2 Feb 8 22:51:37 localhost kernel: usb.c: USB device not accepting new address=2 (error=-71) Feb 8 22:51:37 localhost kernel: hub.c: new USB device 00:1d.7-6, assigned address 3 Feb 8 22:51:37 localhost kernel: usb.c: USB device not accepting new address=3 (error=-71) Anyone know how to resolve this ?:scratch: |
Multipe USB Flash Device Conflicts in RH9?
Hey guys.
I just recently updated to RH9, previously running RH8. I've got two USB Flash Drives, a PNY Attache 64MB and a ghetto cheap one I picked up for free (16MB). Before the upgrade, I had read the how-to in this thread and had managed to get both drives to work beautifully. But post-update, I can only get the ghetto cheap drive to work (and it works fine), but I'm a bit constricted by the relative small size. Is there any reason that one should work and the other wouldn't? My /etc/fstab file: Code:
LABEL=/ / ext3 defaults 1 1 Code:
Feb 9 19:34:13 SplicedBox su(pam_unix)[23245]: session opened for user root by csplice(uid=500) Moving on, here's the output for the non-working Attache: Code:
Feb 9 19:39:55 SplicedBox kernel: hub.c: new USB device 00:07.2-2, assigned address 17 Code:
[root@SplicedBox root]# mount /mnt/usbstick Any help is greatly appreciated. *edit* After viewing a post here, I typed the following at the command line: Code:
[root@SplicedBox root]# fdisk -l /dev/sd[a-z] Guidance, please? |
I have a problem that was already described by itsjustme
I have RH9, kernel 2.4.20; my device is Fujifilm and is allegedly supported by "Linux kernel 2.4.0 and above". Like itsjustme, I followed the instructions, and my computer told me it sda1 was not a valid block device. The tail command gave me what the other person with the same problem already told, which is reproduced below for your convenience: Jan 12 21:12:26 localhost su(pam_unix)[2268]: session opened for user root by (uid=500) Jan 12 21:13:13 localhost kernel: Initializing USB Mass Storage driver... Jan 12 21:13:13 localhost kernel: usb.c: registered new driver usb-storage Jan 12 21:13:13 localhost kernel: USB Mass Storage support registered. Unlike itsjustme, lsusb -v gives me a whole host of variations of the following: "Unknown line at line 6" (where the variation is in the number, as you probably guessed) Any ideas, anyone? itsjustme apparently wasn't supported by his OS, but the documentation that came with mine didn't mention any particular distro, only the kernel, and I have a kernal that is alleged to be supported. |
[QUOTE]Originally posted by Mad Merlin
It's probably not exactly the same thing, but with Mandrake 9.1, I was able to plug in a smartcard using the usb smartcard reader for my digital camera, and was able to read/write to it immediately without any fiddling. Pretty nifty stuff, but from the looks of it, the usb flash drives are different. [/QUOTE I am running Mandrake Linux 9.1 and I just bought a Lexar JumpDrive usb flash drive. All I did was plug it in, and Mdk automatically updated my fstab file, and created a new folder at "/mnt/removable". All I had to do to access it was "mount /mnt/removable". |
Ah ... very nice HOWTO, but there was one issue missing.
With 2.6 series of the linux kernel SCSI emulation is no longer needed to burn CDs, so i didn't have any SCSI compiled in, or as a module. Which meant the drive didn't work. A "quick" recompile later and SCSI emulation was added (i added general as well as for CD and HDD drive) and compiled into the kernel, AND it all worked fine. Just as was already documented. In short SCSI is needed. |
Thanls for the brilliant USB tutorial, membrax. It contained the level of detail needed by us newbies. I especially liked the before-and -after views of files, eg fstab.
Now if only you can do the same for CDROMs and 'how to set up a PPPoE connection' then my life would be complete, for the moment anyway. ps.KDevelop is giving me some grief too. :) |
I use a SanDisk SD Card reader on my two SuSE 8.2 Pro systems and it works fine...
I probably should have just gotten another identical SD Card with reader,... However, I recently picked up a SanDisk Cruzer Mini 128 (model SDCZ2-128). Initially, I got it to accept a file from my desktop machine without too much hassle. Thereafter, I can't get it to recognize as a USB Mass Storage Device at all. I have tried mounting it as /dev/sda1,... /dev/sdb1,... /dev/sdb11 and everything in between. I have edited the fstab file, the mtab file,... and even tried to figure out what it is being identified as with the graphical usbview application... USBVIEW sees the flash drive, but I can't the thing to mount. I tried to format the drive as a fat32 drive under windoze 2000 (which sees and writes and reads the thing just fine). Still, when I [alt] [cntrl] [f10], the process window shows the thing being seen by hotplug services, it tries to mount it as a scsi device (like sdb, for example), it just doesn't seem to be reading the partitioning of the device... I would be happy if I could just get a couple of command lines to work to access the thing (that way I could write a script to dump info to it, one to erase stuff from it, and another one to read stuff off it). However, I'm at a loss. I had a similar problem with an HP USB enabled digital camera, but it works just fine now that a member of my LUG helped me with the command line gphoto2... The usb-storage module is installed and working (insmod usb-storage returned a message saying it was already installed, lsmod shows it working). I got the thing to be mounted once on the desktop machine, moved a file to it, never on my laptop machine,... but not since... I can't understand why a fairly standard USB Mass Storage Device doesn't work. Can anyone assist??? |
As a follow-up,...
I got the cruzer mini working on my desktop system, but on my laptop, the thing freezes as I try to mount the drive. The initial problem was not having all of the scsi stuff for SuSE installed. As far as the laptop is concerned though, I am at a loss. It just hangs while trying to mount the drive. My desktop machine does have some problems such as sometimes not wanting to umount unless I do a lazy umount as root... |
Same problem
I have a simmilar problem with my usb stick and fedora core 1
after #mount -t vfat /dev/sda1 /mnt/flash i get a message : mount: wrong fs type,bad option, bad superblock on /dev/sda1,... i (think i) have all needed modules loaded, the messages on the monitoring console are: Feb 27 21:47:53 localhost kernel: hub.c: new USB device 00:1f.2-2, assigned address 8 Feb 27 21:47:53 localhost kernel: hub.c: USB hub found Feb 27 21:47:53 localhost kernel: hub.c: 1 port detected Feb 27 21:47:53 localhost kernel: hub.c: new USB device 00:1f.2-2.1, assigned address 9 Feb 27 21:47:53 localhost kernel: usb.c: USB device 9 (vend/prod 0x67b/0x2517) is not claimed by any active driver. Feb 27 21:47:56 localhost usb.agent[11042]: missing kernel or user mode driver usbcore Feb 27 21:47:56 localhost usb.agent[11042]: missing kernel or user mode driver usbcore Feb 27 21:47:57 localhost kernel: Initializing USB Mass Storage driver... Feb 27 21:47:57 localhost kernel: usb.c: registered new driver usb-storage Feb 27 21:47:57 localhost kernel: scsi1 : SCSI emulation for USB Mass Storage devices Feb 27 21:47:57 localhost kernel: Vendor: USB 2.0 Model: Flash Disk Rev: PROL Feb 27 21:47:57 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02 Feb 27 21:47:57 localhost kernel: Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0Feb 27 21:47:57 localhost kernel: SCSI device sda: 128000 512-byte hdwr sectors (66 MB) Feb 27 21:47:57 localhost kernel: sda: Write Protect is off Feb 27 21:47:57 localhost kernel: sda: sda1 sda2 sda3 sda4 Feb 27 21:47:57 localhost kernel: USB Mass Storage support registered. Feb 27 21:48:00 localhost devlabel: devlabel service started/restarted any help would be nice!! |
Thanks, Membrax! Excellent instructions.
Lexar JumpDrive 2.0Pro 256 MB here on Red Hat WS3 works like a charm. Tonight I configure my Red Hat 9 box at home. |
My experiences with flash drives
I've got an Apacer Handy Steno 2.0 (apparently the first of the line that actually works with Linux) and went through about 4 hours of grief trying to get it working. At this point, I have an icon for not only it, but also my camera on the desktop that allows me to click the icon and pull up the drive. (Clicking the icon again unmounts and removes it from the system; I'll post the perl script later.)
I found that you need the following things for everything to work: usb mass storage scsi support An open mind I've noticed a lot of people assuming that sda1 or sdb1 is the default location for a usb device; in the case of my configuration (RH9.1, kernel 2.4.24, 2-year-old Tyan MP board) the default location for my flash drive is /dev/sda, and my camera is /dev/sdb1. It's weird, I don't quite understand it (although I have my suspicions), but there it is. Make sure you try /dev/sda as well as the partition numbers; this is actually an un-partitioned device you're trying to mount (usually) so you may not need to specify partition numbers. Ok, now the perl script. You can run it on a command line, but I just created an icon which links to it: #!/usr/bin/perl @mod = `lsmod`; @mount = `mount -l`; $found = 0; foreach $element (@mod) { @split = split(/ /, $element); if (@split[0] eq "usb-storage") { foreach $el (@mount) { @split2 = split(/ /, $el); if (@split2[0] eq "/dev/sda") { $found = 1; `umount /flashdrive`; } } if (@split[15] == 1 or @split[15] == 0) { `rmmod usb-storage`; } } } if ($found == 1) { die; } else { $probe = 1; foreach $element (@mod) { @split = split(/ /, $element); if (@split[0] eq "usb-storage") { `mount /dev/sda /flashdrive`; $probe = 0; } } if ($probe == 1) { `modprobe usb-storage`; `mount /dev/sda /flashdrive`; } `konqueror /flashdrive &`; } This can be a bit of overkill if you don't have multiple usb mass-storage devices on your system, as I do; at that point, rip out all of that module checking code. Obviously you'll need to switch out /dev/sda with whatever device your drive connects to, and /flashdrive with whatever folder you want to mount it on. And if you don't like using konqueror to browse your files, switch that out too. I also recognize that this code is REALLY un-optimized and bulky, but I wasn't going for elegance here. If anyone can come up with a smaller, more efficient version, please post it. I'd be interested in studying it. -Visko |
I almost forgot...
I have a question for anyone who knows more about kernel modules than I do (I'm of the old-school monolithic kernel part of the world), why does the mass-storage module freak out and become non-functional when it's gone from non-zero devices depending on it to 0? I had to add checking into my perl script because if you don't remove the module when its device number hits 0, everything breaks.
What's up with that? Has it been fixed by 2.6? -Visko |
Re: Instructions in post 1
I'd like to point out that the line one adds to /etc/fstab is variable. If your flash drive is not formatted in vfat format, replace vfat with the appropriate format. The part that says "noauto, user, etc." can be made "defaults" (I mention it because the one in the original instructions didn't work on my particular installation; so if such is the case for someone else, try defaults.) Also, I think that if you have all the correct modules loaded, the computer will detect the usb drive before you edit /etc/fstab (my did, at any rate; it may not be true in general), and the material point is that it will tell you what device it is in the logs. You can then edit /etc/fstab with whatever device, whether it's sda or what. |
Re: Boneglorious
I noticed that the default partitioning of my flash drive was causing all sorts of problems, actually, so I popped it into window long enough to format it fat32, and it runs fine with vfat now. Takes care of a lot of problems and makes it more compatible with the fstab post.
-Visko |
formats
The default format on mine was ms-dos, so I changed it to FAT32, which is fine for linux, but seems not to be supported by Mac OS X. I've been having real trouble finding a format that I can use with my Linux and OS X. I think, according to some stuff I read on the internet, I'm going to have to learn to recompile my kernel with some additional modules in order to have it support a format that OS X supports. (I'm hoping to find an easier solution after more research.)
Perhaps oddly, the fact that my linux doesn't support ms-dos wasn't a problem for me. I used "ms-dos" in /etc/fstab, mounted the drive and reformatted it using parted, then changed /etc/fstab to reflect the format change. |
OSX doesn't support fat32? Man, I must be missing something....
I could have sworn even OS8 was supporting fat32 filesystem format....are you sure it's not an option you turned off during OSX installation? Also, since OSX is based on BSD, you should be able to find fat32 support from the BSD, linux, or mac community (the modules are there, if still a bit buggy. I'm constantly reading/writing to fat32 partitions on Linux, but I admit to a lot of cluelessness when dealing with OSX. -Visko |
I'm pretty clueless about OS X, all I know is that after the drive was reformatted, I plugged it into a Mac, on which it previously worked, and it told me it didn't understand the format. My drive came formatted with Ms-dos format, according to the documentation, for Mac/Windows cross-compatibility. I can't imagine any reason to use that format over FAT32 than because OS X doesn't support FAT32. I'm hopeful that my personal OS X guru will soon show up and show me a checkbox in the system preferences that will fix the problem, though, and your reply gave me more hope that that's the case. I'll update this when I solve the problem, so everyone will know the answer to that eternal question: does OS X support FAT32?! (I'm sure everyone's waiting with baited breath!)
|
errmm....
Actually, the problem with FAT32 was that my LINUX wouldn't recognize it, not that the mac wouldn't...and it turns out that I put FAT32 as the fs in /etc/fstab when everybody KNOWS it should be vfat...So the good news is that I put vfat in the proper place, and all of my computers were happy and started sharing the files on my usb drive. So everything's happily ever after, except me, because I'm embarrassed! --boneglorious, the vainglorious newbie! |
Hi again,
<-- as you can probably see I'm running Mandrake 10. I have a Buffalo 128Mb Usb stick. I checked out the howto and got the thing working. Well, it worked once, then never again. I get some weird errors about "scsimon" when viewing the "tail -s 3 -f /var/log/messages" output. When I try to mount the drive it just... does nothing :( So, here's the "tail -s 3 -f /var/log/messages" output: Mar 22 22:01:12 dsl-hkigw6id8 kernel: Initializing USB Mass Storage driver... Mar 22 22:01:12 dsl-hkigw6id8 kernel: drivers/usb/core/usb.c: registered new driver usb-storage Mar 22 22:01:12 dsl-hkigw6id8 kernel: USB Mass Storage support registered. Mar 22 22:01:50 dsl-hkigw6id8 kernel: usb 5-8: new high speed USB device using address 2 Mar 22 22:01:51 dsl-hkigw6id8 kernel: scsi0 : SCSI emulation for USB Mass Storage devices Mar 22 22:01:51 dsl-hkigw6id8 modprobe: FATAL: Module scsimon not found. Mar 22 22:01:51 dsl-hkigw6id8 kernel: Vendor: BUFFALO Model: ClipDrive Rev: 2.00 Mar 22 22:01:51 dsl-hkigw6id8 kernel: Type: Direct-Access ANSI SCSI revision: 02 Mar 22 22:01:51 dsl-hkigw6id8 kernel: sda: Unit Not Ready, sense: Mar 22 22:01:51 dsl-hkigw6id8 kernel: Current : sense key Unit Attention Mar 22 22:01:51 dsl-hkigw6id8 kernel: Additional sense: Not ready to ready change, medium may have changed Mar 22 22:01:51 dsl-hkigw6id8 kernel: sda : READ CAPACITY failed. Mar 22 22:01:51 dsl-hkigw6id8 kernel: sda : status=1, message=00, host=0, driver=08 Mar 22 22:01:51 dsl-hkigw6id8 kernel: Current sd: sense key Unit Attention Mar 22 22:01:51 dsl-hkigw6id8 kernel: Additional sense: Not ready to ready change, medium may have changed Mar 22 22:01:51 dsl-hkigw6id8 kernel: sda: assuming Write Enabled Mar 22 22:01:51 dsl-hkigw6id8 kernel: sda: assuming drive cache: write through Mar 22 22:02:11 dsl-hkigw6id8 scsi.agent[4466]: Timeout on find type for device /sys//devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host0/0:0:0:0 And here is my /etc/fstab: /dev/hdb1 / ext3 defaults 1 1 none /dev/pts devpts mode=0620 0 0 /dev/hdb7 /home ext3 defaults 1 2 /dev/hdc /mnt/cdrom auto umask=0,user,iocharset=iso8859-15,codepage=850,ro 0 0 /dev/hdd /mnt/cdrom2 auto umask=0,user,iocharset=iso8859-15,codepage=850,ro 0 0 /dev/fd0 /mnt/floppy auto umask=0,user,codepage=850,iocharset=iso8859-15,sync 0 0 /dev/hdg1 /mnt/wd vfat umask=0 0 0 /dev/hda1 /mnt/win_c ntfs nls=iso8859-15,umask=0 0 0 /dev/hda5 /mnt/win_d ntfs nls=iso8859-15,umask=0 0 0 /dev/hde5 /mnt/win_e ntfs nls=iso8859-15,umask=0 0 0 /dev/sda /mnt/usbstick vfat user,noauto,umask=0 0 0 none /proc proc defaults 0 0 /dev/hdb6 /usr ext3 defaults 1 2 /dev/hdb5 swap swap defaults 0 0 All I know is that the problem has something to do with the word scsi :) I'm so :newbie: that I again need to ask you guys... what now? |
Hmm... now this is getting a bit weird..
I just recompiled my kernel and the usb stick worked again.. for once. Still saying that scsimon is missing blahblah.. but it worked. Unmount it, unplug it, plug it, mount it=>nothing happens and I again get this error: "Mar 22 22:02:11 dsl-hkigw6id8 scsi.agent[4466]: Timeout on find type for device /sys//devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host0/0:0:0:0" How is this possible? I think I don't have the time to recompile my kernel everytime I want to copy an ogg file to my buffalo stick :) Any ideas? |
Daliz:
> dev/sda /mnt/usbstick vfat user,noauto,umask=0 0 0 Hmm, well, for one thing, you need to change sda to sda1 (that is, the first partition on sda). Never heard of scsimon. Also, I had to remove the ",umask=0" from that line in my fstab for it to work correctly. |
I am having another problem with a SanDisk Cruzer mini 128Mb. I saw someone also had this problem but I couldnt find an answer.
This is my problem, I am running Mandrake 9.2, and the USB devie seems to have problems when the kernel assigns an address. This is what i got: ]# tail -s 3 -f /var/log/messages Apr 12 13:27:09 ale kernel: hub.c: new USB device 00:10.2-1, assigned address 14 Apr 12 13:27:09 ale kernel: usb-uhci.c: interrupt, status 2, frame# 92 Apr 12 13:27:09 ale kernel: usb.c: USB device not accepting new address=14 (error=-110) Apr 12 13:27:09 ale kernel: hub.c: new USB device 00:10.2-1, assigned address 15 Apr 12 13:27:09 ale kernel: usb.c: USB device not accepting new address=15 (error=-110) Apr 12 13:27:09 ale kernel: hub.c: connect-debounce failed, port 6 disabled Apr 12 13:39:32 ale sshd(pam_unix)[2521]: session closed for user daniel Apr 12 13:39:36 ale sshd(pam_unix)[3156]: authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost= nothing happens after this, I cannot see the device as /dev/sda or with the usbview command. If anyone knows an answer, I would be grateful thanks, alevp |
All times are GMT -5. The time now is 01:27 AM. |