| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Informational:Hard drives, partitions and Linux

Page history last edited by Richard Bailey 15 years, 11 months ago

Informational:Hard drives, partitions and Linux

 


 

IDE drives, device naming and SCSI drives

 

 

Traditionally, hard drives in a typical PC were IDE based. These would usually be in two channels, Primary and Secondary, with each channel capable of having two drives, Master and Slave. This gives a total of 4 drives that can exist. These devices show up as /dev/hda, /dev/hdb, /dev/hdc and /dev/hdd in Linux with Primary Master first, then Primary Slave, then Secondary Master then Secondary Slave. It's worth noting that if you only have one drive on the Primary and two on the Secondary then your devices would be hda, hdc and hdd; any missing devices are left out.

 

 

SCSI drives are a little trickier with respect to device naming. Firstly, SCSI devices are named /dev/sda, /dev/sdb, /dev/sdc and so on. However, SCSI has no concept or Master or Slave. SCSI does have the concept of enumeration however, and a device with a lower number (i.e. device 1 instead of device 7) would get the first SCSI device name and so on. This typically means that there are usually no gaps in SCSI device names as there can be in IDE device names.

 

 

Serial ATA drives and USB drives show up as SCSI devices under Linux and undergo the same naming scheme. Also, a CD-ROM or DVD-ROM device is still a drive and still gets a name like all the others.

 

Partitions, limitations and extended partitions

 

 

In a typical PC the de facto partition table format is the MS DOS partition table, even on Linux. There are other partition table formats out there, but they are not common on PCs. The MS DOS partition table is limited however to only four entries. That is right, there can be only four partitions in a partition table.

 

 

A partition table entry will list the starting block, the ending block or the length (I can't remember which one) and the partition type. These three entries are all that is required for the drive to keep track of its partitions. These partitions are called Primary Partitions.

 

 

Partitions are accessed under Linux by simply tacking on a number from 1 to 4 to the end of the device name, for example /dev/hda1, /dev/sdb2, etc. Therefore, when you want to repartition a disk you run fdisk against the drive, not the partition, i.e. you run 'fdisk /dev/sda' not 'fdisk /dev/sda1'.

 

 

You may be wondering how you can add seemingly unlimited partitions to a drive if there is a 4 partition limitation. One of the Primary Partitions is allowed to be an Extended Partition. This can be any one, not only the last one. An Extended Partition can then contain any number of Logical Drives.

 

Logical Drives

 

 

In an Extended Partition there can be any number of Logical Drives. In Linux these drives start numbering from 5 upward. It does not matter if there are less than 4 partitions on the drive, logical drives always start at 5, i.e. /dev/sda5, /dev/sda6, etc. The information about the logical drives is not stored in the partition table but rather in the extended partition, this means that there is no limitation on the number of logical drives that can exist.

 

 

Remember that a drive must have an extended partition before you can create logical drives.

 

Partition Types

 

 

The partition type tells the operating system what is the type of information in the partition. It is a two character code and has a specific meaning. For example 0b or 0c is a FAT32 partition (the traditional DOS/Windows filesystem),  83 is a Linux partition which can be formatted into many filesystems that Linux supports and 83 is a Linux swap partition. Each partition and logical drive will have a partition type. Windows typically ignores all partitions/logical drives that are not a partition type it recognises.

 

Other partition table formats

 

 

There are other partition table formats in existence. The most common in PCs is the MS DOS format but PCs can use other formats. Due to the rigid structure of the partition table a MS DOS table cannot represent partitions on very large disks (a few terabytes), the numbers that are stored in the table can't go up that high. One other format that is catching on is GPT (GUID Partition Table) which is a modern format that has worked around these limitations. I believe that Intel Macs use this format exclusively. Linux and later versions of Windows can also use this format.

 

Comments (0)

You don't have permission to comment on this page.