How does Linux determine drive numbers?

How does Linux determine drive numbers?

Post by James D Parker J » Mon, 22 Jul 2002 11:23:54



How does Linux determine what the numbers (E.g., /dev/hda1, /dev/hda2,
etc) are for hard drive partitions?

Is there a way to allocate partitions in a multiple OS situation (some
Windows partitions, some Linux partitions and some OS/2 partitions) so
that they have the numeric assignments I want for Linux but also will
have the drive letter assignments I want for the other OS's?

I'm using Partition Magic 4.0.

Thanks
Jim

 
 
 

How does Linux determine drive numbers?

Post by Michael Heimin » Mon, 22 Jul 2002 15:54:05



Quote:> How does Linux determine what the numbers (E.g., /dev/hda1,
> /dev/hda2, etc) are for hard drive partitions?

> Is there a way to allocate partitions in a multiple OS situation
> (some Windows partitions, some Linux partitions and some OS/2
> partitions) so that they have the numeric assignments I want for
> Linux but also will have the drive letter assignments I want for
> the other OS's?

/dev/hda1 means, first partition on the first IDE disc.
Ie. /dev/sdb3 means, third partition on the second SCSI disc.
While booting the system mounts the fs, by looking at /etc/fstab,
Ie.:

/dev/hda3   /opt/SuSE   ext3        defaults,usrquota       0 0

Would mount the third partition on the first IDE hd to /opt/SuSE as
ext3 fs with userquotas.

There is no such thing like silly drive letters, however you could
mount it to something like /dose/c or /OS_2/1, like you want.
hint:
$ man -k mount

Hope this helps

Michael Heiming
--
Remove the +SIGNS case mail bounces.

 
 
 

How does Linux determine drive numbers?

Post by faeychil » Mon, 22 Jul 2002 16:20:39


Os/2 and windows (especially windows) are not
going to see linux partitions and windows is not going
to see os/2.
If you were hoping to match numerical order with alpha
order, I think you are sunk.

One advantage with linux is the ability to name your mount point,
so you can call it "C" "D" "E" under linux.



Quote:> How does Linux determine what the numbers (E.g., /dev/hda1, /dev/hda2,
> etc) are for hard drive partitions?

> Is there a way to allocate partitions in a multiple OS situation (some
> Windows partitions, some Linux partitions and some OS/2 partitions) so
> that they have the numeric assignments I want for Linux but also will
> have the drive letter assignments I want for the other OS's?

> I'm using Partition Magic 4.0.

> Thanks
> Jim

 
 
 

How does Linux determine drive numbers?

Post by James D Parker J » Mon, 22 Jul 2002 22:57:33




> > How does Linux determine what the numbers (E.g., /dev/hda1,
> > /dev/hda2, etc) are for hard drive partitions?

> > Is there a way to allocate partitions in a multiple OS situation
> > (some Windows partitions, some Linux partitions and some OS/2
> > partitions) so that they have the numeric assignments I want for
> > Linux but also will have the drive letter assignments I want for
> > the other OS's?

> /dev/hda1 means, first partition on the first IDE disc.
> Ie. /dev/sdb3 means, third partition on the second SCSI disc.
> While booting the system mounts the fs, by looking at /etc/fstab,
> Ie.:

> /dev/hda3   /opt/SuSE   ext3        defaults,usrquota       0 0

> Would mount the third partition on the first IDE hd to /opt/SuSE as
> ext3 fs with userquotas.

> There is no such thing like silly drive letters, however you could
> mount it to something like /dose/c or /OS_2/1, like you want.
> hint:
> $ man -k mount

> Hope this helps

> Michael Heiming
> --
> Remove the +SIGNS case mail bounces.

I know that /dev/hda1 means "first" partition. The question is in what
sense do you mean first? Let me give you an example. I have a hard drive
(hdb) with the following layout:

