LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Can't mount USB stick due to "FAT: invalid media value (0xb9)" (https://www.linuxquestions.org/questions/linux-kernel-70/cant-mount-usb-stick-due-to-fat-invalid-media-value-0xb9-795792/)

bergin 03-16-2010 10:07 AM

Can't mount USB stick due to "FAT: invalid media value (0xb9)"
 
Hi,

I'm working with an embedded system (mach-ep93xx) and have just started up the USB bus on this device. My first test is to attach a USB sitck and mount it. When I attach my stick thing looks good:

----------------------------------------------------------
usb 1-1: new full speed USB device using ep93xx-ohci and address 2
usb 1-1: New USB device found, idVendor=125f, idProduct=c83a
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: A-DATA USB Flash Drive
usb 1-1: Manufacturer: A-DATA
usb 1-1: SerialNumber: 5d0269e36c10f4
scsi0 : usb-storage 1-1:1.0
...
scsi 0:0:0:0: Direct-Access A-DATA USB Flash Drive 0.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [sda] 7897088 512-byte logical blocks: (4.04 GB/3.76 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda:
sda1
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI removable disk
----------------------------------------------------------

Next step is to mount my device and thing does not go well:

----------------------------------------------------------
~ # mount -t vfat /dev/sda1 /mnt/memstick
FAT: invalid media value (0xb9)
VFS: Can't find a valid FAT filesystem on dev sda.
mount: Mounting /dev/sda1 on /mnt/memstick failed: Invalid argument
----------------------------------------------------------

I have done exactly the same steps on a Ubuntu machine and there it works fine. I have searched a lot after the error printout "FAT: invalid media value" but can not find any clue what this mean. Is there any suggestions what's wrong? Any configuration missing?

The error printout is located in fs/fat/inode.c. The function 'fat_valid_media' in include/linux/msdos_fs.h says that valid media is (media==0xf0) or (media >= 0xf8).

Regards,
/Peter

smoker 03-16-2010 11:41 AM

What does fdisk -l have to say about the stick ?

Where did you get sda1 from ?

bergin 03-17-2010 01:58 AM

On my Embedded system I run busybox without fdisk but when I run fdisk -l on my Ubuntu I got the following information:

----------------------------------------------------------
Disk /dev/sda: 4043 MB, 4043309056 bytes
255 heads, 63 sectors/track, 491 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb0ae4efc

Device Boot Start End Blocks Id System
/dev/sda1 * 1 492 3948543+ b W95 FAT32
Partition 1 has different physical/logical endings:
phys=(490, 254, 63) logical=(491, 145, 38)
----------------------------------------------------------

I get sda1 from the dmesg output.

smoker 03-17-2010 06:52 AM

Use fdisk to delete all the partitions on /dev/sda then create a new partition as type FAT32.

Similar to http://www.linuxquestions.org/questi...player-660046/

bergin 03-17-2010 08:13 AM

Thanks for your advice smoker! I will try to avoid doing anything with the memory for a while. The question I try to find the answer to is why I can mount the memory in my Ubuntu and on my Windows machine but not on my embedded linux system? My task now is to config the linux system and I will make it work to plug in USB drives to it.

I found a description of the FAT boot sector here (http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html). Obviusly in my memory on byte 21 there is value 0xb9 (I have checked with hexdump) which is not a valid media according to FAT specification. The strange thing is that neither my Ubuntu nor my Windows complains about this, but my own homemade Linux kernel does. Does anybody have some ideas why?

Here is the first 512 bytes, i.e. the FAT boot sector, on the USB memory:
----------------------------------------------------
FA 31 C0 8E D8 8E D0 BC 00 7C 89 E6 06 57 8E C0
FB FC BF 00 06 B9 00 01 F3 A5 EA 1F 06 00 00 52
52 B4 41 BB AA 55 31 C9 30 F6 F9 CD 13 72 13 81
FB 55 AA 75 0D D1 E9 73 09 66 C7 06 8D 06 B4 42
EB 15 5A B4 08 CD 13 83 E1 3F 51 0F B6 C6 40 F7
E1 52 50 66 31 C0 66 99 E8 66 00 E8 21 01 4D 69
73 73 69 6E 67 20 6F 70 65 72 61 74 69 6E 67 20
73 79 73 74 65 6D 2E 0D 0A 66 60 66 31 D2 BB 00
7C 66 52 66 50 06 53 6A 01 6A 10 89 E6 66 F7 36
F4 7B C0 E4 06 88 E1 88 C5 92 F6 36 F8 7B 88 C6
08 E1 41 B8 01 02 8A 16 FA 7B CD 13 8D 64 10 66
61 C3 E8 C4 FF BE BE 7D BF BE 07 B9 20 00 F3 A5
C3 66 60 89 E5 BB BE 07 B9 04 00 31 C0 53 51 F6
07 80 74 03 40 89 DE 83 C3 10 E2 F3 48 74 5B 79
39 59 5B 8A 47 04 3C 0F 74 06 24 7F 3C 05 75 22
66 8B 47 08 66 8B 56 14 66 01 D0 66 21 D2 75 03
66 89 C2 E8 AC FF 72 03 E8 B6 FF 66 8B 46 1C E8
A0 FF 83 C3 10 E2 CC 66 61 C3 E8 62 00 4D 75 6C
74 69 70 6C 65 20 61 63 74 69 76 65 20 70 61 72
74 69 74 69 6F 6E 73 2E 0D 0A 66 8B 44 08 66 03
46 1C 66 89 44 08 E8 30 FF 72 13 81 3E FE 7D 55
AA 0F 85 06 FF BC FA 7B 5A 5F 07 FA FF E4 E8 1E
00 4F 70 65 72 61 74 69 6E 67 20 73 79 73 74 65
6D 20 6C 6F 61 64 20 65 72 72 6F 72 2E 0D 0A 5E
AC B4 0E 8A 3E 62 04 B3 07 CD 10 3C 0A 75 F1 CD
18 F4 EB FD 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 FC 4E AE B0 00 00 80 00
02 00 0B FE 7F EA 01 00 00 00 FF 7F 78 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA
----------------------------------------------------

nini09 03-17-2010 03:07 PM

Does your embedded system (busybox) support vfat file system? Most PC Linux distribution support vfat.

bergin 03-18-2010 09:33 AM

New interesting information found during my search for the answer.

My problem always occurs at /dev/sda1 and is independent of physical USB port and which USB stick (I have two ports and two USB sticks). I found this because when I attached two USB sticks one became /dev/sda1 and the other /dev/sdb1. /dev/sdb1 is possible to mount always but never /dev/sda1.

After that I went on with my hexdump's and found that when dumping from /dev/sda1 on my embedded system compared to dumping from /dev/sdb1, from same physical device, there are new information in the beginning of /dev/sda1 compared to /dev/sdb1. Approximately 16kB additional data is seen on /dev/sda1 before the common data seen on both /dev/sda1 and /dev/sdb1. This additional data contains several FAT boot sectors (512 bytes ending with 0x55AA). When trying to mount /dev/sda1 it looks at the "additional data" and say that is has wrong media.

(On my Ubuntu the USB stick always become /dev/sdb1 and therefore it is possible to mount it there. When I dumped /dev/sda1 on my Ubuntu I seen the same pattern as on /dev/sda1 on my embedded system. That is the reason why I can mount on my Ubuntu but not on my embedded system.)

Over to the big question I have: How is it possible to read different information from /dev/sda1 and /dev/sdb1 from the same physical device? Is there any configuration in Linux telling that /dev/sda1 has any special feature so it is handled in a special way?

bergin 03-19-2010 02:05 AM

I found the cause of the trouble. :) My misstake. :newbie:

When I created the nodes /dev/sda and /dev/sda1 I used same MAJOR and MINOR number for them (8,0). I now recreated /dev/sda1 with MINOR=1 (8,1) and then it worked to mount my USB memory stick on both sda1 and sdb1.

smoker 03-19-2010 07:32 AM

And people wonder why it's difficult to help.
It might have been useful to know that you created those right at the beginning.


All times are GMT -5. The time now is 07:58 PM.