I've noticed that, in Linux and other operating systems, it's possible to mount a disk partition as read-only. Can this be done in Windows?
Yes, although the approach to a Windows disk partition might seem a little more roundabout than in other OSes. Here's why.
NTFS volumes have a flag that informs the system it's attached to if the volume in question should be set as read-only. This flag is not something you can get to through Explorer, since it's rarely used.
In addition, if you set a volume as read-only by accident, it can have unexpected results. (Imagine doing this by mistake to your system volume. Ouch.)
Windows automatically attempts to mount partitions on any volumes it discovers, by way of the MOUNTVOL utility. This way, when you plug in a flash drive or attach an external hard drive, you don't have to go through the trouble of manually mounting the volume. The vast majority of the time, people want to mount a volume as read-write anyway.
That said, there may be times when you want to temporarily disable auto-mounting, for the sake of manually mounting a volume as read-only. To do this, run MOUNTVOL /N (as an administrative user) to switch off auto-mounting.
You can then use the DISKPART tool to look for the appropriate volume and set the flag by way of the ATTRIBUTES VOLUME SET READONLY command.
One nice side effect of having the read-only flag stored on the volume itself is that the volume will mount as read-only everywhere, not just on that particular system.
Programmer Muhammed Demirbaş has written a PowerShell script to make the job a little easier, without requiring the use of DISKPART.
This was first published in September 2013