Partitions and the Partition Table
CS 321 2007 Lecture, Dr. Lawlor
So you've got a disk. The disk stores bytes. You can in
theory access the raw disk (and some database systems do this for
speed!), but it's way more common to build several layers of storage on
top of the raw disk bytes:
- Disks are divided into "partitions", which are just pieces of the
disk used for different things. You can make one disk appear as
your C, D, and E drives by splitting it into three partitions.
You can install Windows and Linux on the same disk using two partitions.
- Partitions are formatted with a "filesystem", like FAT, NTFS, or Linux ext3.
- Filesystems contain many files, like "README.txt".
Example: Windows Disk Manager
To get to the Windows Disk Manager, first right-click on "My Computer"
and hit "Manage", then select "Disk Manager" near the bottom of the
left-hand side list. This shows you all your disks, and
importantly all your partitions:
The original design of the IBM PC's "boot sector" (the first 512 bytes of the disk) left room for only four "primary" partitions.
Since people running multiple operating systems often want more than
this, you can also make an "extended" partition (in green above) that
counts as a primary partition, but contains other smaller "logical
drive" partitions inside of it. You can also leave
unpartitioned space on your disk, which can later be used to create new
If your partition table gets horribly screwed up, you may still be able
to recover your partitions and all their data using a tool like TestDisk.
Example: Linux fdisk
The same disk viewed in Windows above can be examined in Linux like so:
root@dellawlor:/home/olawlor/class/cs321/lecture/fs_fat # fdisk /dev/hda
Again, I've got a bunch of partitions. /dev/hda2 is my Windows
partition. /dev/hda3 is my main Linux partition. /dev/hda4
is my extended partition, which contains hda5 through hda12.
Command (m for help): p
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 6 48163+ de Dell Utility
/dev/hda2 * 7 4262 34186320 7 HPFS/NTFS
/dev/hda3 * 4263 7910 29302560 83 Linux
/dev/hda4 7911 9729 14611117+ 5 Extended
/dev/hda5 7911 8519 4891761 83 Linux
/dev/hda6 8520 9128 4891761 83 Linux
/dev/hda7 9129 9372 1959898+ 83 Linux
/dev/hda8 9373 9495 987966 82 Linux swap
/dev/hda9 9496 9520 200781 b W95 FAT32
/dev/hda10 9521 9545 200781 b W95 FAT32
/dev/hda11 9546 9570 200781 83 Linux
/dev/hda12 9571 9729 1277136 83 Linux
Command (m for help): q
- Power flows into the CPU
- The CPU begins executing the BIOS, which is stored in flash ROM on your motherboard.
- The BIOS looks for a disk whose first sector ends with the two
bytes "0xaa 0x55". This is a "boot sector", or "master boot
- The BIOS executes the boot sector, which has to contain raw 16-bit mode x86 machine code.
- The boot sector code looks at the partition table (stored inside
itself), and finds the boot loader on your boot partition. This
is usually NTLDR for Windows systems, or Grub or LILO for Linux.
- The boot loader finds the OS kernel on the disk.
- The OS kernel starts running, loads up the disks, starts processes, and the machine can then be used for real work.