10

Today I wanted to check the /etc/fstab on macOS and found that there is no /etc/fstab anymore. Ok, maybe its a long time since I've used it on OS X but i was always sure that the OS X had not too many differences from "UNIX" (since it is supposed that macOS (High Sierra) is indeed a UNIX).

But i had to realize that there is no possibility to admin or configure the fstab anymore. Now, there is an executable called "DiskImageMounter" living in /System/Library/CoreServices/DiskImageMounter.app/Contents/MacOS/ which seems to do the disk administration.

But how we can configure it like with a "normal" Unix like with /etc/fstab? Is it possible?

5
  • 2
    Trivia: macOS is not "UNIX" That's AT&T's product. The kernel of macOS is based on BSD which is a "UNIX-like" operating system.
    – Allan
    Feb 17, 2018 at 11:27
  • 7
    @Allan Very old posting, but I've got to comment. macOS is a UNIX, it has a certification and everything. See opengroup.org/openbrand/register/brand3648.htm . Second, the kernel isn't based on BSD, as much as it's Mach with a BSD userland. See en.wikipedia.org/wiki/XNU and developer.apple.com/library/archive/documentation/Darwin/… Nov 24, 2018 at 0:46
  • 3
    Since Mac OSX ist certified as a Posix compliant Unix, of course it derived and is a certified unix. As long as i know it, it was all the time Unix compliant. Look at images.apple.com/media/us/osx/2012/docs/…
    – Coliban
    Nov 25, 2018 at 7:31
  • 1
    fstab works fine in macOS, & actually very much needed in newer macOS 11, 12, 13, etc to mount network-share drives, to mount external-drives, etc, & for stable performance from such external drives . The fstab file based drive-mounting is not needed for portable external drive users who needs to unplug external drive too frequently or often . Only the "fstab" file is removed, as general individual users dont need that initially.
    – atErik
    Jan 18 at 16:43
  • @atErik: "fstab works fine in macOS" (⨀_⨀) ... omg
    – Seamus
    Nov 23 at 23:38

2 Answers 2

8

You are correct. There is no /etc/fstab file, but the use of the /etc/fstab file by macOS has not be removed. You just have to create this file yourself.

An example of a possible lines in the /etc/fstab file are given below.

UUID=F21AD81B-B114-456C-B2A0-BF4452E4842D none apfs rw,noauto
LABEL=Macintosh\040HD none apfs rw,noauto

A description for the fields can be found by entering the command man fstab.

You may want to refer to this question: How to prevent auto mounting of a volume in macOS High Sierra?

When using ls -l /etc/fstab to determine ownership and permissions, you should get the same as shown below.

-rw-r--r--  1 root  wheel  123 Dec 31 08:48 /etc/fstab

UPDATE (provided by iggie)

A modification of this answer can be used for ssh keys on an external FAT or ExFAT drive (e.g. mounted via VeraCrypt or whatever). Add the following line to your /etc/fstab file, even if it doesn't exist:

LABEL=PRIVATE none msdos -u=501,-m=700

This assumes your user ID is 501 (try ls -n ~) and the label on your FAT or ExFAT volume is PRIVATE.

2
  • A modification of this answer can be used for ssh keys on an external FAT or ExFAT drive (e.g. mounted via VeraCrypt or whatever): Add the following line to your /etc/fstab, even if it doesn't exist: LABEL=PRIVATE none msdos -u=501,-m=700. This assumes your user ID is 501 (try ls -n ~) and the label on your FAT or ExFAT is PRIVATE
    – iggie
    Apr 15, 2019 at 20:03
  • 1
    @iggie: I added your comment to the answer. If you wish, you can correct any mistakes I may have made. Thanks. Apr 15, 2019 at 20:56
0

To clarify: aye, obviously you can use /etc/fstab to mount things on macOS. By default it's empty; but that doesn't mean you cannot create it, it just means that, by default, there are no (external) things to mount! 😄

Note, however, that Apple strongly encourages editing /etc/fstab only by doing sudo vifs — any other way of editing the file may not work.

Although, by default — as the name implies! – vifs will call vim, you can actually use whatever editor you wish. Fo example, if you prefer to use nano instead, just set the EDITOR environment variable, e.g. with export EDITOR=/usr/bin/nano.

After editing the file and saving it, the appropriate command to run is sudo automount -vc — this will refresh existing mounts (none, if /etc/fstab was empty before editing it for the first time) and add new ones. These will persist after logout or even reboot.

Oh, and despite some comments regarding the 'nature' of macOS, the answer is that aye, it is a fully-licensed UNIX, with a modified Mach microkernel — thus unlike FreeBSD or other common BSD derivatives. However, most command-line applications do have a BSD flavour (and many have been compiled from the BSD sources).

It's Linux that isn't UNIX-compliant (and not only because the Linux Foundation couldn't care less about paying the licensing fees) but "Unix-like". macOS is fully UNIX compliant, just like its immediate predecessor, NeXT OS (from "Steve Jobs' Other Company").

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .