Another DOS Format issue with MMC/SD

Gene Smith gds at
Mon Jan 26 16:33:10 UTC 2009

After getting the format command to actually write to my MMC card I 
noticed another problem. I am not sure that it might not be a user error 
of some sort.

When I format with shell cmd
msdosfmt -t 16 /dev/sd-card-a
if I mount the card (or if it remained mounted during fmt), the files 
and data are still there but I think just in cache. So it appears the 
cache is not invalidated by fmt code.

If I restart RTEMS and mount, I can no longer mount /dev/sd-card-a1 but 
have to mount /dev/sd-card-a . Also, the sd-card-a1 partition no longer 
appears when I "ls /dev/", just sd-card-a.

When I put the card on linux, it automounts as device sdc and not sdc1 
as it would before. If I try to format it with gparted, it claims there 
are problems.

When I look at the device with dd in=dev/sdc out=t.txt I see that 
previous OEM formatting of the MBR (1st sector) and the FAT boot record 
(many sectors down) are gone. Instead the first block is not the MBR but 
the FAT boot record followed by the FAT tables and after that OK I 
think. So the disk looks like a "partition" (called sdc) w/o a MBR. I 
can mount it and copy files to it OK in linux.

When I put the card back on RTEMS I can see files and copy them OK but 
still can only mount /dev/sd-card-a.

Then back on linux with gparted, if I re-partition and then format I get 
a MBR back and can see and mount partition sdc1 and on RTEMS sd-card-a1 

Looking at the RTEMS dos fmt code, it appears that it does not read in 
the current MBR and FAT boot record before reformatting but tries to 
determine the parameters based on other information it has. Also, it 
writes the FAT boot record in the first sector (in the code it calls it 
"MBR") which wipes out the valid MBR in the first sector.

I have noticed that other fmt tools (gparted, xp format) seem to keep 
the original MBR and FAT boot record (if valid) and only reinitializes 
the fat table and root dir area. They don't delete or change the 
MBR/partition table or move or change the FAT boot record, I think.


More information about the users mailing list