# USB Flash and vfat

## LostInGentoo

Hi,

on my workstation I mount my USB pendrive (formatted in windows xp) which is running gentoo-2.6.5 kernel. On my laptop (mm-sources 2.6.9-rc1-mm2, 2.6.9-rc2-mm1) I cannot mount the usb pendrive - wrong fs error. I have compiled in the vfat support in both kernels but I just can't mount it. What's wrong.

I use 

 # mount -t vfat /dev/sda /mnt/usb

using fdisk /dev/sda this error arrives

```

Disk /dev/sda: 262 MB, 262144000 bytes

9 heads, 56 sectors/track, 1015 cylinders

Units = cylinders of 504 * 512 = 258048 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   ?     3808034     4142735    84344727   65  Novell Netware 386

Partition 1 has different physical/logical beginnings (non-Linux?):

     phys=(370, 110, 36) logical=(3808033, 1, 53)

Partition 1 has different physical/logical endings:

     phys=(357, 32, 45) logical=(4142734, 4, 34)

Partition 1 does not end on cylinder boundary.

/dev/sda2   ?     2797511     3876706   271957177   66  Unknown

Partition 2 has different physical/logical beginnings (non-Linux?):

     phys=(363, 105, 51) logical=(2797510, 0, 48)

Partition 2 has different physical/logical endings:

     phys=(364, 101, 42) logical=(3876705, 2, 9)

Partition 2 does not end on cylinder boundary.

/dev/sda3   ?     3399610     6832506   865089847+  6e  Unknown

Partition 3 has different physical/logical beginnings (non-Linux?):

     phys=(101, 134, 32) logical=(3399609, 1, 4)

Partition 3 has different physical/logical endings:

     phys=(353, 32, 52) logical=(6832505, 3, 2)

Partition 3 does not end on cylinder boundary.

/dev/sda4   ?     5725558     5725668       27622   61  SpeedStor

Partition 4 has different physical/logical beginnings (non-Linux?):

     phys=(372, 110, 51) logical=(5725557, 7, 43)

Partition 4 has different physical/logical endings:

     phys=(269, 114, 52) logical=(5725667, 4, 14)

Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

```

What is wrong and what to do about it?

My laptop is running the reiser4 fs so I cannot use the gentoo-kernel!

Thanks for helping.

----------

## inode77

 *Quote:*   

> mount -t vfat /dev/sda /mnt/usb

  Can never work try "mount -t vfat /dev/sda1 /mnt". (You can only mount partitions not drives!)

 *Quote:*   

> /dev/sda1   ?     3808034     4142735    84344727   65  Novell Netware 386
> 
>  /dev/sda2   ?     2797511     3876706   271957177   66  Unknown 
> 
> /dev/sda3   ?     3399610     6832506   865089847+  6e  Unknown
> ...

 

That seems quite strange because no partition on /dev/sda (really your pendrive ?) is using a valid vfat type.