Linux Ext2, primary, /dev/hdb2
HPFS, logical, /dev.hdb5
FAT16, logical, /dev/hdb6
FAT32, logical, /dev/hdb7
Linux Ext2, logical (four of them), /dev/hdb8-11
Linux Swap, logical, /dev/hdb12

The extended partition itself is hdb1.

When viewed through Partition Magic, /dev/hdb2 appears to be the first
partition. It does occupy space at the beginning of the drive. So why
isn't it /dev/hdb1 and the extended partition /dev/hdb2?

After thinking about it, it appears to me that Windows, OS and OS/2
assign drive letters based on their physical location on the drive while
Linux assigns numbers based on the location of the partition's entry in
the partition table with primary partitions getting numbers 1 through 4
and logical partitions getting numbers 5 and up. The order in the
partition table is based on when the partition was created.  (Does this
depend on what partitioning tool you use? It appears to be true of
Partition Magic.). For example, if I were to delete and recreate the
HPFS partition, it would become /dev/hdb12 and partitions /dev/hdb6-12
would move down one to /dev/hdb5-11 even though it was recreated in the
same location. For another example, if there were free space between the
HPFS partition and the FAT16 partition and I created a partition in that
space, it would become /dev/hdb13 rather than /dev/hdb6.

The partitioning tools that I use (Partition Magic and Drive
Image) allow you to control the physical location of partitions and thus
you can control drive letter assignment by Windows, DOS and OS/2.
However, there does not appear to be any way to directly control the
numbers that would be assigned by Linux. Well, at least not with
PowerQuest tools. Are there alternatives that can handle this kind of
thing?

Thanks
Jim

 
 
 

How does Linux determine drive numbers?

Post by Peter T. Breue » Mon, 22 Jul 2002 23:23:53





>> /dev/hda1 means, first partition on the first IDE disc.
>> Ie. /dev/sdb3 means, third partition on the second SCSI disc.
>> While booting the system mounts the fs, by looking at /etc/fstab,
>> Ie.:
> I know that /dev/hda1 means "first" partition. The question is in what
> sense do you mean first? Let me give you an example. I have a hard drive

In the sense of FIRST. There is no other sense. The partitions are
listed in a table on the front of the disk. The first in that list is
/dev/hda1.

Quote:> (hdb) with the following layout:

This is NOT a layout! It is some gui's "user friendly" schematic. Toss
it in the bin.

Quote:> Linux Ext2, primary, /dev/hdb2
> HPFS, logical, /dev.hdb5
> FAT16, logical, /dev/hdb6
> FAT32, logical, /dev/hdb7
> Linux Ext2, logical (four of them), /dev/hdb8-11
> Linux Swap, logical, /dev/hdb12
> The extended partition itself is hdb1.

Fine.

Quote:> When viewed through Partition Magic, /dev/hdb2 appears to be the first

Don't view it through partition magic! What's your problem
distinguishing reality from perception?

Quote:> After thinking about it, it appears to me that Windows, OS and OS/2
> assign drive letters based on their physical location on the drive while

You would be completely wrong. The rules to letter assignment are more
complex. I believe primaries on the second disk count before logical
on the first, for example, and non-ms partitions are ignored entirely.
Don't quote me on that - I don't use windows.

Quote:> Linux assigns numbers based on the location of the partition's entry in
> the partition table with primary partitions getting numbers 1 through 4

That is completely right.

Quote:> and logical partitions getting numbers 5 and up. The order in the

There's nothing to "appear". That IS the one and only unique numbering
possible.

Quote:> partition table is based on when the partition was created.  (Does this

No. The order in the partition table is the order you feel like having.
You can put any entry anywhere. That's your decision.

Quote:> depend on what partitioning tool you use? It appears to be true of

Yes, it depends on what partitioning tool you use and what you tell
that tool to do. What else could it depend on?

Quote:> Partition Magic.). For example, if I were to delete and recreate the
> HPFS partition, it would become /dev/hdb12 and partitions /dev/hdb6-12

It would become whatever you wanted it to be, if you used the right
tool.

