How to mount an NTFS partition read-only in Windows?

52

28

I feel like this is a really simple and fundamental function that Windows should have, but so far Google has been telling me it isn't possible. How can I mount an NTFS partition read-only in Windows?


Everett's answer works! (Thanks.)

Additional info about diskpart:

  1. If you have multiple volumes in a disk, neither detail vol nor attr vol shows the correct read-only status. It shows the read-only status of the last modified volume. Try these: sel vol 1, attr vol set readonly, sel vol 2, attr vol clear readonly, sel vol 1. Now detail vol shows that volume 1 is not read-only, but it actually is.

  2. If you modify a volume with Linux's ntfs-3g and then bring it to Windows, it cannot be mount read-only.

  3. If you run attr disk set readonly, none of the disk's volume can be mounted.

netvope

Posted 2010-11-20T04:23:33.200

Reputation: 4 505

1Without trying to detract from an otherwise nice question and answer, if one wants to try to use ATTR/ATT on an old and archaic version of Windows (i.e. XP), diskpart 5.1.3565 doesn't support that command. Why one might want to use an XP version of diskpart might be seem to present quite a puzzle, but, well, just saying, I couldn't use the goodness in this question and answer - the question did not constrain the question to particular vintages of Windows. – kbulgrien – 2017-08-09T22:19:20.060

Answers

55

  • Switch off "automount" by running mountvol.exe /N
  • Connect disk to Windows (do not mount the disk)
  • Run diskpart
    • Enter list volume
    • Enter select volume X (where X is the correct volume number from the previous command)
    • Enter att vol set readonly
    • Enter detail vol and ensure the read-only bit is set

Now you can mount the volume and it will be read-only.

See also: http://crawlmsdn.microsoft.com/en-us/magazine/cc302206.aspx

Everett

Posted 2010-11-20T04:23:33.200

Reputation: 5 425

Curious, is it possible to mount the system volume as read-only? I imagine I would need to disable the pagefile and any logging will crap itself. – Adam Plocher – 2016-12-12T09:42:49.837

Although under Windows 8.1, mountvol /N didn't prevent the drive from being automounted, all of the other commands worked as specified. – Adrian – 2017-07-23T16:25:02.360

9Note: those attributes are persistent and stored on the partition, so this is a bit different from the "read-only mount" notion on Linux (ie. simply putting the hard drive back in the original enclosure won't make the partition read-write, and Windows won't be able to boot on it). – Damien B – 2012-07-12T21:03:46.627

7To re-enable automatic mounting of new volumes use mountvol.exe /E. To remove the readonly flag, select the volume in diskpart (use the commands in this answer) and enter att vol clear readonly. – Ronald – 2012-12-05T23:52:48.923

1

Thank you Everett, this also answers my question. I wrote a PowerShell script according to your explanations, may be useful for someone else.

– mmdemirbas – 2013-03-23T21:03:19.660

it also works for volumes mounted on directories instead of dos units! thanks! – user1586274 – 2013-07-27T05:18:19.857

3

Under Windows 8.1, mountvol /n did not prevent drive from being automounted. One should consider using this beforehand: http://www.petri.co.il/configure_usb_disks_to_be_read_only_in_xp_sp2.htm

– Ivan Vučica – 2014-02-05T21:19:42.580