Prevent Windows partition from automatically mounting - profzei/Matebook-X-Pro-2018 GitHub Wiki

With the exception of partitions in unreadable formats and certain hidden partitions such as EFI and Recovery HD, the default behaviour of macOS is to mount all partitions of a drive on boot-up, login, or on connecting an external drive.

The following steps detail how to ensure only the drives of your choosing mount automatically, leaving the rest unmounted within macOS: here our aim is to prevent Windows partition from automatically mounted on boot.

This task can be accomplished by putting the Windows Volume UUID into /etc/fstab:

  1. Launch Terminal app and paste the command:
diskutil info /Volumes/Win10 | grep 'Volume UUID'

where Win10 is the exact name for my Windows 10 partition as listed in /Volumes. Note: make sure to retain the speech marks if your volume name contains spaces or punctuation i.e. diskutil info /Volumes/"Windows 10" | grep 'Volume UUID'

  1. Copy this UUID string and paste it somewhere safe.
  2. Once this is done, in Terminal, type:
sudo vifs

and enter your administrator password when prompted: an empty editable document will then appear in the Terminal window.

Press the A key to bring up the cursor and, using the Down Arrow key, navigate down the document to below the lines marked with the # symbol and above the lines marked with the ~ symbol: finally press the Enter key.

  1. Now copy and paste the following line into the document:
UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none ntfs ro,noauto,noatime

Replace the string of Xs with your own UUID which you noted earlier. Note Options used above:

  • ro for readonly (can be omitted)
  • noauto to prevent auto-mount
  • noatime to skip writing last access times (performance thing, optional)
  1. Press the Esc key to exit cursor mode, then type :x and hit the Enter key to save your changes and exit the document.
  2. After a reboot, Windows partition added to the document should not automatically mount.

In order to reverse the changes described here you can remove Windows volume UUID from the /etc/fstab file using a similar process as before.

Note

  • To set a partition that is formatted as FAT to not automatically mount, replace ntfs in the above command with msdos.