Note that logical parititions do not appear in the 4-partition table in
the mbr. They are chained within the logical partition.

And you can add bsd slices to that.

Peter

 
 
 

How does Linux determine drive numbers?

Post by James D Parker J » Tue, 23 Jul 2002 01:00:10






> >> /dev/hda1 means, first partition on the first IDE disc.
> >> Ie. /dev/sdb3 means, third partition on the second SCSI disc.
> >> While booting the system mounts the fs, by looking at /etc/fstab,
> >> Ie.:

> > I know that /dev/hda1 means "first" partition. The question is in what
> > sense do you mean first? Let me give you an example. I have a hard drive

> In the sense of FIRST. There is no other sense. The partitions are
> listed in a table on the front of the disk. The first in that list is
> /dev/hda1.

> > (hdb) with the following layout:

> This is NOT a layout! It is some gui's "user friendly" schematic. Toss
> it in the bin.

> > Linux Ext2, primary, /dev/hdb2
> > HPFS, logical, /dev.hdb5
> > FAT16, logical, /dev/hdb6
> > FAT32, logical, /dev/hdb7
> > Linux Ext2, logical (four of them), /dev/hdb8-11
> > Linux Swap, logical, /dev/hdb12

> > The extended partition itself is hdb1.

> Fine.

> > When viewed through Partition Magic, /dev/hdb2 appears to be the first

> Don't view it through partition magic! What's your problem
> distinguishing reality from perception?

> > After thinking about it, it appears to me that Windows, OS and OS/2
> > assign drive letters based on their physical location on the drive while

> You would be completely wrong. The rules to letter assignment are more
> complex. I believe primaries on the second disk count before logical
> on the first, for example, and non-ms partitions are ignored entirely.
> Don't quote me on that - I don't use windows.

> > Linux assigns numbers based on the location of the partition's entry in
> > the partition table with primary partitions getting numbers 1 through 4

> That is completely right.

> > and logical partitions getting numbers 5 and up. The order in the

> There's nothing to "appear". That IS the one and only unique numbering
> possible.

> > partition table is based on when the partition was created.  (Does this

> No. The order in the partition table is the order you feel like having.
> You can put any entry anywhere. That's your decision.

> > depend on what partitioning tool you use? It appears to be true of

> Yes, it depends on what partitioning tool you use and what you tell
> that tool to do. What else could it depend on?

> > Partition Magic.). For example, if I were to delete and recreate the
> > HPFS partition, it would become /dev/hdb12 and partitions /dev/hdb6-12

> It would become whatever you wanted it to be, if you used the right
> tool.

> Note that logical parititions do not appear in the 4-partition table in
> the mbr. They are chained within the logical partition.

> And you can add bsd slices to that.

> Peter

So, what is the right tool? (It needs to be able to manage FAT16, FAT32, HPFS
as well as Linux partitions.)

Thanks
Jim

 
 
 

How does Linux determine drive numbers?

Post by Peter T. Breue » Tue, 23 Jul 2002 01:49:13



Quote:> So, what is the right tool? (It needs to be able to manage FAT16, FAT32, HPFS

Any one you like. These are only entries in a small table on disk. A
binary editor would do. I like to use a combination of fdisk and
sfdisk. Sfdisk allows me to make any existing entry whatever I like,
and fdisk allows me to make "default" setups which I can then tweak.

Quote:> as well as Linux partitions.)

The parttion type is only a field on the partiton entry. The
contents of the partition are dealt with with a formatting tool, not a
partitioning tool.

Peter

 
 
 

How does Linux determine drive numbers?

Post by Richard Stein » Tue, 23 Jul 2002 03:05:36


Here in comp.os.linux.setup,

Quote:>> After thinking about it, it appears to me that Windows, OS and OS/2
>> assign drive letters based on their physical location on the drive while

>You would be completely wrong. The rules to letter assignment are more
>complex. I believe primaries on the second disk count before logical
>on the first, for example, and non-ms partitions are ignored entirely.
>Don't quote me on that - I don't use windows.

