Preventing Windows from assigning the Drive Letter to a partition is useful when you manually create partitions on the drive prior to installing the OS. Or you want to simply hide a partition from all Windows versions installed on your computer.
The typical partition structure for Windows 10 and Windows 11 includes the following partitions.
System (EFI) – mandatory on GPT drives, FAT32.
MSR (Microsoft System Reserved) – needed on GPT, used by Windows for servicing operations. Windows can work without it.
Windows – this is the system partition where the OS is installed.
Windows RE – a special partition that contains the System Recovery Environment. This partition never appears in File Explorer, and we are going to learn more about how it works.
How Windows hides partitions
During the creation of the partition structure for Windows RE, Windows set a special attribute 0x8000000000000001. It is a combination of two attributes – one blocks the automatic assignment of a drive letter. The other marks the partition as mandatory for the system to work, which prevents it from being removed from the Disk Management snap-in. Check out this document.
How to view partition attributes
To view attributes for a partition, use the diskpart tool. In diskpart, run the detail partition
command displays the type and attribute of the partition, as well as related properties. The following screenshot shows details for the recovery partition.
Also, something similar you can get from within PowerShell. The command is Get-Disk -Number <your disk number> | Get-Partition -Number <your partition number> | fl Type, GptType, IsHidden, NoDefaultDriveLetter
You will see the following details.
Type : Recovery
GptType : {de94bba4-06d1-4d40-a16a-bfd50179d6ac}
IsHidden : True
NoDefaultDriveLetter :
However, the Get-Partition cmdlet does not print out the Required attribute. But it shows the NoDefaultDriveLetter option.
So, by setting similar attributes to a partition, we will stop the OS from assigning the drive letter. At the same time, it implements foolproof protection, which prevents deleting a partition from the “Disk Management” snap-in – there is only “Help” in the context menu.
Stop Windows from Assigning Drive Letter to Partition
- Press ⊞ Win + R , type
diskpart
and hit ↵ Enter . - Type
list disk
to find the disk on which we will hide the partition, and typeselect disk #
to select it.#
is the disk number. - Similarly, type
list partition
andselect partition #
to select the partition with the number#
to hide it. - If your disk has a GPT layout, issue the two commands,
set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
andgpt attributes=0x8000000000000001
. - If it is an MBR disk, issue the command
set id=27 override
.
The identifier de94bba4-06d1-4d40-a16a-bfd50179d6ac
stands for the Microsoft recovery partition. It corresponds to the Hidden property.
The attribute 0x8000000000000001 is a combination of attributes 0x8000000000000000 (do not assign a drive letter) and 0x0000000000000001 (required partition). The second attribute is also reflected in the section details, the Required property.
The corresponding Powershell command is Get-Disk -Number <your disk number> | Get-Partition -Number <your partition number>| Set-Partition -IsHidden $True -GptType "{de94bba4-06d1-4d40-a16a-bfd50179d6ac}"
.
Obviously, the -IsHidden $True
option sets the 0x4000000000000000 attribute.
Disable Drive Letter assigning for a volume
If you disk has a GPT partitioning, you can use diskpart to block drive letter assignment for a volume. After that, all the partitions created on that volume will have the 0x8000000000000000 attribute and will never get drive letters.
Disable Drive Letter Assignment
diskpart
list volume
select volume N
attributes volume set nodefaultdriveletter
attributes volume clear nodefaultdriveletter
Enable Drive Letter Assignment
diskpart
list volume
select volume N
attributes volume clear nodefaultdriveletter
Allow Drive Letter Assigning for a Partition
You can get rid of the properties of the hidden partition. After than, you will restore the ability to assign a drive letter and access it in File Explorer. To do this, set the base partition ID to ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
and set the GPT attribute to 0
.
diskpart
select disk M
list partition
select partition N
set id=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
gpt attributes=0x0000000000000000
assign letter=H
If you don’t explicitly add the drive letter with the last command, Windows will automatically assign it after a reboot. Also, to access the disk in File Explorer, you don’t actually need to change the ID
the identifier. But it is required when you need to specify the drive letter manually.
Keep in mind that in PowerShell, the Set-Partition cmdlet doesn’t support removing the “Required” attribute, i.e. 0x0000000000000001.