I suggest you emerge dosfstools, backup all important data from the stick using windows (It'll work there if I understood you ritght).

Using linux do 

```
fdisk /dev/sda

delete all partitions (using "d")

create one (or more if your like with "n")

make them type "b" or "c" (using "t")

write/quit

mkfs.vfat /dev/sda1 (and the others too if you created more)

```

and you should have no more problems.

----------

## LostInGentoo

EDIT: INFO FROM LAPTOP

Well, I guess it's a kernel-problem - I mount the /dev/sdb (have scsi hd in workstation) from my workstation, so I guess it's actually quite ok..

The /dev/sda is the only device with /dev/sda in front of it:

```

bash-2.05b$ ls -la sd*

brw-rw----  1 root disk 8, 0 Sep 23 21:31 sda

bash-2.05b$ 

```

dmesg say:

```

hub 1-1:1.0: USB hub found

hub 1-1:1.0: 1 port detected

usb 1-1.1: new full speed USB device using address 6

scsi1 : SCSI emulation for USB Mass Storage devices

  Vendor: USB 2.0   Model: Flash Disk        Rev: PROL

  Type:   Direct-Access                      ANSI SCSI revision: 00

SCSI device sda: 512000 512-byte hdwr sectors (262 MB)

sda: assuming Write Enabled

sda: assuming drive cache: write through

 sda: unknown partition table

Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0

Attached scsi generic sg0 at scsi1, channel 0, id 0, lun 0,  type 0

USB Mass Storage device found at 6

```

Thanks.

----------

## LostInGentoo

INFO FROM WORKSTATION

dmesg:

```

usb 2-1: new full speed USB device using address 3

hub 2-1:1.0: USB hub found

hub 2-1:1.0: 1 port detected

usb 2-1.1: new full speed USB device using address 4

scsi2 : SCSI emulation for USB Mass Storage devices

  Vendor: USB 2.0   Model: Flash Disk        Rev: PROL

  Type:   Direct-Access                      ANSI SCSI revision: 02

SCSI device sdb: 512000 512-byte hdwr sectors (262 MB)

sdb: assuming Write Enabled

sdb: assuming drive cache: write through

 /dev/scsi/host2/bus0/target0/lun0: p1 p2 p3 p4

Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0

Attached scsi generic sg3 at scsi2, channel 0, id 0, lun 0,  type 0

USB Mass Storage device found at 4

```

mount -t vfat /dev/sdb /mnt/usb:

```

preben@echelon preben $ sudo mount -t vfat /dev/sdb /mnt/usb/

preben@echelon preben $ sudo ls -la /mnt/usb/

total 33

drwxr--r--  11 root root  2048 Jan  1  1970 .

drwxr-xr-x  14 root users  360 Jul 21 14:10 ..

drwxr--r--   6 root root  8192 May 23 13:46 20040523_rapport

drwxr--r--   3 root root  2048 Aug 18 06:16 Kassekladde

drwxr--r--   3 root root  2048 May 24 21:25 am12_toolbox

drwxr--r--   6 root root  2048 May 24 21:25 backup

drwxr--r--   2 root root  2048 Sep  2 19:45 backup_laptop

-rwxr--r--   1 root root   187 Sep 15 06:32 boss-todo.txt

-rwxr--r--   1 root root   152 Aug 18 14:58 boss-todo.txt~

drwxr--r--   2 root root  2048 May 25 23:32 new_toolbox

drwxr--r--   7 root root  2048 Sep  9 06:26 quintos

-rwxr--r--   1 root root    55 Aug 18 12:09 s.txt

drwxr--r--   2 root root  2048 Sep  9 06:22 tasm

drwxr--r--   9 root root  2048 Sep  9 06:22 tc

preben@echelon preben $

```

But on the workstation the /dev/sdb1, sdb2, sdb3 and sdb4 devices exist, but I mount the /dev/sdb

Trying to results in these errors:

```

root@echelon preben # mount /dev/sdb1 /mnt/usb

/dev/sdb1: Input/output error

mount: /dev/sdb1: can't read superblock

root@echelon preben # mount /dev/sdb2 /mnt/usb

/dev/sdb2: Input/output error

mount: /dev/sdb2: can't read superblock

root@echelon preben # mount /dev/sdb3 /mnt/usb

'/dev/sdb3: Input/output error

mount: /dev/sdb3: can't read superblock

root@echelon preben # mount /dev/sdb4 /mnt/usb

/dev/sdb4: Input/output error

mount: /dev/sdb4: can't read superblock

root@echelon preben #

```

It sure is strange  :Wink: 

Thanks for helping.

----------

## LostInGentoo

Did as suggested..

Removed every partition from the usb flash drive, and I tried to mount on my laptop with

```

bash-2.05b$ sudo mount -t vfat /dev/sda1 /mnt/usb

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

       or too many mounted file systems

bash-2.05b$ 

```

I just did the same on the workstation and there It works (created the partition with CFDISK as a type 0B).

```

usb 1-2: new full speed USB device using address 7

usb 1-2: device not accepting address 7, error -71

usb 1-2: new full speed USB device using address 8

hub 1-2:1.0: USB hub found

hub 1-2:1.0: 1 port detected

usb 1-2.1: new full speed USB device using address 9

scsi2 : SCSI emulation for USB Mass Storage devices

  Vendor: USB 2.0   Model: Flash Disk        Rev: PROL

  Type:   Direct-Access                      ANSI SCSI revision: 00

SCSI device sda: 512000 512-byte hdwr sectors (262 MB)

sda: assuming Write Enabled

sda: assuming drive cache: write through

 sda: sda1

Attached scsi removable disk sda at scsi2, channel 0, id 0, lun 0

Attached scsi generic sg0 at scsi2, channel 0, id 0, lun 0,  type 0

USB Mass Storage device found at 9

Unable to load NLS charset cp437

FAT: codepage cp437 not found

Unable to load NLS charset cp437

FAT: codepage cp437 not found

bash-2.05b$

```

This has something to do with code-page problems I guess.. How to resolve these?

```

bash-2.05b$ ls -la /dev/sda*

brw-rw----  1 root disk 8, 0 Sep 23 21:56 /dev/sda

brw-rw----  1 root disk 8, 1 Sep 23 21:56 /dev/sda1

bash-2.05b$ 

```

Thanks for helping.

----------

## inode77

Just enable the codepage 437 nls support in your kernel under file systems => native language support and recompile. (VFAT needs a valid nls if it should work)

```
<*> Base native language support                                                                                      x x   

  x x                                              (iso8859-1) Default NLS Option                                                                                        x x   

  x x                                              < >   Codepage 437 (United States, Canada) 
```

----------

## LostInGentoo

Which codepage should be used!

I live in denmark - normally the codepage would be 865, but how do I make the vfat fs support this codepage or should it just support the 437 codepage as standard would be?

Thanks

----------

## inode77

Just include the desired codepage(I prefer an iso8859-x as default nls) and set the default to it.

----------

## Nate_S

It sounds as though your pendrive was formated as a floppy drive rather than as a hard drive origionally.  If I were you, I'd back it up, and wipe the partition table, make a new one with fdisk like you would for a hard drive, and format it with vfat from within linux.  This should clear up any errors due to winxp's somewhat unreliable formating.  

-Nate

----------

## tollwilly125

i just had a similar problem. make sure codepage 437 and NLS iso8859-x are set in the kernel... you should be all set

----------

## LostInGentoo

Does vfat require codepage 437 or can it use another codepage if I choose to? (when creating the filesystem)

----------

## tollwilly125

im not completely sure, but i suspect that you can use any of the listed code pages in the kernel config. besides they are all listed under FAT file system support. Let us know how it goes.

----------

## LostInGentoo

 *tollwilly125 wrote:*   

> im not completely sure, but i suspect that you can use any of the listed code pages in the kernel config. besides they are all listed under FAT file system support. Let us know how it goes.

 

Yeah, but the problem is, that I don't know how to make the filesystem with another codepage!

----------

## inode77

You don't need to. I formated my pendrive with and have iso8859-1 specified as default kernel option. I never said use this or that to make my fs on the pendrive. Just make sure you have one it doesn't matter which one.

----------

## LostInGentoo

 *inode77 wrote:*   

> You don't need to. I formated my pendrive with and have iso8859-1 specified as default kernel option. I never said use this or that to make my fs on the pendrive. Just make sure you have one it doesn't matter which one.

 

Well dmesg told me errors when trying to use mkfs.vfat on my laptop where cp437 wasn't in kernel. Now I've chosen the cp437 kernel codepage so now fat works just fine.

----------

## inode77

 *LostInGentoo wrote:*   

>  *inode77 wrote:*   You don't need to. I formated my pendrive with and have iso8859-1 specified as default kernel option. I never said use this or that to make my fs on the pendrive. Just make sure you have one it doesn't matter which one. 
> 
> Well dmesg told me errors when trying to use mkfs.vfat on my laptop where cp437 wasn't in kernel. Now I've chosen the cp437 kernel codepage so now fat works just fine.

 Strange this is my config and my gentoo never complained

```
      <*> Base native language support                                                                                      x x   

  x x                                              (iso8859-1) Default NLS Option                                                                                        x x   

  x x                                              < >   Codepage 437 (United States, Canada)x x   

  x x                                              <M>   Windows CP1250 (Slavic/Central European Languages)                                                              

  x x                                              <*>   NLS ISO 8859-1  (Latin 1; Western European Languages)  
```

----------

