In one of the previous articles, I covered how to write-protect removable USB drives. Today, we'll see how to write protect a specific non-removable disk partition or the entire disk drive without using third-party tools.
Advertisеment
There are many reasons to make a disk write-protected. It can be useful as an additional security option in some environments. Once you enable write protection for a drive or a partition, it will become read-only. Let's see how it can be done.
To make a disk readonly in Windows 10, do the following.
- Open an elevated command prompt.
- Type or copy-paste diskpart and press the Enter key. This will launch DiskPart. DiskPart is a text-mode command interpreter bundled with Windows 10. This tool enables you to manage objects (disks, partitions, or volumes) by using scripts or direct input at a command prompt.
- In DiskPart, type the following command
list disk
In the output, see the disk which you are about to make read-only.
- To continue with the required disk, you need to "select" it.
In the following command use the disk number you got from the previous command.sele disk DISK_NUMBER
For example, I need disk #1.
- To make the whole disk read-only, type the following command:
attributes disk set readonly
All partitions on the disk will be read-only.
The undo command is
attributes disk clear readonly
To make a partition readonly in Windows 10, do the following.
- Open an elevated command prompt.
- Type or copy-paste diskpart and press the Enter key.
- To find a specific partition, type
list volume
- "Select" the required volume by typing the following command:
select volume VOLUME_NUMBER
Replace the volume number with a number you got from the previous command.
- Make it read-only using the following command
attributes volume set readonly
The specified volume will be read-only.
The undo command is:
attributes volume clear readonly
That's it.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment
Please note that the diskpart read only flag works only on the computer on which the command was issued. On another comptuer, the read only flag will not be respected – anyone can write on it.
Is there a way to make the C: drive or the system/ boot partition read-only?
You’ll break the OS. I don’t recommend you doing that.
This operation is not allowed on the current boot, system or pagefile volume. It is also not allowed on any volume on a basic MBR disk that contains the boot, system or pagefile volume.
An alternate way with PowerShell:
Get-Disk # show disk numbers
Set-Disk -Number 1 -IsReadonly $true # for example disk 1 ($false for r/w)