LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Formating FAT32, but linux created FAT32 is not like win created FAT32?? Difference? (https://www.linuxquestions.org/questions/linux-newbie-8/formating-fat32-but-linux-created-fat32-is-not-like-win-created-fat32-difference-820695/)

boki15 07-19-2010 09:12 AM

Formating FAT32, but linux created FAT32 is not like win created FAT32?? Difference?
 
Hello,

I have one Problem and can't even understand it.

When I format my SD Card in win with fat32 (I do it with bootice), everything works but when I format with linux (I tried mkfs.vfat, mkfs.msdos, gparted, fdisk) nothing works.

I created a shell script which creates multiboot usb with one NT6 system some Live ISO's and I added posibillity to chainload with grub2 in mbr all other popular bootloaders like syslinux, grub4dos, nt5 (ntldr),...

Problem: If I format my SD card in win and run then my script, everything works great. But as soon as I format it in linux nothing works. I can't boot win7 (pc restarts), for syslinux I get "boot error" and for grub "no grldr". I really don't understand what the difference is or how to format. I tried some other commands (with offset, -o) but nothing works, I getting already mad it's like somebody is telling me that 1+1 is not 2!

Actually everything works, but I just can't belive that I really need commercial OS like Win to format my SD card if there are so many great linux distros.

If nobody knows how to format right, just explain the difference beetween windows created FAT32 (0x0b) and gparted, fdsik,... created FAT32 (0x0b)?

BTW: I tried it from ubuntu lucid, maverick installed and also iso's, same results

GrapefruiTgirl 07-19-2010 09:21 AM

You might find this other thread of interest: http://www.linuxquestions.org/questi...tition-386916/

Hopefully that addresses the issue; if not, let us know.

boki15 07-19-2010 09:22 AM

thanks, I'll take a look now :)

boki15 07-19-2010 09:39 AM

@GrapefruiTgirl

as long as I understood the link, there was an LBA problem. The solution was to format it with 0x0C instead of 0x0B. As long as I understand LBA, with 8gb SD Card there is no sense to format with 0x0C (win formats it also with 0x0B and everything works). And I don't have problem that win/linux/macos/dos/... (I tried them all) can't read the partition (no matter if formated in win, linux, macos). My problem is more that in both OS I create FAT32 (0x0B) without errors and everything works fine. The only difference is the behavior during boot process, which is incorrect if I format it from linux, in my case ubuntu lucid.

I thought also that it could be BIOS thing, but it can't be bios problem because I tested it on different mainboards and notebooks).

GrapefruiTgirl 07-19-2010 09:44 AM

Hmm.. OK, I don't have a further suggestion at this time - hopefully someone else can shed some insight.

Best of luck - hopefully it's something simple!

boki15 07-19-2010 09:58 AM

Anyway, thanks for a help.

Here are some things that I tried, maybe it helps someone to help me :)

format with linux:
1. Format fat32
Code:

sudo mkfs.vfat -n ${VOLUME} ${DEVICE}1
or
Code:

sudo mkfs.msdos -n ${VOLUME} ${DEVICE}1
or
gparted/fdisk
2. install syslinux
Code:

sudo ./syslinux/linux/syslinux ${DEVICE}1
3. install grub2
Code:

sudo grub-install --no-floppy --root-directory=/media/${VOLUME} ${DEVICE}
4. create all menus with "cat <<EOF>"

format with Win:
1. Format fat32
2. Start Linux/Linux LiveCD
3. install syslinux
Code:

sudo ./syslinux/linux/syslinux ${DEVICE}1
4. install grub2
Code:

sudo grub-install --no-floppy --root-directory=/media/${VOLUME} ${DEVICE}
5. create all menus with "cat <<EOF>"


checking all if formated with win:
Backup mbr, destroy mbr, restore mbr - all OK
Backup pbr, destroy pbr, restore pbr - all OK
Backup mbr & pbr, create new ms-dos fs ie w. gparted, create new partition (smaller) in windows, restore mbr & pbr - all OK
Backup mbr & pbr, create new ms-dos fs ie w. gparted, create new partition (smaller) in linux, restore mbr & pbr - NOT WORKING

checking all if formated with linux:
Backup mbr, destroy mbr, restore mbr - no difference only grub2 works - NOT WORKING
Backup pbr, destroy pbr, restore pbr - no difference only grub2 works - NOT WORKING
Backup mbr & pbr, create new ms-dos fs ie w. gparted, create new partition (smaller) in windows, restore mbr & pbr - all OK
Backup mbr & pbr, create new ms-dos fs ie w. gparted, create new partition (smaller) in linux, restore mbr & pbr - NOT WORKING

mostlyharmless 07-19-2010 10:32 AM

Maybe of interest, from "man mkfs.vfat":

Quote:

Bugs
mkdosfs can not create bootable filesystems. This isn't as easy as you might think at first glance for various reasons and has been discussed a lot already. mkdosfs simply will not support it ;)

tredegar 07-19-2010 10:32 AM

No, you misunderstand:

It not "format with 0x0C instead of 0x0B", it is partition as ...

When you partition a disk, there is a byte to the partition table that describes the filesystem type. This is the Id of the partition that you see listed with fdsik -l

FAT16 is type 5
FAT16 LBA is type e
FAT32 is type b
FAT32 LBA is type c
Linux is type 83

