How to prevent an internal partition from mounting at boot

mountpartition

I have a HFS partition on my internal boot disk on a Mac Mini (High Sierra) that I would like to not automatically mount at boot time. Rather, I want to reserve it to raw-mount to a VirtualBox VM by default.

How do I configure the Mac to not automount the partition?

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            600.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:   ***           Apple_HFS Shared user data         199.6 GB   disk0s4
   5:                 Apple_APFS Container disk3         199.6 GB   disk0s5
...

I want to reserve disk0s4.

I've seen some similar posts that suggest automountd is involved, but don't provide any help configuring it.

Best Answer

Traditionally, the file you have to edit to prevent automounting is /etc/fstab.

In your case, you would need to add the line shown below to this file.

LABEL=Shared\040user\040data none    hfs   rw,noauto

You can get more information on the /etc/fstab file, by entering the command man fstab.

This also works:

$ diskutil info disk1s4 | grep Volume
   Volume Name:              Shared user data
   Volume UUID:              3D9A5D0C-1307-3178-81FA-9245634906D5
   Volume Total Space:       0 B (0 Bytes) (exactly 0 512-Byte-Units)
   Volume Free Space:        0 B (0 Bytes) (exactly 0 512-Byte-Units)
   Read-Only Volume:         Not applicable (not mounted)
dmaestro$ cat /etc/fstab
UUID=3D9A5D0C-1307-3178-81FA-9245634906D5 /Volumes/Shared\040user\040data hfs rw,noauto

Note that the mount path must be created manually before using Disk Utilities to mount the partition manually, and Disk Utilities will destroy that mount directory when unmounting manually.