Prevent BootCamp partition from automatically mounting

Solution 1:

I found this forum post which has a couple options:

The straightforward way is to create a login applescript, replacing /Volumes/Windows with your path:

tell application "Finder"
    if (exists the disk "Windows XP") then
        do shell script ("hdiutil unmount /Volumes/Windows\\ XP -force")
    end if
end tell

Another way is to modify /private/etc/rc.local to add:

disktool -u disk0s3

If you have more than one disk, or have formatted it into more than just a MacOS and Windows volume, you will have to use Disk Utility or something to determine the Disk Number (in this case 0) and Partition Number (in this case 3) of your Windows volume.

Solution 2:

Your original solution using /etc/fstab will work, but you must use the volume's UUID (which DOES exist, Disk Utility just doesn't display it for NTFS formatted partitions- thanks Apple...) To learn the UUID use the following command in terminal:

diskutil info /dev/diskXsY ##substituting the X & Y for the disk and partition designation of the volume you want NOT to be mounted- which you can learn with: diskutil list

For this command to succeed and show you the UUID you can not have Tuxera NTFS enabled for that partition. If you are using that or probably any other non-native file system drivers for NTFS, you must disable them (at least for that partition) and reboot. The partition must also either be mounted or dismounted when you run the command- I can't remember which (and I remember that for me it actually turned out to be the opposite of what I found posted on a forum somewhere... so experiment).

If for some reason you just can't get OS X to show you the UUID you can resort to booting up with an Ubuntu installation disk and using a tool like gparted (there are quite a few ways using either the command line or a GUI app- you won't have trouble finding more information on that). You don't have to worry, the UUID will be the same between operating systems.

Then add the following line to /etc/fstab

UUID=(you know what to put here- no enclosing brackets or anything) none ro,noauto 0 0

reboot and voila- no unwanted partitions mounted! This is a system wide setting for all users, but you can still mount the partition using the Disk Utility.

This is the most pervasive and effective solution to this problem- plus it's not broken if you happen to move the disk to another controller or port, or even if you change the volume's label. However, formatting the partition will assign it a new UUID.

Solution 3:

In Mac OS Catalina 10.15.7 and above, you SHOULD NOT Edit the fstab entry directly. Instead you should use vifs with sudo. To accomplish what the original post is requesting in MacOS Catalina and above, you should take the following steps.

  1. Open your terminal app
  2. Type diskutil list
  3. Note the disk volume of your bootcamp partition, i.e. /dev/disk0s3
  4. Next find the Volume UUID of your bootcamp partition by typing diskutil info /dev/diskXsY where X is your disk and Y is your bootcamp partition. i.e. diskutil info /dev/disk0s3
  5. The result will return information of Type (Bundle): ntfs and Volume UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  6. Note both of those paramaters, and copy the Volume UUID into your clipboard.
  7. Type sudo vifs and enter your password
  8. Once in vifs, type 'a' and hit enter.
  9. Create a new line on the bottom of the page.
  10. Copy and paste this EXACTLY as it is printed here replacing the UUID with your UUID that you copied in step 6:
# Forbid Mounting of Bootcamp volume at boot by uncommenting the line below
UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none ntfs ro,noauto
  1. Press escape, then hold shift and type zz to save the file.

  2. Bootcamp will now be properly forbidden from automounting at MacOS Boot.