# Some USB flash drives don't work

## Tadeas

I have an old Transcend USB flash drive (500 MB) that works perfectly with Linux. But I also have a new one 8GB Kingston that simply doesn't. I can mount it, I can read it but I cannot write into it. On an attempt to write into it it seems that everything is fine, but once the transfer is completed I get an error (in mc)

```
Cannot chown target directory "/media/usb/Obrazky" 

Operation not permitted (1) 
```

 but the files seem to be there. Umount take quite a while and when I mount it again, the drive is again empty.

Anybody encountered anything like this?

This already happened to me with several flash drives and it did happen on two different computers and distros, in Debian on this machine and on another one (also running Debian). Here in Gentoo I use 2.6.27 kernel, in Debian there's 2.6.28 - also compiled by myself. Is it possible that I've turned off some drivers in the kernel configuration? I have followed the Gentoo USB guide quite thoroughly. Shall I post the .config anyway?

I've tried to follow this guide:

http://www.sls.psi.ch/controls/help/howto/usbstick.html?forprint

but it didn't help at all.

Shall I post anything else?

Thanks in advance!

----------

## nerdbert

Hi Tadeas, 

what FS are you using on the USB drive? Have you tried to copy as root? 

-nerdbert

----------

## Tadeas

Thank you for your reply!

