3. Technical info

3.1. Disks

A hard disk is made of sectors numbered from 0 to the max.

dmesg gives, for example:

hdb: ST34321A, 4103MB w/128kB Cache, CHS=523/255/63

CHS means Cylinders, Heads, Sectors.

523*255*63=8401995 sectors of 512 bytes, thus the 4103 MB. This is only a logical map; it's not necessarily what is written on the disk cover (except for the total size).

The true size of the sectors is of no interest for us, given that we don't want to modify anything, but merely wish to restore a previous state. For us, the default size given by fdisk is all right.

The size seen by the system is directly dependent on the work of the BIOS (Basic Input/Output System - the PC's ROM). The mode of the hard disk indicated in the BIOS is essential. On a new disk, it's better to use BIOS automatic hard disk recognition and say "yes". Anyway, any modification at this level may destroy all the data of the disk, so don't play with this without essential reason.

This is probably what your disk already uses, so don't be afraid.

3.2. Partitions

Disk are now huge -- 500 GB drives are not rare -- so it's not really handy to have all this stuff packed in only one part. Only MS Windows does so, and, if you use Linux, maybe it's because you are aware of how inefficient the other is.

So a hard disk is usually cut in some pieces called "partitions" (see the Partition HOWTO for details, also read README.fdisk on the web or on your disk - location vary).

Let's get a look at (part of) my own print of fdisk -l :

Disk /dev/hdb: 255 heads, 63 sectors, 523 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 153 1228941 83 Linux
/dev/hdb2 154 166 104422+ 82 Linux swap
/dev/hdb3 * 167 291 1004062+ 83 Linux
/dev/hdb4 295 523 1839442+ 5 Extended
/dev/hdb5 295 422 1028128+ 83 Linux
/dev/hdb6 423 523 811251 6 FAT16

This is my second hard disk, tied to guesses and tries. (The first is too simple to be interesting.)

/dev/hdb is my second ide disk (slave on the primary interface),

/dev/hdb1 is the first primary partition, running from the first (1) block to the block 153.

There can be four such primary partitions. If one wants more than 4, one of them must be repurposed as an "extended" partition (not necessarily the fourth), and all other partitions are "logical" and are located inside the extended one. Notice that partition number 5 and partition number 4 have the same beginning. Number five is logical, number 4 extended. Logical partitions' numbering always begins at 5, even if there are only 2 primary partitions.

Here's the fdisk -u -l listing of an other disk:

Disque /dev/hda : 240 têtes, 63 secteurs, 2584
cylindres Unités = secteurs sur 1 * 512 octets
Périphérique Amorce Début Fin Blocs Id Système
/dev/hda1 * 63 10357199 5178568+ c Win95 FAT32 (LBA)
/dev/hda2 15452640 39070079 11808720 83 Linux
/dev/hda3 10357200 15150239 2396520 f Win95 Etdue (LBA)
/dev/hda4 15150240 15452639 151200 84 Lecteur C: caché OS/2
/dev/hda5 10357263 10463039 52888+ 83 Linux
/dev/hda6 10463103 10780559 158728+ 82 Echange Linux
/dev/hda7 10780623 15150239 2184808+ 6 FAT16
Les entrées de la table de partitions ne suivent pas l'ordre du disque.

Don't worry about the French part, I'm French ... look at your own disk listing. Of course, numbers are bigger.

3.3. Why is there a problem?

The problem is that all installed operating systems must share the disks, and, since at start, the BIOS only scans the first one, there must be a so called "partition table" at the very beginning of this disk. This partition table is located in the Master Boot Record (MBR), side by side with the boot loader.

Any misuse of the MBR by any of the OS's leads to problems. When trying to install any system, a "yes" answer at a question like "automatic partitioning?" is likely to give problems... This is specially true with MS Windows, and especially with custom MS Windows installations made by special makes' PCs (when no true "Windows" CD is included, as with many laptops). But it's also true with some "smart" (not so smart!) Linux installation programs included with some distributions (hopefully this is not more the case in 2008).