Partition table or boot sector?

I have encountered the following problem:

It appears that some FAT32 formatted Compact Flash cards have the partition table whereas some other cards don't. This creates trouble during the initialization of the file system.

I couldn't find a standard procedure to distinguish the boot sector and the partition table. We can do some speculation on the values of the different fields, however that may not be valid for all cases, such as for the different file systems.

Do you know if there is a standard recommended procedure for that purpose?

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky
Loading thread data ...

Are we talking about a x86, BIOS valid, boot sector ?

If so, then traditional disks require 0xAA55 in the last couple of bytes in the boot sector for the BIOS to detect it as a valid boot sector. I would assume that bootable CF cards have the same requirements.

See

formatting link
. It's been a while since I've written boot sector code, so I can't remember if 0xAA55 is stored as a big or little endian number on disk.

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980's technology to a 21st century world
Reply to
Simon Clubley

Thank you for the useless advice. Partition table has 0xAA55, too.

Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

I should also point out that the primary partition table _is_ part of the boot sector on traditional disks and resides at a known location within the boot sector.

Therefore if CF cards are laid out like normal disks, you would either get a boot area (even if not filled in) _and_ partition table or neither.

I've found the following that might be of interest:

formatting link

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980's technology to a 21st century world
Reply to
Simon Clubley

Also quite useful would be a utility that erases everything and then creates a standard boot sector and partition table. Anyone know of one?

Reply to
me

On the compact flash, there could be either MBR or VBR. This is the experimental fact, although it may not be exactly correct from the point of view of the specifications.

The question is: what is the standard procedure to distinguish if this is MBR or VBR.

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

You can use fdisk, gparted, or any other partitioning utility. There's nothing special about CF cards. They're just normal block devices (at least for the purposes of this discussion).

--
Grant Edwards                   grante             Yow! My pants just went to
                                  at               high school in the Carlsbad
                               visi.com            Caverns!!!
Reply to
Grant Edwards

WinHex from

formatting link
comes with a set of template files for breaking down the contents of key physical disk sectors, including the master boot record and partition table entries. I don't want to post his templates but the product itself is pretty reasonably priced and a useful tool if you need to work with disk-like objects at that low level.

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

Interesting; I wasn't aware of that - the last time that I came across VBRs on the primary boot sector was when experimenting with boot blocks on floppy devices.

Is there some reason why you have to use the devices as is or can you wipe them ?

On Linux, I format new devices by using dd to wipe the first few sectors of the device, then use fdisk to create a partition table, before using the standard filesystem formatting utilities on the individual partitions.

If I need a boot block on the device I either install grub or let the operating system that I'm installing write one.

Simon.

PS: Warning to anyone reading this: you don't get a second chance when using dd; if you make a mistake and get the wrong target disk you _will_ wipe the wrong device.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980's technology to a 21st century world
Reply to
Simon Clubley

Which is why this style of formatting block devices is referred to as the "super floppy" format. It went out of fashion in the PC field somewhere between MO disks and ZIP disks.

And if you want a super-floppy, just drop the fdisk step, and format the primary device as-is --- assuming the system allows this for the device. Some will only do so for removable drives.

Reply to
Hans-Bernhard Bröker

Boot sectors generally start with hex "EB ?? 90" followed by 8 bytes of readable text (which some versions of windows clobber) followed by a BPB, which contains a filesystem indicator in readable text "FAT16" or "FAT32" . . . NTFS boot sectors appear not to have it.

Partition tables (that I have seen) generally start with hex "33 C0", and generally don't any readable text until near the end.

I have only really seen DOS & Windows versions of each, and this assumes that the sector is not just a dummy.

--
ArarghMail810 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the extra stuff from the reply address.
Reply to
ArarghMail810NOSPAM

It's still known in certain circles because formatting the raw device gives you a little more space, and you don't want to waste that!!!!1

Recently, a customer came to me with a SD card formatted this way. SD cards are even worse because the CSD register can explicitly say "this card has a partition table", but if J.R.Lamer has formatted it, it of course has none.

I now try to parse the whole partition table, and if it doesn't make sense, I retry parsing it as a superfloppy boot sector. Of course this can fail, but that's the problem if you violate the format specs...

I don't think parsing opcodes makes too much sense. Boot sectors start with an x86 jump instruction, 0xE9 or 0xEB, but I don't see a reason why a partition table should not start with a jump. Actually, I believe one of those I wrote did that.

Stefan

Reply to
Stefan Reuther

That's what I am trying to do, too. However, just for example, Windows have no problems accessing media formatted either way. That makes me think that there should be a standard method for distinguishing VBR and MBR.

Exactly. There could be somewhat ~five equally valid variants of start for MBR or VBR.

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

Linux tries to read the partition table and if it fails no partition nodes are created. So you will end up with a "/dev/sda" only (or sdb, ...). If you know the filesystem you can try to mount this full device. If Linux detects a partition table it will also create at least a /dev/sda1 (or sdb1,....). If it is present you must mount this one instead of the raw /dev/sda.

jbe

Reply to
Juergen Beisert

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.