fdisk
utility. Linux allows only 4 primary
partitions. You can have a much larger number of logical partitions by
sub-dividing one of the primary partitions. Only one of the primary
partitions can be sub-divided.
p print the partition table
n create a new partition
d delete a partition
q quit without saving changes
w write the new partition table and exit
Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders Units = cylinders of 4032 * 512 bytes Device Boot Start End Blocks Id System /dev/hdb1 * 1 184 370912+ 83 Linux /dev/hdb2 185 368 370944 83 Linux /dev/hdb3 369 552 370944 83 Linux /dev/hdb4 553 621 139104 82 Linux swapThe first line shows the geometry of your hard drive. It may not be physically accurate, but you can accept it as though it were. The hard drive in this example is made of 32 double-sided platters with one head on each side (probably not true). Each platter has 621 concentric tracks. A 3-dimensional track (the same track on all disks) is called a cylinder. Each track is divided into 63 sectors. Each sector contains 512 bytes of data. Therefore the block size in the partition table is 64 heads * 63 sectors * 512 bytes er...divided by 1024. (See Section 6 for discussion on problems with this calculation.)
fdisk /dev/hdb
Command (m for help): p Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders Units = cylinders of 4032 * 512 bytesI knew that I had a 1.2Gb drive, but now I really know: 64 * 63 * 512 * 621 = 1281982464 bytes. I decide to reserve 128Mb of that space for swap, leaving 1153982464. If I use one of my primary partitions for swap, that means I have three left for ext2 partitions. Divided equally, that makes for 384Mb per partition. Now I get to work.
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-621, default 1):Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): +384M
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (197-621, default 197):Now the partition table looks like this:Using default value 197 Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M
Device Boot Start End Blocks Id System /dev/hdb1 1 196 395104 83 Linux /dev/hdb2 197 262 133056 83 Linux
Command (m for help): a Partition number (1-4): 1And I make the second partition of type swap:
Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap) Command (m for help): pThe end result:
Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders Units = cylinders of 4032 * 512 bytes Device Boot Start End Blocks Id System /dev/hdb1 * 1 196 395104+ 83 Linux /dev/hdb2 197 262 133056 82 Linux swap /dev/hdb3 263 458 395136 83 Linux /dev/hdb4 459 621 328608 83 Linux
fdisk /dev/sda
> The number of cylinders for this disk is set to 22800. There is > nothing wrong with that, but this is larger than 1024, and could in > certain setups cause problems with: 1) software that runs at boot > time (e.g., LILO) 2) booting and partitioning software from other > OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-22800, default 1): <RETURN> Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-22800, default 22800): 3258The last partition is the extended partition:
Partition number (1-4): 4 First cylinder (9775-22800, default 9775): <RETURN> Using default value 9775 Last cylinder or +size or +sizeM or +sizeK (9775-22800, default 22800): <RETURN> Using default value 22800The result, when I issue the print table command is:
/dev/sda1 1 3258 26169853+ 83 Linux /dev/sda2 3259 6516 26169885 83 Linux /dev/sda3 6517 9774 26169885 83 Linux /dev/sda4 9775 22800 104631345 5 Extended
Command (m for help): n First cylinder (9775-22800, default 9775): <RETURN> Using default value 9775 Last cylinder or +size or +sizeM or +sizeK (9775-22800, default 22800): 13032The end result is:
Device Boot Start End Blocks Id System /dev/sda1 1 3258 26169853+ 83 Linux /dev/sda2 3259 6516 26169885 83 Linux /dev/sda3 6517 9774 26169885 83 Linux /dev/sda4 9775 22800 104631345 5 Extended /dev/sda5 9775 13032 26169853+ 83 Linux /dev/sda6 13033 16290 26169853+ 83 Linux /dev/sda7 16291 19584 26459023+ 83 Linux /dev/sda8 19585 22800 25832488+ 83 LinuxFinally, I issue the write command (w) to write the table on the disk. To make the partitions usable, I will have to format each partition and then mount it.
/dev/hda1 | /boot | (15 megs) |
/dev/hda2 | windows 98 partition | (2 gigs) |
/dev/hda3 | extended | (N/A) |
/dev/hda5 | swap space | (64 megs) |
/dev/hda6 | /tmp | (50 megs) |
/dev/hda7 | / | (150 megs) |
/dev/hda8 | /usr | (1.5 gigs) |
/dev/hda9 | /home | (rest of drive) |
© 2000 Karsten M. Self (kmself@ix.netcom.com)
Last updated 2000/12/04 19:30:54
Filesystem 1k-blocks Used Available Use% Mounted on /dev/root 152247 51652 92733 36% / /dev/sdb5 101089 3737 92133 4% /tmp /dev/sdb6 303344 233213 54470 82% /var /dev/hda5 495960 118804 351556 26% /var/spool/news /dev/sda5 1209572 1038000 110128 91% /usr /dev/sdb7 1517920 1240280 200532 87% /usr/local /dev/hda8 253775 156210 84463 65% /usr/doc /dev/hda6 249871 135434 101537 58% /usr/src /dev/sda7 585008 352004 203288 64% /home /dev/hda2 1007992 699120 257668 74% /mnt/misc1 /dev/hdc 47808 47808 0 100% /mnt/cdrom
Disk /dev/hda: 128 heads, 63 sectors, 620 cylinders Units = cylinders of 8064 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 39 157216+ 6 FAT16 /dev/hda2 40 293 1024128 83 Linux /dev/hda3 294 332 157248 83 Linux /dev/hda4 333 620 1161216 5 Extended /dev/hda5 333 459 512032+ 83 Linux /dev/hda6 460 523 258016+ 83 Linux /dev/hda7 524 555 128992+ 83 Linux /dev/hda8 556 620 262048+ 83 Linux Disk /dev/sda: 255 heads, 63 sectors, 261 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/sda1 1 17 136521 82 Linux swap /dev/sda2 18 261 1959930 5 Extended /dev/sda5 18 170 1228941 83 Linux /dev/sda6 171 187 136521 82 Linux swap /dev/sda7 188 261 594373+ 83 Linux Disk /dev/sdb: 255 heads, 63 sectors, 261 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 17 136521 82 Linux swap /dev/sdb2 18 261 1959930 5 Extended /dev/sdb5 18 30 104391 83 Linux /dev/sdb6 31 69 313236 83 Linux /dev/sdb7 70 261 1542208+ 83 Linux