Removable Device drive letter assignment

Hello

I have a 256MB USB stick.

A)

  1. I created two partitions in it
  2. plugged the device
  3. Only one drive letter appeared, why? (from the first partition table
    entry)
  4. If I clear first partition table entry, then 2nd partition table entry is
    assigned a letter and displayed

B)
What system component (what driver, is it disk.sys?) is responsible for
drive letter assignment / reading the partition / etc, in the case of the
removable device?


Elias

See the classpnp and disk example in the DDK, for removable drivers only one
partition is initialized.

“lallous” wrote in message news:xxxxx@ntdev…
> Hello
>
> I have a 256MB USB stick.
>
> A)
> 1. I created two partitions in it
> 2. plugged the device
> 3. Only one drive letter appeared, why? (from the first partition table
> entry)
> 4. If I clear first partition table entry, then 2nd partition table entry
> is assigned a letter and displayed
>
> B)
> What system component (what driver, is it disk.sys?) is responsible for
> drive letter assignment / reading the partition / etc, in the case of the
> removable device?
>
> –
> Elias
>
>

> I have a 256MB USB stick.

Is it a removable media according to its INQUIRY data? Most new USB flash
drives - are, but I saw older (2003 year) ones which are not.

A)

  1. I created two partitions in it
  2. plugged the device
  3. Only one drive letter appeared, why? (from the first partition table
    entry)
  4. If I clear first partition table entry, then 2nd partition table entry is
    assigned a letter and displayed

Correct. Windows only sees the very first MBR partition on the removable
device, and does not see the others as separate objects, their sectors are only
accessible using \.\PhysicalDrive%d and proper offset. Some vendors like
IoMega use this to hide some their specific stuff on their media.

Partition device objects are created in Disk/ClassPnP combo, the source is in
the DDK.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

First of all, I have checked 3 removable USB and one 1394.
Only one them (USB) is defined as “Removable Storage”.
Others are recognized as “Hard Disk Drive”.

I’d suggest, all is written by Maxim must be checked for Keys are
defined as “Removable” and “Hard Disk” independently. Over more, I
guess, it is right only for disks defined as “Removable”, not “Hard
Disk”.
Really, if Disk is defined as “Hard”, it is not trivial problem
recognizing it as USB or 1394 drive. :frowning:

Some useful information:
I have found the difference in the assigning letters for Windows 2003
Server. W2K3 doesn’t assign letter auto, as XP or 2000! On W2K3 it may
be done only via administrative tools (compmgmt.msc). But be assign
once, it continues recognition in the future up to this letter would be
assign for other device. Some kind of protection from Microsoft I guess.
:slight_smile:
I have not checked assigning for multi partitions…

Additional question:
I’d like to know which difference in HardwareID (or else?) defines disk
as “Removable” or “Hard Disk”?

Regards,
Michael.

> I have a 256MB USB stick.

Is it a removable media according to its INQUIRY data? Most new USB
flash >drives - are, but I saw older (2003 year) ones which are not.

Correct. Windows only sees the very first MBR partition on the
removable >device, and does not see the others as separate objects,
their sectors are >only accessible using \.\PhysicalDrive%d and proper
offset. Some vendors >like IoMega use this to hide some their specific
stuff on their media.

Partition device objects are created in Disk/ClassPnP combo, the source
is >in the DDK.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Hello Maxim,

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>> I have a 256MB USB stick.
>
> Is it a removable media according to its INQUIRY data? Most new USB flash
> drives - are, but I saw older (2003 year) ones which are not.
>
>> A)
>> 1. I created two partitions in it
>> 2. plugged the device
>> 3. Only one drive letter appeared, why? (from the first partition table
>> entry)
>> 4. If I clear first partition table entry, then 2nd partition table entry
>> is
>> assigned a letter and displayed
>
> Correct. Windows only sees the very first MBR partition on the removable
> device, and does not see the others as separate objects, their sectors are
> only
> accessible using \.\PhysicalDrive%d and proper offset. Some vendors like
> IoMega use this to hide some their specific stuff on their media.
>
> Partition device objects are created in Disk/ClassPnP combo, the source is
> in
> the DDK.
>

Can you tell me what source file / function decide whether all partitions
should be used or just one?

Thanks,
Elias

This is a useless code( which creates the partition objects ), so for Vista
this code has been removed, in Vista the volume manager creates the
partition objects for the removable media and non removable media( i.e. hard
drivers).
In case of Win2k/XP the partition objects are created by the
classpnp.sys/disk.sys. But classpnp’s partition objects are used only for
the removable drivers, in case of the hard drivers they are not reported to
the PnP manager and have DEVICE_INITIALIZING flag. For the hard drivers the
ftdisk.sys or dmio.sys creates the partition PDOs which are used by the
system.

