LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 03-16-2010, 10:07 AM   #1
bergin
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Rep: Reputation: 0
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
 
Old 03-16-2010, 11:41 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
What does fdisk -l have to say about the stick ?

Where did you get sda1 from ?
 
Old 03-17-2010, 01:58 AM   #3
bergin
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 03-17-2010, 06:52 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
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/
 
Old 03-17-2010, 08:13 AM   #5
bergin
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Original Poster
Rep: Reputation: 0
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
----------------------------------------------------
 
Old 03-17-2010, 03:07 PM   #6
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,010

Rep: Reputation: 71
Does your embedded system (busybox) support vfat file system? Most PC Linux distribution support vfat.
 
Old 03-18-2010, 09:33 AM   #7
bergin
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Original Poster
Rep: Reputation: 0
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?
 
Old 03-19-2010, 02:05 AM   #8
bergin
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I found the cause of the trouble. My misstake.

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.
 
Old 03-19-2010, 07:32 AM   #9
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Invalid mount option when attempting to mount the volume." on plugging USB sumeet inani Linux - Newbie 5 02-23-2010 09:40 PM
LXer: Installing "Sugar on a stick" (Strawberry Release) On A USB Stick LXer Syndicated Linux News 0 08-04-2009 03:50 PM
Slackware 12.2 /sbin/dhcpcd: invalid option R due to DHCP_KEEPRESOLV[x]="yes" rhermsen Slackware 2 07-19-2009 12:06 PM
USB stick won't mount ("wrong fs type, bad option, bad superblock ...") Arla Linux - Hardware 4 06-01-2007 07:23 AM
can mount C not D FAT: invalid media value (0x45) mount: wrong fs type, bad option Emmanuel_uk Linux - Newbie 10 11-29-2005 02:47 AM


All times are GMT -5. The time now is 07:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration