[Techtalk] Partitioning issues.

Alvin Goats agoats at compuserve.com
Fri Jul 25 19:11:56 EST 2003


> Uh oh, now i'm on slippery ground ;-)
> 
> If i remember correctly FAT32 (thats the partition you <gugh> 
> mishandled? <guch> right? has two File Allocation Tables, a master and a 
> copy:
> 1 at the start, and one at block xxx, which is dependent on the 
> partition size. By making it into an extended you added a secondary 
> partition table at block 1 of the extended partition, and the logical 
> ones then live behind that.
> So the secondary partition table overwrote the start of the first (or 
> active or master) FAT. Which is why you no longer can mount it normally. 
> It should be possible though to recover, using the secondary FAT table.
> 
> If you google on <DOS secondary FAT table> you will find several entries 
> that may be of help. Sorry for not having time to further search.
> 


Let's see if I can help a little bit...


The partition table is a peculiar beast that sits at head zero,
track/cylinder zero sector zero on the disk drive (I hesitate to use
hard disk as it is used on Bernoulli, Jaz, Zip, Syquest and other disk
drives). It is designed to be independant of Operating Systems, but does
have flags to help the OS know what partitions are what (or belongs to
itself). These flags are numbered like 82 for linux swap and 83 for
linux native. 

Some versions of windows checked for the appropriate numbers and would
then prompt for you to uninstall linux in order to install windows. A
dirty trick, but easily defeated by logging what each partition really
is, i.e. hda2 is linux swap, hda3 is linux native... Use linux fdisk to
change the partition's label to something like SunOS or Solaris, install
windows and then use linux fdisk again to relabel the partitions back to
what they were. Of course, you have to have some sort of rescue disk or
be able to boot an install CD, but you can bypass some of Microsoft's
nefariousness.

The "extended" or "logical" partitions allows the limited abilities of
the partition record to have more than 4 total partitions. In the early
days, the drives were so small that one partiton was all that was
needed. As disk capacities increased, multiple partitions were needed
for safety and efficiency (system stuff on one partition, data on the
other). 2 primary partitions were used on early PC's and 4 appears to be
the standard today. As disk capacities grew, the limited number of
partions was a pain, so the extended logical partition was made, where
all of the remaining disk space is allocated to one primary partition
and then subdivided into more partitions (I have one drive with 10
partitions to segregate types of data stored). This still resides in the
partition table that is at head zero, sector zero, track/cylinder zero.

The next sector after the partition table is the start of the Master
Boot Record that will actually bootstrap the disk to start loading some
operating system. This could be something like the Microsoft MBR,
OnTrack, Lilo or Grub, which will start loading something. I've found
that on a totally blank OEM type drive, I've had to install something to
the MBR in order for the disk to boot, even if I'm using lilo with the
bootable linux partition's first superblock. 

The filesystem contains an index of what sectors of disk space belongs
to which file. In DOS/Windows, this index is the FAT or File Allocation
Table. For Microsoft systems, this is at a location after the OS
bootsrap (io.sys that loads basic drivers immediately followed by
msdos.sys which bootstrapped the rest of the OS, then the FAT and
finally command.com). 

Originally, there was only one copy of the FAT, and once it was damaged,
there was absolutlely no way to recover the files on the disk. This was
fixed by making a second copy of the FAT which immediately follows the
first FAT on the disk (about MS-DOS 3.3). This is much like having an
index of a book with a second index following the first index. The
operating system writes and updates both FAT's, but generally only used
one. The earlier versions of MS-DOS did not have any repair tools
immediately avaliable, so third party vendors like Mace, Norton and PC
Tools had them which would read both FAT tables and repair the broken
one.

Microsoft has continued to use the same FAT arrangement, and as far as I
know, still uses the same basic FAT structure for XP, modified for 32
bit systems and NTFS. With Windows95 and above, scandisk is the utility
used to fix these damaged systems. It is possible to fix a screwed up
drive by using the install CD's, but it differs greatly between versions
of Windows.

Linux has a file allocation table system as well, using inode tables and
superblocks. Copies of the inode tables are stored at various locations
and typically at certain superblocks. For ext2 filesystems, e2fsck will
check the filesystem and repair a damaged file allocation table as much
as possbile using copies of the inode tables stored at the other
superblocks. If the inode tables and superblocks are too badly damaged
to be repaired, the data is lost, but depending on drive/partition size,
there may be as many as 16 superblocks with copies of the inode tables. 

Other operating systems have other forms of table writing as well.

 
Alvin


More information about the Techtalk mailing list