DOS (also Win9x and pre-LVM OS/2) drive lettering order (assuming two
physical hard disks) is typically:

  1st primary on 1st physical disk
  1st primary on 2nd physical disk

  1st logical in extended on 1st disk
  2nd logical in extended on 1st disk
    ...
  nth logical in extended on 1st disk

  1st logical in extended on 2nd disk
  2nd logical in extended on 2nd disk
    ...
  nth logical in extended on 2nd disk

  2nd primary on 1st physical disk (possible with boot manager like
                                    XOSL or System Commander that let
                                    you freely adjust visibility)

I'm uncertain after that point.

Quote:>Note that logical parititions do not appear in the 4-partition table in
>the mbr. They are chained within the logical partition.

>And you can add bsd slices to that.

Not with FreeBSD (which doesn't recognize the DOS "extended partition"
structure at all).  Perhaps other BSD derivatives, though.

--
 -Rich Steiner >>>---> http://www.visi.com/~rsteiner >>>---> Eden Prairie, MN
    OS/2 + BeOS + Linux + Win95 + DOS + PC/GEOS = PC Hobbyist Heaven! :-)
     Applications analyst/designer/developer (13 yrs) seeking employment.
        See web site in my signature for current resume and background.

 
 
 

How does Linux determine drive numbers?

Post by Michael Heimin » Tue, 23 Jul 2002 03:32:30



Hello Peter,


>> So, what is the right tool? (It needs to be able to manage FAT16,
>> FAT32, HPFS

> Any one you like. These are only entries in a small table on disk.
> A binary editor would do. I like to use a combination of fdisk and
> sfdisk. Sfdisk allows me to make any existing entry whatever I
> like, and fdisk allows me to make "default" setups which I can
> then tweak.

After problems with fdisk and a "big" IDE disc, I'm using cfdisk,
as suggested by 'man fdisk'.

Michael Heiming
--
Remove the +SIGNS case mail bounces.

 
 
 

How does Linux determine drive numbers?

Post by lmc » Tue, 23 Jul 2002 04:21:02



Quote:> How does Linux determine what the numbers (E.g., /dev/hda1, /dev/hda2,
> etc) are for hard drive partitions?

> Is there a way to allocate partitions in a multiple OS situation (some
> Windows partitions, some Linux partitions and some OS/2 partitions) so
> that they have the numeric assignments I want for Linux but also will
> have the drive letter assignments I want for the other OS's?

> I'm using Partition Magic 4.0.

> Thanks
> Jim

Since it seems that your a graphic type guy, may I suggest using

Paragon Disk Manager 5.0 http://www.paragon-gmbh.com/f_fm.htm

It's not as pretty as Partition Magic, but does show the proper layout
of the partition table

 
 
 

How does Linux determine drive numbers?

Post by James D Parker J » Tue, 23 Jul 2002 06:46:11



> Here in comp.os.linux.setup,

> >> After thinking about it, it appears to me that Windows, OS and OS/2
> >> assign drive letters based on their physical location on the drive while

> >You would be completely wrong. The rules to letter assignment are more
> >complex. I believe primaries on the second disk count before logical
> >on the first, for example, and non-ms partitions are ignored entirely.
> >Don't quote me on that - I don't use windows.

> DOS (also Win9x and pre-LVM OS/2) drive lettering order (assuming two
> physical hard disks) is typically:

>   1st primary on 1st physical disk
>   1st primary on 2nd physical disk

>   1st logical in extended on 1st disk
>   2nd logical in extended on 1st disk
>     ...
>   nth logical in extended on 1st disk

>   1st logical in extended on 2nd disk
>   2nd logical in extended on 2nd disk
>     ...
>   nth logical in extended on 2nd disk

>   2nd primary on 1st physical disk (possible with boot manager like
>                                     XOSL or System Commander that let
>                                     you freely adjust visibility)

> I'm uncertain after that point.

> >Note that logical parititions do not appear in the 4-partition table in
> >the mbr. They are chained within the logical partition.

> >And you can add bsd slices to that.

> Not with FreeBSD (which doesn't recognize the DOS "extended partition"
> structure at all).  Perhaps other BSD derivatives, though.

> --
>  -Rich Steiner >>>---> http://www.visi.com/~rsteiner >>>---> Eden Prairie, MN
>     OS/2 + BeOS + Linux + Win95 + DOS + PC/GEOS = PC Hobbyist Heaven! :-)
>      Applications analyst/designer/developer (13 yrs) seeking employment.
>         See web site in my signature for current resume and background.

By 1st and 2nd partition do you mean with respect to its physical location on
the disk or do you mean with respect to the position of its partition table
entry within the partition table?

Jim

 
 
 

How does Linux determine drive numbers?

Post by Nico Kadel-Garci » Tue, 23 Jul 2002 07:12:08




Quote:> I know that /dev/hda1 means "first" partition. The question is in what
> sense do you mean first? Let me give you an example. I have a hard drive
> (hdb) with the following layout:

> Linux Ext2, primary, /dev/hdb2
> HPFS, logical, /dev.hdb5
> FAT16, logical, /dev/hdb6
> FAT32, logical, /dev/hdb7
> Linux Ext2, logical (four of them), /dev/hdb8-11
> Linux Swap, logical, /dev/hdb12

> The extended partition itself is hdb1.

> When viewed through Partition Magic, /dev/hdb2 appears to be the first
> partition. It does occupy space at the beginning of the drive. So why
> isn't it /dev/hdb1 and the extended partition /dev/hdb2?

Because someone numbered it that way. Partitions /dev/hda[1-4] are set by a
number loaded into the partition table, not by the order of the drives. It's
actually possible to associate /dev/hda1 with, say, cylinders 100-200, and
/dev/hda4 with cylinders 1-99. I've seen it done, usually by Partition Magic
swapping partitions around or expanding them to fill an earlier space on the
disk without renumbering the partitions.

Quote:> After thinking about it, it appears to me that Windows, OS and OS/2
> assign drive letters based on their physical location on the drive while
> Linux assigns numbers based on the location of the partition's entry in
> the partition table with primary partitions getting numbers 1 through 4
> and logical partitions getting numbers 5 and up.

Oh. *Really*. Then why is the "A:" drive a floppy, "B:" drive the secondary
removable drive, whichever partition is marked as active and gets booted
with the "C:" drive, whichever partition is found next on the same drive the
"D:" drive, etc., etc.? DOS, the background OS for Microsoft's drive
handling decisions, makes things up to stack the drives the way Micro$oft
expects them.

Linux actually reads the partition table and associates partitions with the
first four partition numbers. It allows you to see a good bit more of the
internals, and control them more precisely.

Quote:>The order in the
> partition table is based on when the partition was created.  (Does this
> depend on what partitioning tool you use? It appears to be true of
> Partition Magic.). For example, if I were to delete and recreate the
> HPFS partition, it would become /dev/hdb12 and partitions /dev/hdb6-12
> would move down one to /dev/hdb5-11 even though it was recreated in the
> same location. For another example, if there were free space between the
> HPFS partition and the FAT16 partition and I created a partition in that
> space, it would become /dev/hdb13 rather than /dev/hdb6.

It's not the tool, it's how you use it. If you create partitions 1 and 2,
delete 1, then expand 2 to fill the same space, it's still partition 2. PM
will allow you to create more primary partitions, but 2 will now be the
first partitions on the drive.

PM is the only tool I've used that allows this.

Quote:> The partitioning tools that I use (Partition Magic and Drive
> Image) allow you to control the physical location of partitions and thus
> you can control drive letter assignment by Windows, DOS and OS/2.
> However, there does not appear to be any way to directly control the
> numbers that would be assigned by Linux. Well, at least not with
> PowerQuest tools. Are there alternatives that can handle this kind of
> thing?

