Partition TableMaster Boot Record: CHS Addressing


Partition Table/Master Boot Record: CHS Addressing

After the partition table has been identified, the user can proceed with Cylinder, Head, Sector (CHS) partition layout. The CHS model was the first defining structure that was developed for partitions, but due to size limits, it was replaced by Logical Block Addressing (LBA), which controls almost all disk partitions today. We begin with CHS to build a foundation for absolute addressing (CHS), thus limiting the total size, and then we discuss relative addressing (LBA).

With CHS, the start, end, and total sectors are defined within the constraints of a 6-bit sector, 10-bit cylinder, and 8-bit head, thus limiting this model to a max capacity of 8.4GB. In the following sections, examples and scenarios are included to help illustrate this concept.

Defining a Primary Partition

Pick your favorite tool and define a 100MB primary partition with type Linux, flagged as a bootable partition on a newly added disk starting at sector 0.

When complete, view your work by using dd if=/dev/disk_device_file of=/tmp/disk_device_file.out bs=512 count=1 where disk_device_file is equal to /dev/sdX or /dev/hdX depending on IDE or SCSI devices. Then, after using bvi, the partition info under the MBR should look similar to the following:

"bvi /tmp/disk_device_file.out"  ****   0  1  2  3  4  5  6  7  8  9 0A 0B 0C 0D 0E 0F 0x1B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 01 0x1C0: 01 00 83 0E 3F 14 3F 00 00 00 46 4D 00 00 00 00 0x1D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA


Note that the bold row beginning with **** does not actually exist; however, it is included here for illustrative purposes to identify the column.

Ending in "55 AA," focus on byte 1BE with value 80, which is a boot flag mark. With byte 1BE set to 80, the BIOS loads the bootloader into memory. In the previous example, byte location 1BF1C1 equals "01 01, 00," which defines the CHS for the starting address space. Later, we discuss how to calculate C:H:S, but for now, these bytes are read (C)ylinders (H)eads (S)ectors, and these values are common on almost all first partition bootable drives.

Note

CHS does not align on the byte boundary; CHS is covered in more detail later in this chapter.


Byte 1C2 defines the partition type. In this example, byte 1C2 has value 83, which implies Linux native. Some of the possible values for byte 1C2 are:

4  FAT16 <32M    3c  PartitionMagic  82  Linux swap   c6  DRDOS/sec (FAT-  5  Extended      40  Venix 80286     83  Linux        c7


A complete list can be found using fdisk, but beware that some of these values are not common and sometimes have multiple meanings. For example, what if byte 1C2 from sector 0 had a value of 42? By only considering the partition types defined by fdisk or cfdisk, we would most likely conclude that the partition type holds a secure filesystem (SFS). However, it's much more probable that the partition is a Windows dynamic disk.

Note

For the remainder of this chapter, we denote Hex with value(H), Binary with value(B), Octal with value(O), and Decimal with value(D).


Byte 01C3 has value "0E," which defines the ending head value in the current partition. 0E (H) = 14(D) heads exist in partition 1.

Bytes 01C4 and 01C5 have a value of "3F 14," which defines the last sector and cylinder count for the partition. Because we are playing with a partition smaller than 8.4GB, we use absolute addressing for the CHS count. This changes when a partition is over 8.4GB to LBA, which we discuss later.

Using absolute addressing, only 6 bits are needed to define the last sector, and 10 bits are required to define the last cylinder, both of which are difficult to depict. Taking the values from locations 01C4 and 01C5 from the previous example and using Table 6-3, we can depict the sector and cylinder counts as follows:

  Sector Cylinder 0011 1111 0001 0100  "3" "F" "1" "4"


Again, note that the sector only needs 6 bits, and 10 bits are required for the cylinder count. To meet this requirement, the bit order must be reestablished. Move the highvalue bits from the first byte and extend the high-value bits on the last byte.

0011 11{11 0001 0100} <---Placing brackets around 6 and 10 bits.


The following shows the move:

1111 11 {00 0001 0100}   3 F {0 1 4}


The cylinder count leaves us with 014(H) = 20 cylinders.

The sector count leaves us with 3F(H) = 63 sectors.

(Cylinder) x (Heads) x (Sectors) = (21) x (15) x (63) = 19845 sectors. However, do not forget about the offset. Offset is determined by byte 01C601C9.

Bytes 01C601C9 have the value "3F 00 00 00."

Offset value 3F(H) = 63(D) sectors. The total size of our partition is 1984563 = 19782 sectors.

To demonstrate the same value described previously through a faster, automated procedure, we can use cfdisk.

# > cfdisk P t /dev/hde Partition Table for /dev/hde          ---Starting---      ----Ending----     Start Number of  # Flags Head Sect Cyl   ID  Head Sect Cyl     Sector  Sectors -- ----- ---- ---- ---- ---- ---- ---- ----  -------- ---------  1  0x80    1    1    0 0x83   14   63   20       63      19782  2  0x00    0    0    0 0x00    0    0    0        0          0  3  0x00    0    0    0 0x00    0    0    0        0          0  4  0x00    0    0    0 0x00    0    0    0        0          0


In this example, the primary partition "1" is fully described. The remaining possible primary partitions are listed, but they are defined with zero placeholders. This is just a characteristic of cfdisk, which always reports all possible primary partitions but only represents values for the logical partitions that are defined.

To continue with our example, bytes 01CA01CD have the value "46 4D 00 00," which defines the total sectors for the partition. In this example, 4D46(H) = 19782 sectors. These bits will be critical later when we stop using absolute addressing and move to LBA addressing (or relative addressing).

Determining Whether Additional Partitions Can Be Created

Now that we have discussed the location of the bits that define the capacity of a partition, let us move to the common question of whether additional partitions can be created. With this next example, we show limitations of primary partitions. Only four primary partitions can exist within a partition table. To illustrate the limitation of primary partitions, we have created four primary partitions, each of which is 10MB in size.

[root@localhost root]# cfdisk -P rst /dev/hde Disk Drive: /dev/hde Sector 0: 0x000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ~~~~~~ 0x1A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 01 0x1C0: 01 00 83 0E 3F 14 3F 00 00 00 46 4D 00 00 80 00 0x1D0: 01 15 83 0E 3F 29 85 4D 00 00 85 4D 00 00 80 00 0x1E0: 01 2A 8E 0E 3F 3E 0A 9B 00 00 85 4D 00 00 80 00 0x1F0: 01 3F 82 0E 3F 53 8F E8 00 00 85 4D 00 00 55 AA Partition Table for /dev/hde             First    Last  # Type     Sector   Sector   Offset  Length   Filesystem Type (ID) Flags -- ------- -------- --------- ------ --------- ---------------- ---------  1 Primary       0    19844      63    19845  Linux (83)        Boot (80)  2 Primary   19845    39689       0    19845  Linux (83)        Boot (80)  3 Primary   39690    59534       0    19845  Linux LVM (8E)    Boot (80)  4 Primary   59535    79379       0    19845  Linux swap (82)   Boot (80)    None      79380 12594959       0 12515580  Unusable          None (00) Partition Table for /dev/hde          ---Starting---      ----Ending----    Start Number of  # Flags Head Sect Cyl   ID  Head Sect Cyl    Sector  Sectors -- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------  1  0x80    1    1    0 0x83   14   63   20       63     19782  2  0x80    0    1   21 0x83   14   63   41    19845     19845  3  0x80    0    1   42 0x8E   14   63   62    39690     19845  4  0x80    0    1   63 0x82   14   63   83    59535     19845


The Number of Sectors on the second, third, and fourth partitions equals 19845 because the 63 sector offset is not present. Therefore, we lost 63 sectors on the first partition.

Bytes 1CF1D1 define the starting sector in absolute partitions, which is the same calculation previously shown on bytes 01C301C5.

For primary partition 2, 01CF01D1 equals "00 01 15." The starting CHS address for the partition is byte 01CF, which has a value of 00. This implies a head value of 0.

Bytes 01D001D1 have a value of "01 15," which equals 0000 00 {01 0001 0101}. Recall that you must have 10 bits for the cylinder count. Move the high-value bits from the first byte and extend the high-value bits on the last byte.

The following shows the bit move:

01 0001 {00 0001 0101}


The decoded values look like this:

01 {001} = 1 sector {21 cylinders}


Byte 01D3 has value "0E" and has the same meaning as 01C3, which defines the last head of the partition. To prevent partitions from overlapping, the start of the next consecutive partition sector count is equal to the end of the previous partition plus one. Therefore, 01D401D5, 01E401E5, and 01F401F5 differ. Refer to 01C301C5 at the beginning of the chapter for calculation rules.

Byte 01DA01DD define the total sectors in the partition that differ between partition 1, 2, 3, and 4 due to the first 63 sector offset for the primary partition. The 63 sector offset is due to BIOS software called dynamic drive overlay (DDO). DDO enables BIOSs that do not support LBA addressing to address drives larger than 528MB. In short, it is an old fix that became a standard.

Scenario 6-1: Error Message While Adding Partitions

The plan is to add a new 72GB disk to a server and then to create several partitions. The customer's machine in this example uses a Compaq Smartarray Controller utilizing the cciss driver. In this case study, the customer adds many partitions until an error message, "Value out of range," displays while adding partitions. The following example is from the Linux server's console.

ml350linux-> fdisk /dev/cciss/c0d0 Command (m for help): p Disk /dev/cciss/c0d0: 72.8 GB, 72833679360 bytes 255 heads, 32 sectors/track, 17433 cylinders Units = cylinders of 8160 * 512 = 4177920 bytes Device Boot Start End Blocks Id System /dev/cciss/c0d0p1 * 1 50 203984 83 Linux /dev/cciss/c0d0p2 51 1078 4194240 83 Linux /dev/cciss/c0d0p3 1079 1592 2097120 83 Linux /dev/cciss/c0d0p4 1593 8716 29065920 f Win95 Ext'd (LBA) /dev/cciss/c0d0p5 1593 3134 6291344 83 Linux /dev/cciss/c0d0p6 3135 4668 6258704 83 Linux /dev/cciss/c0d0p7 4669 5696 4194224 83 Linux /dev/cciss/c0d0p8 5697 6724 4194224 83 Linux /dev/cciss/c0d0p9 6725 7238 2097104 83 Linux /dev/cciss/c0d0p10 7239 7752 2097104 82 Linux swap /dev/cciss/c0d0p11 7753 8266 2097104 83 Linux /dev/cciss/c0d0p12 8267 8645 1546304 83 Linux Command (m for help): Command (m for help): n First cylinder (8646-8716, default 8646): Using default value 8646 Last cylinder or +size or +sizeM or +sizeK (8646-8716, default 8716): \ +1000M Value out of range. Last cylinder or +size or +sizeM or +sizeK (8646-8716, default 8716): \ Using default value 8716


Solution 6-1

fdisk uses blocks rather than sectors. One block is equal to 1024 bytes, so the block count is always half the sector count. The problem in this example is that the primary partitions 14 are defined, and the last primary partition, 4, was defined too small.

Notice that partition 4 is marked with the extended partition flag, which means logical partitions reside within it. If fdisk, cfdisk, or a GUI tool such as diskdrak, disk druid, or yast2-partitioner were used to delete primary partition 4 and redefine it with all cylinders, the customer would have been able to define his new volume.

Warning

By deleting partition 4 in this example, all logical volumes under the extended partition would be deleted.


/dev/cciss/c0d0p4 1593 8716 29065920 f Win95 Ext'd (LBA) <--- largest # of sectors is set to low... /dev/cciss/c0d0p5 1593 3134 6291344 83 Linux /dev/cciss/c0d0p6 3135 4668 6258704 83 Linux /dev/cciss/c0d0p7 4669 5696 4194224 83 Linux /dev/cciss/c0d0p8 5697 6724 4194224 83 Linux /dev/cciss/c0d0p9 6725 7238 2097104 83 Linux /dev/cciss/c0d0p10 7239 7752 2097104 82 Linux swap /dev/cciss/c0d0p11 7753 8266 2097104 83 Linux /dev/cciss/c0d0p12 8267 8645 1546304 83 Linux




Linux Troubleshooting for System Administrators and Power Users
Real World Mac Maintenance and Backups
ISBN: 131855158
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Joe Kissell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net