How are partitions numbered?

This is a discussion on How are partitions numbered? within the Linux General forums, part of the Linux Forums category; Are partitions numbered strictly sequentially under Linux or in the order in which they were created? Does it depend on ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-28-2003
Charles Sullivan
 
Posts: n/a
Default How are partitions numbered?

Are partitions numbered strictly sequentially under Linux or in the order
in which they were created? Does it depend on which tool was used to
create them, e.g., fdisk, FDISK.EXE, Partition Magic?

For example, if I initially partition a drive as:
Partition 1
*Free space*
Partition 2

but later go back and partition the Free space, would I get:
Partition 1
Partition 2
Partition 3

or
Partition 1
Partition 3
Partition 2

Would the same answer(s) be true for logical partitions in
an extended partition?

Thanks for your help.
Reply With Quote
  #2 (permalink)  
Old 06-28-2003
John-Paul Stewart
 
Posts: n/a
Default Re: How are partitions numbered?

Charles Sullivan wrote:
>
> Are partitions numbered strictly sequentially under Linux or in the order
> in which they were created?


Generally, in the order in which they were created unless your
partitioning tool asks you which number partition you're creating.
Linux fdisk will ask you for a partition number when you create primary
partitions but not for logical drives in the extended partition (which
are always sequential). DOS fdisk is always sequential, IIRC.

> Does it depend on which tool was used to
> create them, e.g., fdisk, FDISK.EXE, Partition Magic?
>
> For example, if I initially partition a drive as:
> Partition 1
> *Free space*
> Partition 2
>
> but later go back and partition the Free space, would I get:
> Partition 1
> Partition 2
> Partition 3
>
> or
> Partition 1
> Partition 3
> Partition 2


The second layout: 1-3-2. Note that in those circumstances, fdisk will
issue a warning about "partitions not in disk order" or some such. It's
just an informational message, though.

> Would the same answer(s) be true for logical partitions in
> an extended partition?


Yes, in general. See my note above.
Reply With Quote
  #3 (permalink)  
Old 06-29-2003
Vilmos Soti
 
Posts: n/a
Default Re: How are partitions numbered?

Charles Sullivan <cwsulliv@triad.rr.com> writes:

> Are partitions numbered strictly sequentially under Linux or in the order
> in which they were created? Does it depend on which tool was used to
> create them, e.g., fdisk, FDISK.EXE, Partition Magic?


Under Linux, the IDE disks are called hd[a-z], and the scsi disks
are called sd[a-z]. So, /dev/hdb refers to the slave disk on the
first IDE channel, /dev/hdc refers to the master disk on the
second IDE channel, etc. It is entirely possible that you have
/dev/hda and /dev/hdd but not /dev/hdb and /dev/hdc. It means that
you have a primary master and a secondary slave drive.

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

So you now know how the disks are named. In the PC world,
the first sector of the disk is called the Master Boot Record,
MBR in short. Inside this MBR is the boot loader (which is
relevant if you boot from the disk), and the partition table.
The partition table is 64 bytes long, and one entry inside
the partition table is 16 bytes long. Therefore, you can have
four primary partitions (16*4=64) on a single disk. One for
each entry.

Suppose we are talking about the primary slave IDE disk, which
is /dev/hdb. BTW /dev/hdb refers to the whole disk. So the
first entry in the partition table is /dev/hdb1, the second
is /dev/hdb2, the third is /dev/hdb3, and the fourth is /dev/hdb4.

It is entirely possible that there is no entry in the partition
table for /dev/hdb2, the second slot, and in this case you would
have /dev/hdb1, /dev/hdb3, and /dev/hdb4. One valid entry in the
partition table is the so called extended partition type. In
that case, the area referred by that entry can have sub partitions
which are called logical partitions. They start with the number
5 (remember, 1-4 are for primary partitions), and they are
numbered sequentially. The first logical partition will be
/dev/hdb5, the second will be /dev/hdb6, etc.

