Home » Questions » Computers [ Ask a new question ]

How to assign permanent drive letters to removable USB hard drives

How to assign permanent drive letters to removable USB hard drives

I have scripts that expect specific drive letters for hard drives. Windows sometimes assigns the different drive letters (e.g. I expected my Maxtor drive to be E:, but it's now F:, therefore my scripts will fail), depending on the order of how the drives are plugged into my laptop.

Asked by: Guest | Views: 250
Total answers/comments: 2
bert [Entry]

"You can do this in Computer Management without external tools. The interface is slightly different in Windows 7 but the location is the same.

Start -> Type compmgmt.msc and press Enter -> Storage -> Disk Management

or

Press Win + x and then press k to choose Disk Management."
bert [Entry]

"Drive letters get ""forgotten"" when you assign a new drive to that letter. If you want multiple drives (for example, backup drives) to have the same remembered letter it is a pain, but there is a non-randomware way.

I felt the need to post this after scouring the Internet trying to find a solution for multiple drives that I wanted to rotate out, all retaining the same drive letter for my scripting joy. Sometimes whateverware (USBDLM) just isn't a good enough solution for your domain controllers, sensitive kiosks, etc., so we will do this the hard way.

If you don't have a lot of data or are starting from scratch, the easiest way is to disk to disk clone the device with the assigned letter to other devices using Clonezilla. But if you already have data on drives and can't backup/restore that data, or don't want to, or just like the hard way it appears to be associated with the volume GUID so you'll need to find a way to modify that on your existing volumes so that they all match and then do some testing. I did it the Clonezilla way. I haven't tried but imagine a partition clone would also work.

What I can verify for you is that it does not come from the disk id, so modifying this via diskpart is not helpful, and that you can get volume GUIDs using PowerShell:

GWMI -namespace root\cimv2 -class win32_volume

Hopefully somebody smarter than me can figure out how to change or specify volume GUID and test it out or at least determine if this is indeed where the reg value comes from so we can dynamically do this without cloning entire drives.

How it works:

When you assign a drive letter to a drive, Windows stores this in the registry under the key hklm\system\mounteddevices. You can observe that when you assign a new drive the X letter (for example) the data portion for the reg_binary (\dosdevices\x: in this case) is overwritten with the new drive and you can't have multiple entries with different values, so the next time you plug in that old drive it won't be X any more.

If you look at the reg_binary value itself it starts with dmio id followed by a GUID - which actually stems from the disk unique id. I don't actually understand the relation/translation into the binary reg vlaue except to say that it comes from the disk's unique id. I only say this to illustrate that we don't need to worry about volume GUIDs here, because the lettering all stems from the drives unique id. This may not be the case on MBR/Basic disks I'm only working with GPT dynamic disks here (and you probably are too).

Further reading/stuff I found:

Partitions and volumes
social.technet.microsoft.com/Forums/en-US/e7b2ddd6-f245-49ed-8fec-3b6e08e75369/how-do-i-find-the-partition-guid?forum=winservergen

Volumes GUIDs and other things in mounteddevices
morgansimonsen.com/2009/01/26/displaying-the-volume-guid-of-a-volume-2/"