Stop Windows from mounting a NTFS file system

Solution 1:

The fstab equivalent on Windows is the "Mount Manager", which you control via DiskMgmt.msc, or DISKPART, or the MOUNTVOL command.

It may be enough to remove the drive letter, either via DiskMgmt.msc, or using remove within DISKPART. Additionally you can set the GPT attribute field to "No automount" (bit 63) to prevent the partition from ever automatically receiving a drive letter.

If that still doesn't help, set the GPT attribute "Hidden" (bit 62) to make the Mount Manager completely ignore this partition, and/or "Read-only" (bit 60) to tell Windows it should be read-only.

If that doesn't help, change the partition's GPT type GUID to something else than "Microsoft Basic Data". For example, use one of the Linux partition types.

(All of the above are completely ignored by Linux and will not prevent you from using the partition.)

Windows (DiskPart)

  1. Use list disk and sel disk <num> to select the physical disk.
  2. Use list part and sel part <num> to select the partition you want to change.
  3. Use remove to unassign the current drive letter.
  4. Set GPT attributes to "Hidden" using gpt attributes=0x4000000000000000.

    • No automount = 0x8000000000000000
    • Hidden = 0x4000000000000000
    • Read-only = 0x1000000000000000
    • all of the above = 0xD000000000000000

Linux (sfdisk)

sfdisk takes a comma-separated list of bits to set:

sfdisk --part-attrs /dev/sda <partnum> 63

For "Microsoft Basic Data" partitions, bit 63 is "No GPTautomount"; bit 62 is "Hidden"; bit 60 is "Read-only".

Linux (gdisk)

Run gdisk /dev/sda.

  • To change partition type GUID: Use t and choose whatever type looks least Windows-friendly.

  • To change partition flags: Use x to enter "Expert" menu, then a to select "Set attributes". Enter partition number and enable bits 60/62/63. Afterwards use m to return to the main menu.

Don't forget to use w to write the updated partition table.