From this, it should be clear that the partition numbering
scheme depends on the partitioning software but only in the
way in which order the software fills the partition table.
If it fills the first slot first, then you have /dev/hdb1,
then /dev/hdb2, etc. If it fills backwards, then you have
/dev/hdb4 first, then /dev/hdb3, etc. It is also possible
to have a hole in the partition table, so you might have
/dev/hdb1 and /dev/hdb3.

Also, if you have only a single primary partition on a disk,
and this is an extended partition, and inside that extended
partition you have a single logical partition, then you
will have /dev/hdb1 and /dev/hdb5 on the disk.

> For example, if I initially partition a drive as:
> Partition 1
> *Free space*
> Partition 2
>
> but later go back and partition the Free space, would I get:
> Partition 1
> Partition 2
> Partition 3
>
> or
> Partition 1
> Partition 3
> Partition 2


It entirely depends on the order the entries in the partition
table point to the disk areas.

> Would the same answer(s) be true for logical partitions in
> an extended partition?


AFAIK, if you erase a logical partition, then the ones above
it will cascade down, but I am not sure since I didn't play
with many logical partitions for years.

Vilmos
Reply With Quote
  #4 (permalink)  
Old 06-29-2003
bd
 
Posts: n/a
Default Re: How are partitions numbered?

On Sat, 28 Jun 2003 18:25:29 -0700, Vilmos Soti wrote:

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


devfs can help alleviate this - my ide-scsi cdrom is, for example:
lr-xr-xr-x 1 root root 31 Jun 27 16:54 /dev/sr0 ->
scsi/host0/bus0/target0/lun0/cd

As long as you use the overly verbose devfs filenames (or a symlink
thereof), they should remain unchanged (I think).

--
Freenet distribution not available
If the rich could pay the poor to die for them, what a living the poor
could make!

Reply With Quote
  #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
  #6 (permalink)  
Old 06-29-2003
Charles Sullivan
 
Posts: n/a
Default Re: How are partitions numbered?

On Sat, 28 Jun 2003 21:25:29 -0400, Vilmos Soti wrote:

> Charles Sullivan <cwsulliv@triad.rr.com> writes:
>
>> Are partitions numbered strictly sequentially under Linux or in the
>> order in which they were created? Does it depend on which tool was
>> used to create them, e.g., fdisk, FDISK.EXE, Partition Magic?

>

<snip>
> From this, it should be clear that the partition numbering scheme
> depends on the partitioning software but only in the way in which order
> the software fills the partition table. If it fills the first slot
> first, then you have /dev/hdb1, then /dev/hdb2, etc. If it fills
> backwards, then you have /dev/hdb4 first, then /dev/hdb3, etc. It is
> also possible to have a hole in the partition table, so you might have
> /dev/hdb1 and /dev/hdb3.

<snip>

OK, I think I got it: The partitions are numbered by Linux according to
their order in the partition table, but the order of the actual
partitioned spaces on a drive may or may not be the same, depending
on the software used to create the partitions. Thanks Vilmos.

Regards,
Charles Sullivan
Reply With Quote
  #7 (permalink)  
Old 06-29-2003
Charles Sullivan
 
Posts: n/a
Default Re: How are partitions numbered?

On Sat, 28 Jun 2003 22:25:04 -0400, Robert Heller wrote:
<snip>
> I don't believe the IDE interfaces allow you to have slaves without
> masters -- you can have masters without slaves.

<snip>

I think this may depend on the particular hardware and bios. I have
my two HDDs as Master/Slave on a Promise UDMA 66 add-on card.
If I unplug the master, the bios will (after a timeout) boot from
the slave.

I notice that some HDDs have one jumper position for both Single
drive or Master in a Master/Slave configuration, whereas others
have separate jumper positions for these two cases. This may
make a difference.

Because of flaky behavior of my particular (Phoenix) bios
when all 4 onboard IDE slots are filled, I moved an ATAPI ZIP drive
to the secondary channel of the Promise card. I neglected to change
the ZIP drive jumper from slave to master when I did this but the
drive worked fine as slave even though there was no master on that
channel.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:37 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0