Nobody cares that much about drive numbers in the Linux world, except for
restrictive partitioning tools. It's just a number! It's where you mount the
partitions that is key to arranging things the way you want. Both PM and
Linux's parted and fdisk variants have the tools to shuffle directories,
copy them elsewhere, recreate them, delete them and give them new numbers.
So you can do this sort of thing with other tools, except that fdisk will
throw a hissy fit if you try to set one partition in front of another one on
the disk that already has a higher partition number.
 
 
 

How does Linux determine drive numbers?

Post by Nico Kadel-Garci » Tue, 23 Jul 2002 07:17:40



> Here in comp.os.linux.setup,

> >> After thinking about it, it appears to me that Windows, OS and OS/2
> >> assign drive letters based on their physical location on the drive
while

> >You would be completely wrong. The rules to letter assignment are more
> >complex. I believe primaries on the second disk count before logical
> >on the first, for example, and non-ms partitions are ignored entirely.
> >Don't quote me on that - I don't use windows.

> DOS (also Win9x and pre-LVM OS/2) drive lettering order (assuming two
> physical hard disks) is typically:

>   1st primary on 1st physical disk
>   1st primary on 2nd physical disk

No. It's not. Whichever partition is booted  as "active" or from the MBR is
drive C:, even if it was the 15th virtual partition on the 3rd disk. I
believe that the additional drive numbering continues on that disk, then
goes through the next disk, then the next, etc. And don't forget the joyful
"swapping" of IDE disks as first or second disk based on which of them is
active. It gets quite messy: trust me on this.

Now, most sensible people don't do it that way because installing Windows is
typically restricted to the first partition on the first disk. But you can
move it elsewhere fairly trivially, then life gets nutso this way.

This is also off-topic here. Let's get back to Linux.

 
 
 

How does Linux determine drive numbers?

Post by mjt » Tue, 23 Jul 2002 08:37:51


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Quote:> How does Linux determine what the numbers (E.g., /dev/hda1, /dev/hda2,
> etc) are for hard drive partitions?

> Is there a way to allocate partitions in a multiple OS situation (some
> Windows partitions, some Linux partitions and some OS/2 partitions) so
> that they have the numeric assignments I want for Linux but also will
> have the drive letter assignments I want for the other OS's?

> I'm using Partition Magic 4.0.

http://www.tldp.org/HOWTO/HOWTO-INDEX/os.html#OSPARTITIONS

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Michael J. Tobler: motorcyclist, surfer,  #    Black holes result
 skydiver, and author: "Inside Linux",     #   when God divides the  
 "C++ HowTo", "C++ Unleashed"              #     universe by zero

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9Ox5ztTveLPAHcDIRAqPdAKCJMJiZRILpIyukveTkPP9QPrxfOACgkZja
Apd3KorQb5Ho7WiAGmYZeVE=
=G93u
-----END PGP SIGNATURE-----

 
 
 

How does Linux determine drive numbers?

Post by Richard Stein » Tue, 23 Jul 2002 11:46:08


Here in comp.os.linux.setup,



>> DOS (also Win9x and pre-LVM OS/2) drive lettering order (assuming two
>> physical hard disks) is typically:

>>   1st primary on 1st physical disk
>>   1st primary on 2nd physical disk

>No. It's not. Whichever partition is booted  as "active" or from the MBR
>is drive C:, even if it was the 15th virtual partition on the 3rd disk.

*Sigh*.  That'll teach me to post so late.  Yes, you're right.  The
"active" partition is the one typically assigned "C:".

--
 -Rich Steiner >>>---> http://www.visi.com/~rsteiner >>>---> Eden Prairie, MN
    OS/2 + BeOS + Linux + Win95 + DOS + PC/GEOS = PC Hobbyist Heaven! :-)
     Applications analyst/designer/developer (13 yrs) seeking employment.
        See web site in my signature for current resume and background.