Etc.

Linux does not care if the filesystem (as generated by format (mkfs...)) is different from the partition table descriptor byte (as written by fdisk).

Windows does care.

So, check your partition table on the removable device. You probably need to change it to type b, by using fdisk and then reformat the partition to FAT32.

GrapefruiTgirl 07-19-2010 10:33 AM

LOL -- thanks *harmless, apparently the answer right under our noses, in the man pages :/ though I still am optimistic for *something* good..

tredegar 07-19-2010 10:45 AM

In the light of the above, don't forget to mark the partition as "bootable" ( by using fdisk not mkfs... [this is not mkfs's job, it is the job of fdisk to mark partitions as "bootable"] )

boki15 07-19-2010 10:54 AM

Partition is marked as bootable and it has never changed from 0x0b. Actually grub2 should work on all, syslinux not, the only one compatible to all bootloaders I use is fat32, it's slow but it has advantage that all OS can read/write it, including macos which I also boot.

I tried msdos just to see if there is a difference in booting, grub2 can boot from msdos, syslinux too.

mkfs.vfat:
Code:

Platte /dev/sdf: 8166 MByte, 8166309888 Byte
255 Köpfe, 63 Sektoren/Spur, 992 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004c935

  Gerät  boot.    Anfang        Ende    Blöcke  Id  System
/dev/sdf1              1        992    7968208+  b  W95 FAT32

Screenshot

boki15 07-19-2010 11:19 AM

Maybe it will help if you look at menus:

Grub2 is in MBR and Syslinux 3.86 in PBR and if it's formated from win, then these entries work:
Grub2 Menu:
Code:

menuentry "00. BOOTMGR (NT6) via PBR file" {
insmod fat
set root=(hd0)
chainloader (hd0,1)/bootmgr.pbr +1
boot
}
menuentry "01. Grub via PBR (second stage bootloader)" {
 insmod fat
 set root=(hd0)
 chainloader (hd0,1)/grldr.pbr +1
}
menuentry "02. Grub4Dos" {
 linux16 /boot/grub4dos/grub.exe
}
menuentry "03. Syslinux via chainloading" {
 insmod fat
 set root="(hd0,1)"
 chainloader +1
}
menuentry "03. Syslinux via PBR file" {
 insmod fat
 set root="(hd0)"
 chainloader (hd0,1)/syslinux.pbr +1
}
menuentry "04. NTLDR (NT5) via PBR file" {
 insmod fat
 set root="(hd0)"
 chainloader (hd0,1)/ntldr.pbr +1
}

syslinux menus
Code:

label back
menu  label grub2
TEXT HELP
 This entry will bring you to the Grub2 menu.
ENDTEXT
kernel /boot/syslinux/chain.c32
append hd0 0

label nt6
menu  label 01. NT6 chainload
TEXT HELP
 NT6 - bootmgr
ENDTEXT
com32 /boot/syslinux/chain.c32
append ntldr=/bootmgr

If I format in Linux, these entries just don't work. I tried restoring pbr's and mbr's, but it's always the same. Win formated partiotion - OK, linux - NOT WORKING

If you want to try, here are my pbr's.

tredegar 07-19-2010 11:41 AM

Thank you. Two things to think about:
1] There is no boot marker:
Code:

Platte /dev/sdf: 8166 MByte, 8166309888 Byte
255 Köpfe, 63 Sektoren/Spur, 992 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004c935

  Gerät  boot.    Anfang        Ende    Blöcke  Id  System
/dev/sdf1  *          1        992    7968208+  b  W95 FAT32

2] Maybe format the card from windows, then, before you do anything else, use dd to make a copy of the MBR:

Code:

dd if=/dev/sdf of=WIN-MBR-backup bs=512 count=1
Then format the card from linux, and make another copy of the MBR:

Code:

dd if=/dev/sdf of=Linux-MBR-backup bs=512 count=1
Then use cmp to compare the two files.
Are they the same, if not, what are the differences?

Aside:
Quote:

If you want to try, here are my pbr's.
It won't download (but I'd have to read up on what a pbr is! I never had to mess with them).

boki15 07-19-2010 12:02 PM

Thanks for help,

I did it already yesterday,but I didn't save logs about it (deleted non working). I'll try it now again to post the result.

Yesterday the result was:
Extracted mbr and pbr from Windows formated sd. Reformat in windows, restore mbr/pbr from win or linux. Everything works.

Formated in linux and restored mbr/pbr which was backed up from win formated partition. Same result, not working (exactly: mbr loads always,no matter if in win or linux formated. pbr boots only if formated in win. This is the problem. I even tried to install syslinux from win to pbr of partition which was created with mkfs.vfat/mkfs.msdos/gparted/fdisk, same result, not working.

As you can see in gparted, it's marked as boot. Even if not it should work with makeactive (for grub) and parttool (hd0,1) boot+ (for grub2).

I formated now with with win
sudo fdisk -l /dev/sdb
Code:

Platte /dev/sdb: 8166 MByte, 8166309888 Byte
255 Köpfe, 63 Sektoren/Spur, 992 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004c935


boki15 07-19-2010 12:04 PM

PBR - Partition Boot Record (Second Stage Bootloader)


All times are GMT -5. The time now is 08:56 PM.