View Single Post

  #5 (permalink)  
Old 06-29-2003
Robert Heller
 
Posts: n/a
Default Re: How are partitions numbered?

Vilmos Soti <vilmos@vilmos.org>,
In a message on 28 Jun 2003 18:25:29 -0700, wrote :

VS> Charles Sullivan <cwsulliv@triad.rr.com> writes:
VS>
VS> > Are partitions numbered strictly sequentially under Linux or in the order
VS> > in which they were created? Does it depend on which tool was used to
VS> > create them, e.g., fdisk, FDISK.EXE, Partition Magic?
VS>
VS> Under Linux, the IDE disks are called hd[a-z], and the scsi disks
VS> are called sd[a-z]. So, /dev/hdb refers to the slave disk on the
VS> first IDE channel, /dev/hdc refers to the master disk on the
VS> second IDE channel, etc. It is entirely possible that you have
VS> /dev/hda and /dev/hdd but not /dev/hdb and /dev/hdc. It means that
VS> you have a primary master and a secondary slave drive.

I don't believe the IDE interfaces allow you to have slaves without
masters -- you can have masters without slaves.

VS>
VS> The scsi disks are named in a bit different matter. Say, you
VS> have three scsi cards, and on the first one you have one, on
VS> the second you have two, and on the third, you have one disk.
VS> So /dev/sda will be the sole disk on the first scsi card,
VS> /dev/sdb will be the scsi card with the lower scsi id on the
VS> second card, /dev/sdc will be the second (with a higher scsi
VS> id) disk on the second card, and /dev/sdd will be the sole
VS> drive on the third scsi card. The problem here is that if
VS> you remove a disk which is not the very last, then all the
VS> disks beyond that will cascade down and what used to be /dev/sdc
VS> can become /dev/sdb, etc.

This is what Ext2 and Ext3 file system labels are for... :-)

VS>
VS> So you now know how the disks are named. In the PC world,
VS> the first sector of the disk is called the Master Boot Record,
VS> MBR in short. Inside this MBR is the boot loader (which is
VS> relevant if you boot from the disk), and the partition table.
VS> The partition table is 64 bytes long, and one entry inside
VS> the partition table is 16 bytes long. Therefore, you can have
VS> four primary partitions (16*4=64) on a single disk. One for
VS> each entry.
VS>
VS> Suppose we are talking about the primary slave IDE disk, which
VS> is /dev/hdb. BTW /dev/hdb refers to the whole disk. So the
VS> first entry in the partition table is /dev/hdb1, the second
VS> is /dev/hdb2, the third is /dev/hdb3, and the fourth is /dev/hdb4.
VS>
VS> It is entirely possible that there is no entry in the partition
VS> table for /dev/hdb2, the second slot, and in this case you would
VS> have /dev/hdb1, /dev/hdb3, and /dev/hdb4. One valid entry in the
VS> partition table is the so called extended partition type. In
VS> that case, the area referred by that entry can have sub partitions
VS> which are called logical partitions. They start with the number
VS> 5 (remember, 1-4 are for primary partitions), and they are
VS> numbered sequentially. The first logical partition will be
VS> /dev/hdb5, the second will be /dev/hdb6, etc.
VS>
VS> From this, it should be clear that the partition numbering
VS> scheme depends on the partitioning software but only in the
VS> way in which order the software fills the partition table.
VS> If it fills the first slot first, then you have /dev/hdb1,
VS> then /dev/hdb2, etc. If it fills backwards, then you have
VS> /dev/hdb4 first, then /dev/hdb3, etc. It is also possible
VS> to have a hole in the partition table, so you might have
VS> /dev/hdb1 and /dev/hdb3.
VS>
VS> Also, if you have only a single primary partition on a disk,
VS> and this is an extended partition, and inside that extended
VS> partition you have a single logical partition, then you
VS> will have /dev/hdb1 and /dev/hdb5 on the disk.
VS>
VS> > For example, if I initially partition a drive as:
VS> > Partition 1
VS> > *Free space*
VS> > Partition 2
VS> >
VS> > but later go back and partition the Free space, would I get:
VS> > Partition 1
VS> > Partition 2
VS> > Partition 3
VS> >
VS> > or
VS> > Partition 1
VS> > Partition 3
VS> > Partition 2
VS>
VS> It entirely depends on the order the entries in the partition
VS> table point to the disk areas.
VS>
VS> > Would the same answer(s) be true for logical partitions in
VS> > an extended partition?
VS>
VS> AFAIK, if you erase a logical partition, then the ones above
VS> it will cascade down, but I am not sure since I didn't play
VS> with many logical partitions for years.
VS>
VS> Vilmos
VS>







Reply With Quote