Topics

What is a Partition

In Windows terms a partition is a drive. Example c: is usually the first hard drive, d: is usually the CD or DVD drive. f: could be the second partition on a hard drive or a second hard drive or even a USB drive you just plugged in.

In Linux a partition is an area of disk storage that is accessed as if it is a directory (folder in windows terms) containing files and other directories. In Linux every thing is a file, even stuff like the modem or keyboard is just another file that it reads from and writes to.

Types of Partitions

There are three types of partitions. Primary, Extended, and Logical.

4 primary partitions

Primary partition information is stored in the master boot record (MBR). Because the size of the MBR is fixed so is the number of primary partitions a drive can have. Four is the number of primary partitions a given drive can have. A primary partition can be formatted as a file system and contain data. Or one can be made a extended partition and contain logical partitions.

primary + extended partition

Extended partitions: One and only one of the primary partitions can be made an extended partition. An extended partition is the container for logical partitions. Think of an extended partition as a kitchen cabinet, think of a logical partition as a box of oatmeal in the cabinet and think of the file and folders in the partition as the oatmeal.

A Logical partition simply put is an area a disk that resides in an Extended partition.

logical partition

Only one primary partition can be exetended but it doesn't matter which one

any primary can be logical

Master Boot Record

master boot record

The MBR and Partitions go hand in hand. The MBR occupies the first 512 bytes of a hard drive (or any other disk drive for that matter) and has three parts:

  1. The boot code which is 446 bytes long. When you see install GRUB to the MBR This is the area of disk that the GRUB install writes a little bit of code to. What this code does is execute the file /boot/grub/stage2
  2. The partition table which is 64 bytes long
  3. The boot code signature of 55aa which is 2 bytes long and goes at the very end

Partition boot sector aka volume boot record.

The first 63 sectors of a partition are what is called the boot sector of a partition. Code placed here is what makes chainloading possible.

Live CD - Mount hard drive partition for edit

sudo mkdir /mnt/root
sudo mount -t ext3 /dev/hda1 /mnt/root

List partitions by uuid with:

ls /dev/disk/by-uuid/ -l

or

blkid

Partition Strategies

T30 laptop Linux used 99% of the time.

IBM T30 laptop partitions

40GB hard drive, 768 MB ram 2.1gHz P4 processor

  1. XP SP3 + Office 2003
  2. Ubuntu Linux / (root)
  3. Ubuntu Linux /home
  4. Data
  5. Swap - a little larger than available memory - laptop hibernates without a problem
  6. Dedicated Grub partition

Linux only desktop

2 - 40GB hard drives, 1GB ram, 2.1gHz P4 processor 2 Runs Ubuntu Desktop, and a LAMP server

whitebox sda partitions
  1. Ubuntu Linux / (root)
  2. Ubuntu Linux /home
  3. Dedicated Grub partition
  4. Swap - 1/2 GB is plenty
  5. test partition
  6. Data
whitebox sdb partitions
  1. Data
  2. Swap - 1/2 GB is plenty

Linux + XP desktop

This PC Runs XP 99% of the time. Used as a file and print server. And for windows games. Dual boots Ubuntu Linux 8,04.

blackbox sda partitions
  1. XP SP3 + Office 2007
  2. Data
  3. Dedicated Grub partition
  4. Ubuntu Linux / (root)
  5. Swap - a little larger than available memory - laptop hibernates without a problem