Partition

Here is a review of disk partitions.

First, you have a disk. Within this disk, there is a slice table (also called "partition table" under Linux and Windows to further confuse things). The slice table is modified/managed with the fdisk program. In the slice table, you can have up to 4 primary slices.

One of four primary paritions can act as a "container" for up to 23 logical slices. Logical partitions are usually located within primary partition #4, but this is merely convention, and not a requirement. The numbering for logical slices always starts at "5", regardless of the number of primary partitions. The aggregate size of logical paritions cannot exceed the size of the primary partition in which they reside; however, it is permissable to have unused space.

Slices and partitions are allowed to overlap, but this is typcially a very bad idea. That said, below for information on slice "c" or "2" below, which typically refers to the "whole disk."

A slice is identified by an 8 bit number indicating what sort of slice this is here are a few common ones:


 * 0x04 DOS FAT-16
 * 0x07 NPFS/NTFS
 * 0x0B Win95 FAT-32
 * 0x83 Linux
 * 0x82 Linux swap
 * 0x9F BSDI
 * 0xA5 FreeBSD
 * 0xA6 OpenBSD
 * 0xA8 Mac OS X
 * 0xA9 NetBSD
 * 0xAB Mac OS X Boot
 * 0xB7 BSDI files
 * 0xB8 BSDI swap
 * 0xBF Solaris
 * 0xFD Linux RAID

In some Operating Systems (e.g. Linux and Windows) to put a filesystem directly on one of the slices. Conceptually, this looks like:



Not so with most other UNIX-like Operating systems (including all of the BSD variants and Solaris X86) which will put a partition table inside the slice. Individual partitions will hold filesystems such as / (root), /usr, /var, /tmp, /usr/home and so on. In OpenBSD up to 16 partitions are allowed. The program disklabel (in FreeBSD it's called bsdlabel) manages the partitions:

type: ESDI disk: ESDI/IDE disk label: SAMSUNG SP1614C flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 16383 total sectors: 312581808 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0          # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: a:      2097648      65802240  4.2BSD   2048 16384  328 # Cyl 65280 - 67360 b:      4194288      67899888    swap                   # Cyl 67361 - 71521 c:    312581808             0  unused      0     0      # Cyl     0 -310100 d:     12582864      72094176  4.2BSD   2048 16384  328 # Cyl 71522 - 84004 e:    227899665      84677040  4.2BSD   2048 16384  328 # Cyl 84005 -310095* i:     65802177            63 unknown                   # Cyl     0*- 65279
 * 1) disklabel wd0
 * 2) Inside MBR partition 3: type A6 start 65802240 size 246774465
 * 3) /dev/rwd0c:
 * 1)             size        offset  fstype [fsize bsize  cpg]

Note: These partitions can then be newfs'ed  and mounted from the device which is represented by the name of the driver, the disk number (starting from 0) and the partition number (a through p).

The 3rd partition or 'c' always represents the entire slice (In OpenBSD's case the entire disk--this is possible since OpenBSD uses an absolute offset for managing it's partitions, and can adderss the entire disk directly). Generally, slice 'c' should not be used directly for a filesystem. Visually, this looks similar to:



$ df Filesystem 512-blocks      Used     Avail Capacity  Mounted on /dev/wd0a      2061100    144604   1813444     7%    / ...

FreeBSD is different (and more obvious) it is made up of the driver name, the disk number (starting from 0), an s to indicate slice, the slice number (starting at 1) and the partition number (a through h, yes only 8 partitions):

$ df Filesystem   1K-blocks     Used   Avail Capacity  Mounted on /dev/idad0s1a    495726    61046  395022    13%    / ...

Solaris is even more different. Partitions are managed with the format command. Also, the device files representing a filesystem look a much different: e.g. /dev/dsk/c0t0d0s2 would indicate controller 0, target 0, drive 0 and slice 2. Don't get confused Solaris calls its partitions "slices" (yes different implementors different slinging of lingo). Notice that 2 represents the entire drive, just as 'c' in BSD does (3rd one from beginning).