If you want to show or hide your hard drive partition using Command Prompt or Terminal, here is how you can do it. All you need to do is to remove the drive letter.
Unhide or hide hard drive partition using Command Prompt
While there are multiple ways to hide drive partitions, in this post, we are specifically sharing how to do it from the Command Prompt. We are using the Diskpart tool, which also offers a command-line interface. Before going ahead, stay warned that Diskpart is a powerful tool that offers complete management of the drive, and it includes the option to delete the partitions as well. While hiding don’t delete and you can always bring them back, use them carefully.
Basic Diskpart Command
- diskpart – Opens Diskpart console
- list volume – Displays all the volumes on the computer.
- select volume #number – Selects the partition you want to hide
- remove letter #driveletter – Removes drive letter of the selected volume
- assign letter #driveletter – Assigns drive letter to the selected volume
Follow the steps to hide or show the drive partition.
Open Command Prompt with admin permissions. You can do so by typing CMD in the Run prompt (Win + R), followed by pressing Shift + Enter together. You will get the UAC prompt; make sure to choose yes from the pop-up window.
Type the following command, and press the Enter key to launch the Diskpart console.
Diskpart
The text in the Command Prompt, which was displaying the path, will be replaced by “Diskpart>” Next, type the following to list all the partitions that you can see using File Explorer.
list volume
Open File Explorer, go to This PC, and match it with what you see here. In the Diskpart tool result, the Lable column will match with the exact name you see on the computer. It might cut short the name because of the limit but gives you a fair idea. You can also identify the disk with the drive letter.
To do any operation on a particular drive, here we are going to hide it, you need to select the drive or partition. Let’s assume I want to hide the “D” partition with the label Backup. First, we will have to select the Volume and then operate on the drive. The backup partition has the label Volume 2. Execute the following as per your computer to select the drive which you want to hide.
select volume 2
By design, if a partition doesn’t have a drive letter assigned, it will not be accessible. If you remember, when you format a drive, it is always assigned a drive letter at the end. Now you know the reason. Execute the command to remove the drive letter, which, in my case, is D.
remove letter D
Once the execution is completed, you should receive a success message. Double-check with File Explorer, and it will not be available from anywhere. Technically, the partition has been dismounted.
To bring back the partition, you will need to mount it again and assign the drive letter again. You can always assign any drive letter which is not assigned to anyone else. If you are doing it after some time, then follow the complete list, else just the last one is enough.
list volume select volume 2 assign letter J
To exit the diskpart tool, type exit, and you will get back to the command prompt as usual.
I hope the post helped you hide drive partitions using the command prompt.
Read: Why is C the default Windows System Drive letter always
How to show hidden partition in cmd?
To show hidden partition using cmd or Terminal, open it with administrator privileges and enter these commands:
- diskpart
- list volume
- select volume [volume-number]
- assign letter [drive-letter]
How do I hide a hard disk partition?
To hide a hard disk partition in Windows 11/10, you need to remove the drive letter. You can use Disk Management or Command Prompt or Terminal. In the Command Prompt, enter these commands:
- diskpart
- list volume
- select letter [volume-number]
- remove letter [drive-letter]