“lallous” wrote in message news:xxxxx@ntdev…
> Hello Maxim,
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
>>> I have a 256MB USB stick.
>>
>> Is it a removable media according to its INQUIRY data? Most new USB flash
>> drives - are, but I saw older (2003 year) ones which are not.
>>
>>> A)
>>> 1. I created two partitions in it
>>> 2. plugged the device
>>> 3. Only one drive letter appeared, why? (from the first partition table
>>> entry)
>>> 4. If I clear first partition table entry, then 2nd partition table
>>> entry is
>>> assigned a letter and displayed
>>
>> Correct. Windows only sees the very first MBR partition on the removable
>> device, and does not see the others as separate objects, their sectors
>> are only
>> accessible using \.\PhysicalDrive%d and proper offset. Some vendors like
>> IoMega use this to hide some their specific stuff on their media.
>>
>> Partition device objects are created in Disk/ClassPnP combo, the source
>> is in
>> the DDK.
>>
>
> Can you tell me what source file / function decide whether all partitions
> should be used or just one?
>
> Thanks,
> Elias
>
>

Ftdisk & dmio create “volume PDOs” not "partition PDOs’.

For removable media the volume & partition PDOs are the same object.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Slava Imameyev
Sent: Tuesday, July 11, 2006 12:26 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Removable Device drive letter assignment

This is a useless code( which creates the partition objects ), so for
Vista this code has been removed, in Vista the volume manager creates
the partition objects for the removable media and non removable media(
i.e. hard drivers).
In case of Win2k/XP the partition objects are created by the
classpnp.sys/disk.sys. But classpnp’s partition objects are used only
for the removable drivers, in case of the hard drivers they are not
reported to the PnP manager and have DEVICE_INITIALIZING flag. For the
hard drivers the ftdisk.sys or dmio.sys creates the partition PDOs which
are used by the system.

“lallous” wrote in message news:xxxxx@ntdev…
> Hello Maxim,
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
>>> I have a 256MB USB stick.
>>
>> Is it a removable media according to its INQUIRY data? Most new USB
>> flash drives - are, but I saw older (2003 year) ones which are not.
>>
>>> A)
>>> 1. I created two partitions in it
>>> 2. plugged the device
>>> 3. Only one drive letter appeared, why? (from the first partition
>>> table
>>> entry)
>>> 4. If I clear first partition table entry, then 2nd partition table
>>> entry is assigned a letter and displayed
>>
>> Correct. Windows only sees the very first MBR partition on the
>> removable device, and does not see the others as separate objects,
>> their sectors are only accessible using \.\PhysicalDrive%d and
>> proper offset. Some vendors like IoMega use this to hide some their
>> specific stuff on their media.
>>
>> Partition device objects are created in Disk/ClassPnP combo, the
>> source is in the DDK.
>>
>
> Can you tell me what source file / function decide whether all
> partitions should be used or just one?
>
> Thanks,
> Elias
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> This is a useless code( which creates the partition objects ), so for Vista

this code has been removed, in Vista the volume manager creates the
partition objects for the removable media and non removable media( i.e. hard
drivers).

…at last. I disliked this design with partmgr.sys and pseudo-PnP in it a lot.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>For removable media the volume & partition PDOs are the same object.

I would like to add to the Peter’s message.

PRE-VISTA ONLY:

Yes, since the volume managers - and even PartMgr - are not employed for the
removable media.

Disk/ClassPnP creates an 1 partition PDO for the removable media, and this very
PDO is the “mounted device”, the target of MountDev IOCTLs and thus the target
of the drive letter symlinks.

For a fixed disk, the MountDev is created in the volume manager (FtDisk for a
simple partition which is not a software RAID), has the name like
\Device\HarddiskVolume%d, and its relation to the partition PDO is kept only as
some internal stuff within FtDisk.

This makes the task of associating the drive letter to the physical disk in
user mode rather hard, the usual way is to employ
IOCTL_STORAGE_GET_DEVICE_NUMBER on a drive letter, since FSD will pass it down
to FtDisk, and FtDisk will pass it down to the partition PDO using its internal
association.

IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS can also be used, fully handled in FtDisk,
and provides the same disk number as IOCTL_STORAGE_GET_DEVICE_NUMBER.

Then you substitute this number to \.\PhysicalDrive%d, or - if you need the
CM_xxx/SetupDi handles for a disk - enumerate all disks, ask each for the
device number, and match.

I hope all is better in Vista. I would very much like to see the SetupDi-only
way of associating the drive letter to its physical disk. Anyway each volume is
a PnP devnode, though hidden.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com