Of course I was doing it all as root  :Cool:  . (Although I'd love to be able to do it all as a regular user, just because of the conveniece).

The FS was some sort of FAT32, I don't remmember exactly which one, however I've replaced it according to this howto with 

```
W95 FAT32 (LBA)
```

but it doesn't work either. 

Shall I try ext2? Just for the sake of trying, I'll need to use that stick with Windows...

----------

## nerdbert

Yes, I would give ext2 a chance. If it doesn't work there you know it's hardware-related...

----------

## Tadeas

Formating with ext2 went well (I deleted the partition on the stick, created a new one using fdisk and then formated it with "mke2fs /dev/sdb1"), however I cannot mount it now.

```
tux gentoo # mount /dev/sdb1 /media/usb/

mount: you must specify the filesystem type

tux gentoo # mount -t ext2 /dev/sdb1 /media/usb/

mount: unknown filesystem type 'ext2'

```

Also dmesg is behaving strangely, it writes this on and on and on after I plug it in:

```
[15384.572158] usb-storage: queuecommand called

[15384.572172] usb-storage: *** thread awakened.

[15384.572177] usb-storage: Command TEST_UNIT_READY (6 bytes)

[15384.572182] usb-storage:  00 00 00 00 00 00

[15384.572193] usb-storage: Bulk Command S 0x43425355 T 0x63 L 0 F 0 Trg 0 LUN 0 CL 6

[15384.572196] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes

[15384.572305] usb-storage: Status code 0; transferred 31/31

[15384.572308] usb-storage: -- transfer complete

[15384.572310] usb-storage: Bulk command transfer result=0

[15384.572312] usb-storage: Attempting to get CSW...

[15384.572314] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[15384.572547] usb-storage: Status code 0; transferred 13/13

[15384.572549] usb-storage: -- transfer complete

[15384.572552] usb-storage: Bulk status result = 0

[15384.572556] usb-storage: Bulk Status S 0x53425355 T 0x63 R 0 Stat 0x0

[15384.572560] usb-storage: scsi cmd done, result=0x0

[15384.572566] usb-storage: *** thread sleeping.

[15386.572148] usb-storage: queuecommand called

[15386.572162] usb-storage: *** thread awakened.

[15386.572167] usb-storage: Command TEST_UNIT_READY (6 bytes)

[15386.572170] usb-storage:  00 00 00 00 00 00

[15386.572182] usb-storage: Bulk Command S 0x43425355 T 0x64 L 0 F 0 Trg 0 LUN 0 CL 6

[15386.572185] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes

[15386.572320] usb-storage: Status code 0; transferred 31/31

[15386.572322] usb-storage: -- transfer complete

[15386.572324] usb-storage: Bulk command transfer result=0

[15386.572326] usb-storage: Attempting to get CSW...

[15386.572329] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[15386.572564] usb-storage: Status code 0; transferred 13/13

[15386.572566] usb-storage: -- transfer complete

[15386.572568] usb-storage: Bulk status result = 0

[15386.572572] usb-storage: Bulk Status S 0x53425355 T 0x64 R 0 Stat 0x0

[15386.572576] usb-storage: scsi cmd done, result=0x0

[15386.572635] usb-storage: *** thread sleeping.
```

The stick is allright from the hardware point of view, it works fine with windows (or worked 'till I formated it with ext2...)

----------

## nerdbert

Maybe you don't have ext2 compiled in the kernel. Try mounting it as ext3 or reformat it as ext3

----------

## Tadeas

I reformated it as ext3:

```
tux gentoo # mke2fs -j /dev/sdb1

mke2fs 1.41.3 (12-Oct-2008)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

490560 inodes, 1959916 blocks

97995 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2009071616

60 block groups

32768 blocks per group, 32768 fragments per group

8176 inodes per group

Superblock backups stored on blocks: 

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.
```

however I still cannot mount it..

```
tux gentoo # mount /dev/sdb1 /media/usb/

mount: you must specify the filesystem type

tux gentoo # mount -t ext3 /dev/sdb1 /media/usb/

mount: wrong fs type, bad option, bad superblock on /dev/sdb1,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so
```

BTW I have to remove it and then plug it in after the reformat, because the device /dev/sdb disappears in the process..

----------

## nerdbert

 *Tadeas wrote:*   

> 
> 
> BTW I have to remove it and then plug it in after the reformat, because the device /dev/sdb disappears in the process..

 

IIRC that is normal.

You could boot some linux from CD to check whether it's the computer or your gentoo installation...

I'm running out of ideas   :Crying or Very sad: 

----------

## Tadeas

 *nerdbert wrote:*   

> I'm running out of ideas  

 

Thank you for your attention anyway  :Wink: 

 *nerdbert wrote:*   

> You could boot some linux from CD to check whether it's the computer or your gentoo installation...

 

I have Debian installed here and I have the same problems. However I use an own-compiled kernel on both the systems, so it is possible that I've made some mistakes in both of them...

However I'll give a try to Ubuntu boot CD I have here...

----------

## NeddySeagoon

Tadeas,

USB storage devices come in two sorts, those that look like big floppies, with no partition table and those that look like a normal hard drive.

You cannot turn one into the other, although, as with a normal hard drive, you do not need to format it.

Connect the USB stick and look in dmesg, you should see something like

```
[ 2665.014434] usb-storage: device found at 6

[ 2665.014437] usb-storage: waiting for device to settle before scanning

[ 2670.012118] usb-storage: device scan complete

[ 2670.012604] scsi 5:0:0:0: Direct-Access     SanDisk  Cruzer           7.01 PQ: 0 ANSI: 0 CCS

[ 2670.012966] scsi 5:0:0:1: CD-ROM            SanDisk  Cruzer           7.01 PQ: 0 ANSI: 0

[ 2670.039454] sd 5:0:0:0: [sdh] 31306239 512-byte hardware sectors: (16.0 GB/14.9 GiB)

[ 2670.040114] sd 5:0:0:0: [sdh] Write Protect is off

[ 2670.040118] sd 5:0:0:0: [sdh] Mode Sense: 45 00 00 08

[ 2670.040120] sd 5:0:0:0: [sdh] Assuming drive cache: write through

[ 2670.042088] sd 5:0:0:0: [sdh] 31306239 512-byte hardware sectors: (16.0 GB/14.9 GiB)

[ 2670.042580] sd 5:0:0:0: [sdh] Write Protect is off

[ 2670.042583] sd 5:0:0:0: [sdh] Mode Sense: 45 00 00 08

[ 2670.042585] sd 5:0:0:0: [sdh] Assuming drive cache: write through

[ 2670.042589]  sdh: sdh1
```

The important part there is the last line. /dev/sdh and /dev/sdh1 are detected. This tells my SanDisk  Cruzer is like a hard drive.

If there are no partitions, try mounting the /dev/sdh.

Windows doesn't care - it will only mount the first partition of a USB device anyway.

----------

## Tadeas

I've just booted in Kubuntu 8.04 Live CD and it looks a little better:

dmesg:

```
[  277.796910] usb 6-3: new high speed USB device using ehci_hcd and address 7

[  277.853659] usb 6-3: configuration #1 chosen from 1 choice

[  277.858047] scsi6 : SCSI emulation for USB Mass Storage devices

[  277.859366] usb-storage: device found at 7

[  277.859370] usb-storage: waiting for device to settle before scanning

[  279.964991] usb-storage: device scan complete

[  279.965272] scsi 6:0:0:0: Direct-Access     Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 2

[  279.975336] sd 6:0:0:0: [sdb] 15679488 512-byte hardware sectors (8028 MB)

[  279.975619] sd 6:0:0:0: [sdb] Write Protect is off

[  279.975634] sd 6:0:0:0: [sdb] Mode Sense: 23 00 00 00

[  279.975638] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[  279.976723] sd 6:0:0:0: [sdb] 15679488 512-byte hardware sectors (8028 MB)

[  279.976990] sd 6:0:0:0: [sdb] Write Protect is off

[  279.976996] sd 6:0:0:0: [sdb] Mode Sense: 23 00 00 00

[  279.977004] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[  279.977008]  sdb: sdb1

[  280.078181] sd 6:0:0:0: [sdb] Attached SCSI removable disk

[  280.078225] sd 6:0:0:0: Attached scsi generic sg1 type 0
```

However I still cannot mount it:

```
ubuntu@ubuntu:~$ sudo mount /dev/sdb1 /media/

mount: you must specify the filesystem type

ubuntu@ubuntu:~$ sudo mount -t ext3 /dev/sdb1 /media/

mount: wrong fs type, bad option, bad superblock on /dev/sdb1,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

```

Neddy Seagoon,

thank you for your reply.

This isn't any sort of a hard drive, it's a USB flash memory, I think it's this one. With other flash memories I get the same dmesg result as you showed, however this isn't the case. It looks similarly in Ubuntu, however it looks pretty strange in Gentoo (and Debian), see several posts above.

----------

## NeddySeagoon

Tadeas,

Try -t auto in the mount command. That asks moount to try each filesystem it knows about.

----------

## Tadeas

 *NeddySeagoon wrote:*   

> Tadeas,
> 
> Try -t auto in the mount command. That asks moount to try each filesystem it knows about.

 

Will do that as soon as I'll get to my computer. However doesn't mount add "-t auto" implicitly when nothing is specified? I mean, if I just type 

```
mount /dev/sdb1 /media/usb
```

 doesn't it try to guess the FS the way it does when there is "-t auto"?

EDIT:

 *NeddySeagoon wrote:*   

> Tadeas,
> 
> Try -t auto in the mount command. That asks moount to try each filesystem it knows about.

 

I've got this result:

```
tux gentoo # mount -t auto /dev/sdb1 /media/usb/

mount: you must specify the filesystem type
```

So it didn't help:-(

----------

## Tadeas

Bump:-)

I have some news about the issue: It doesn't work in Debian either, with my own as well as with generic 2.6.28 kernel. However it DOES work with the Linux Mint 6 LiveCD, so there has to be a way to get it working in other distros  :Smile:  . Any ideas? The problem is still the same - USB flash pendrives don't work - they can be mounted, read but I cannot write on them. They are mounted rw of course  :Smile:  .

----------

## NeddySeagoon

Tadeas,

Only root can write to any vfat or ntfs media unless you give mount some options to fake *NIX permissions for the volume.

vfat has no idea of permissions and ntfs permissions do not map to *NIX.

A blunt instrument, for testing only, is to add  

```
-o umask=0
```

  to the mount command.

This makes everything world accessable.

Plug in your non working USB drive and post 

```
dmesg | tail -n 30
```

That should show what your drive was detected as, if it was detected at all.

----------

## doctork

Perhaps you're having problems with "U3" enabled flash drives.  They show up on my system as two SCSI LUNs.  Like so:

 *Quote:*   

> scsi 10:0:0:0: Direct-Access     Best Buy Geek Squad       7.01 PQ: 0 ANSI: 0 CCS
> 
> scsi 10:0:0:1: CD-ROM            Best Buy Geek Squad       7.01 PQ: 0 ANSI: 0
> 
> 

 

The magic of UDEV, HAL and friends finds the following:

 *Quote:*   

> /dev/sr1 on /media/U3 System type iso9660 (ro,nosuid,nodev,uhelper=hal,uid=1000,utf8)
> 
> /dev/sdb1 on /mnt/stick type vfat (rw,noexec,nosuid,nodev,noatime,user=jkorpi)
> 
> 

 

I have these set in my kernel config:

 *Quote:*   

> CONFIG_ISO9660_FS=y
> 
> CONFIG_SCSI_MULTI_LUN=y
> 
> 

 

I believe I read somewhere that the data in the iso9660 partition can cause the second to be write protected.  Note that "fdisk" does not see the iso9660 partition.  It thinks there's only one fat16 partition on the drive.

--

doc, wage-slave emeritus

----------

