What do the readonly attributes in diskpart really mean

diskpartread-only

I am wondering exactly what the meaning is of the "Read-only" disk and volume attributes that you can twiddle in diskpart on Windows 7. I am trying to set up an external USB drive as an installation medium for my own software, so I'd like to protect it against casual or inadvertent changes by users who it is given to, so they don't screw up the installation files they might need in the future.

From what I can tell by experimentation with diskpart, the volume read-only attribute is actually stored on the physical disk somewhere, because I can set it and it shows up when I take the drive to another machine. This is great because my users can't (easily) change any of the files on the volume, or format it from Windows explorer.

However, the disk read-only attribute seems to be just an aspect of how the current machine is accessing the drive. When I set it I can no longer delete the volume in the disk via Disk Management, but when I take the drive to another machine, the attribute is no longer set and in Disk Management I can delete the volume on the disk. I guess I'm not that worried about my users doing that, but I am annoyed that I don't understand what these attributes are really doing.

Another thing that I don't understand is that the "volume" read-only attribute actually seems to be global to the disk – if I have two volumes on the disk, and I set the readonly flag on one of them, then it gets set on the other one too. ?!?

I have the feeling I'm not searching for the right docs – all I'm finding is diskpart docs that give the syntax for twiddling these attributes, not what they really mean. Any pointers would be very welcome!

Thanks,

Asa

Best Answer

I'm currently digging around volume attributes because Vista installation fails without using official Setup, by deploying an image using imagex and bcdboot.

I can't figure out where diskpart saves the information about attributes, most likely on the disk because (nodefaultdriveletter) is also applied after restarting; also when booting to an offline system.

And yes, diskpart is applying volume attributes always to all volumes on the selected disk. The behavior of attributes volume is not the expected, and it is nowhere documented. Occurs on all versions including Win8's build 9200.

The readonly attribute is only a hint, it doesn't prevent one from writing on the disk.

To hide a volume from Windows, use remove, but that information is saved to HKLM\SYSTEM\MountedDevices (so only applied to the current running system), or you are required to use set id=, NTFS default id is 07, try 17 or 27. There is a List of partition identifiers for PCs, to decide what you like. FAT32 identifiers does Windows like to also identify as NTFS, without mounting them automatically.

Related Question