This is a brief guide on partitioning intended as a brief introduction to partitioning terminology and some tips.
UPDATE 11/30/06 Thank you ImmigrantUS for your critical review.
UPDATE 1/02/07 Thank you Bulldog for your review and suggestions.
UPDATE 9/08/08 Please note: as of Ubuntu 7.10 all drives are labeled sdxy (the terminology hdxy is depreciated).
UPDATE 6/04/2012 - Added information fro ext4.
Primary, Extended, and Logical partitions.
Primary partitions: The original partitioning scheme for PC hard disks allowed only four partitions, thus you are allowed up to 4 primary partitions. Linux numbers primary partitions 1-4.
Note: Some OSs (Windows, BSD) can ONLY be installed into a PRIMARY partition.Extended and Logical partitions: To overcome this limitation, extended partitions are used. A single primary partition may "converted" into an "extended" partition which is then further divided into sub-partitions called logical partitions. Sorry you may not convert more then 1 primary partition into an extended partition. You then create logical partitions within the extended partition. It may be possible to create further extended partitions within an extended partition, although this becomes complicated and I am not sure of any advantage this offers.
Linux (and swap) can be installed into a primary or logical partition.
Linux numbers Logical partitions starting with 5: The numbers 1,2,3 and 4 are reserved for the primaries, even if you have just one primary partition. So if you make one primary partition and one extended extended partition with one logical partition:
The primary would be sda1
The entire extended partition (and any logical partition(s) it contains) would be sda2.
The logical partition within the extended partition would be sda5.
Clear as mud ?
Naming of partitions.
Windows: Windows uses lettering (c:\ ; e:\ , etc).
Linux: Linux uses /dev/hdxy or /dev/sdxy (most distros now use "/dev/sdxy", see below).
x will be a letter starting with a, then b,c,....
y will be a number starting with 1, then 2,3,....
Thus sda1 = First partition on the master HD.
Grub numbers drives starting with 0.
Grub also names partitions starting with 0.
Thus grub (sd0,0) = Linux sda1.
Examples of partition names.
Note: Names without a trailing digit refer to the whole disk, while names with a trailing digit refer to a partition of that whole disk.
Using sda as an example with multiple partitions:
/dev/sda = Entire HD
3 primary partitions:
/dev/sda1 = First partition = GRUB (hd0,0)
/dev/sda2 = Second partition = GRUB (hd0,1)
/dev/sda3 = Third partition = GRUB (hd0,2)3 logical partitions (Note you can have more then 3 logical partitions within an extended partition:
Note: /dev/sda4 = Entire Extended partition. sda4 is "theoretical" in that it can not be mounted as such, but it "takes up a number".
This is true for both Linux and grub speak !-----
/dev/sda5 = fourth partition = GRUB (hd0,4)
/dev/sda6 = fifth partition = GRUB (hd0,5)
/dev/sda7 = sixth partition = GRUB (hd0,6)HD vs SD.
As of Ubuntu 7.10 all drives are sd. This information is thus depreciated, and is available as a reference for those people using a version of Ubuntu previous to 7.10
IDE/ATA cable = hdxy
- Hard Drives
/dev/hda = Entire first HD, master drive on primary IDE cable.
/dev/hda1 = First partition on master drive.
/dev/hdb = Entire second HD, slave drive on primary IDE cable.
/dev/hdc = Master CD on secondary IDE cable
/dev/hdd = Slave CD on secondary IDE cable
SCSI devices = sdxy
- SATA HD
- SCSI HD
- Zip drives
Note: Although they contain only 1 partition, zip drives are numbered "4".
- USB devices- both flash drives and hard drives.
- Firewire devices.
/dev/fd0 = First FD.Basic partitioning scheme.
Ubuntu (Linux) "requires" 2 partitions: / and swap. Both / and swap may be either Primary or Logical partitions.
/ = root min size 5 GB (Yes, I know you can go smaller if needed), 15-20 Gb may be better if you have the HD space.
- RAM < 1 Gb swap = RAM X2.
- RAM > 1 Gb swap = 2 Gb
Some claim a swap size of > 1 Gb is excessive. The 2 Gb recommendation is "conservative".
(If you boot more then 1 distro you should share the swap partition)
/home: This is helpful if you need to re-install Ubuntu. /home stores user data and user configuration files.
- /home does not save all of the installed applications you have installed or removed beyond the base install.
- If you boot multiple distros those user config files can conflict.
/data: This is helpful and I use this in favor of /home.
- First, I boot multiple distros and user configuration files in /home can conflict as above.
- Those user config files are not "mission critical" to back up. They will be regenerated if deleted, although you will loose your application preferences.
- Backup /home to /data and you can restore /home.
- Data partition can be shared with other OS (Windows or other distro's) easier then /home.
You can, of course, mount your data partition as any name (mount point) you like.
Bulldog's Partitioning advice
Some suggestions for disk partition
Windows as big as you like.
Create an ext4 10GB for /
Create an extended from the rest off the space.
In the extended,
Create a /home 10GB
Create a swap 1GB
Create a ext4 partition
for data if you have space left.
You have a separate
/home for some data and a separate /data partition
to backup important data.
I think a 10GB / partition
is necessary to install programs without running out of space to soon.
Yes it can be 5GB or even less,but I think you shouldn't promote that one.
You can give each system directory a separate mount point. This includes:
This is not needed on a desktop install but is more common in server installs.
Adding /boot, /home, /var, and /tmp partitions can increase security.
For further reading, see References section below.
Partitioning and formatting can be done from the CLI:
This works well with new discs/devices and, IMO, is faster then GParted.
You can delete, create, and format partitions easily.
The CLI will not resize or move a partition, use Gparted.
The CLI will not format a partition with ntfs (windows XP).
How to Gparted, graphical guide
Partitioning with fdisk: It is easy and fast. IMO fdisk is more reliable then GParted, although Gparted is improving. The main problem I have had GParted is that it likes to re-number existing partitions which can then be fixed with fdisk.
Unmount the HD or USB device you want to partition or boot from a Live CD.
Then start fdisk:
Basic fdisk syntax:
sudo fdisk /dev/sda
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
Partitioning with fdisk
New HOWTO: Linux Partition HOWTO
Linux Partition HOWTO
Format with the command line: Syntax mkfs.<fs> <option_label> label_name <device>
See also man mkfs.* (man mkfs.ext3)Note: If you are installing Linux you can format the target (install) partition during the install process. In this case you do not need do do more then partition your HD.
mkfs.ext2 -L <label_name> <device>
mkfs.ext3 -L <label_name> <device>
mkfs.ext4 -L <label_name> <device>
mkfs.reiserfs -l <label_name> <device>
mkfs.reiser4 -l <Device>
mkfs.jfs -L <label_name> <device>
mkfs.xfs -L <label_name> <device>
Note: If you use xfs for your root partition you will need a separate /boot partition.FAT:
/boot may be formated as ext2 (saves space)
sudo mkfs.vfat -n <label_name> <device>
Will format sda1 to ext3 and add a label "data".
mkfs.ext3 -L data /dev/sda1
Will format sda1 to ext4 and add a label "data".
mkfs.ext4 -L data /dev/sda1
Will format sda1 to FAT32 and add a label "data".
mkfs.vfat -n data /dev/sda1
See this as a primer to more advanced partitioning: Linux Partitioning Guide.
For a more detailed, "short" review see also: A Short Guide to Partitioning a Hard Drive for a Linux System
For a shorter, yet through discussion see: Ubuntu Partitioning Thanks aysiu
GParted: How to Gparted, graphical guide
Partitioning with fdisk
New HOWTO: Linux Partition HOWTO