Knowledge Base Glossary       Exit
(how to) Search  

Browse by Category
Knowledge Base > Operating Systems > Linux > Overview of working with partitions in Linux

Overview of working with partitions in Linux

How drives and partitions are designated in Linux

* All ATA (IDE) type drive/partition designations start with the letters 'hd'

* To that, add the letter representing the entire drive (a, b, c, d, ....)
a = primary/master drive
b = primary/slave drive
c = secondary/master drive
d = secondary/slave drive

* To that, add the number representing the individual partition (1, 2, 3, 4, 5, ...)
1 through 4 are for primary partitions, based on their partition table position
5 and up are for volumes in the extended partition (always start at 5)

* Examples:
The entire primary/master drive is designated as simply hda
The first primary partition on the primary/master drive is hda1
The first volume in the extended partition on the primary/master drive is hda5
The third volume in the extended partition on the secondary/slave drive is hdd7

* Additional Notes:
You will normally see all drive and partition designations prefixed with /dev. So the entire primary/master drive will be /dev/hda, it's first partition will be /dev/hda1, and so on.

Primary partition numbers are always based strictly on partition table position. If only the first partition table position (or slot) is occupied, it will be numbered as 1 (as in hda1). But if that partition is in the 2nd position with the first position empty, it will be numbered as 2 (as in hda2). There will be no hda1 in this case.

Volumes in the extended partition will always start at 5, regardless of how many primary
partitions exist on the drive.

SCSI disks and partitions follow the same scheme, except that the drive designations start with 'sd' instead of 'hd'. For example, /dev/sda1

How to see a list of your partitions

fdisk -l will list all partitions on all drives (l is lower case L)
fdisk -l > filename will save the output to a text file
fdisk -l | more will make the output viewable one screen at a time
fdisk -l /dev/hda will list all partitions on just /dev/hda (primary/master)

 Note: The fdisk command has to be run as root

How to see which partitions are mounted (accessible)

df is the basic command to list mounted partitions
df -Th will also display file system type, and the size in human readable format
mount will show similar information, but no sizes

 How to determine what your root partition is

When observing the output of the 'df' command shown above, the partition mounted on / is the root partition.

How to mount a partition

mount /dev/hdxx /mountpoint

Mountpoint above is the path to where you want to mount the partition. As an example, if you wanted to mount the partition /dev/hda4 in the directory /home/firstuser/driveD, you would use this command:

mount /dev/hda4 /home/firstuser/driveD

Sometimes, depending on kernel/module configuration, the file system of the partition also has to be specified. For example, to mount a FAT32 partition at /home/firstuser/driveD, you would use this command:

mount -t vfat /dev/hda4 /home/firstuser/driveD

How to have partitions mounted automatically when you boot

The file /etc/fstab contains a list of partitions to be mounted at boot. A line needs to be added for each additional partition that you want to mount automatically. As an example, the following shows a line that could be added to automatically mount a FAT32 partition located on /dev/hda4 in the directory /home/firstuser/driveD:

<file system> <mount point>

Note that there are many options that can be specified under <options>, and these can also be used on the mount command line. Refer to the man pages for mount and fstab for more information. Also note that modern Linux desktop environments, such as Gnome and KDE, have made many administrative tasks such as these easier by providing GUI configuration programs for them.

How helpful was this article to you?

powered by Lore