electronic.alchemy :: Running MacOS X without a GUI
electronic.alchemy
where the past meets the future
start > 2017-05 > running macos x without a gui

Running MacOS X without a GUI

Created by hww3. Last updated by hww3, 8 years ago. Version #6.

Every once in a while, I run into a situation where I wish there was a way to run a Mac OSX box (these days rebranded macOS) without all of the GUI craziness.

This is admittedly a niche need, but it comes in handy at times. For example, when running a headless install, or in a constrained environment such as a continuous integration server. In such cases, there's no need to have the overhead of the GUI and all of the processes it starts up.

I'm trying to set up a continuous integration farm with VMs for each major OS revision and memory gets pretty tight on my Mac Mini "server". Since I'll be running the builds unattended, there's no real need for anything other than SSH or terminal access. The default VMWare settings for 10.9 are a 40GB disk and 2 GB of memory. Once more than one VM is running, things really start to slow down because of swapping and the like. Perhaps disabling the GUI will free up some memory and CPU cycles.

For example, on my fairly vanilla macOS 10.12 VM with a user logged in and a terminal running:

1927M used (432M wired) 120M unused.

And on the same machine with a user logged in but without the GUI running:

 1348M used (279M wired) 698M unused.

That's a significant amount of additional free space (let's not get into why a base OS should use so much memory in the first place… it's likely a case of death by a thousand cuts).

Enabling terminal mode login

The process is pretty basic: we need to disable the graphical login interface and turn on a standard UNIX terminal login process. Somewhere around OSX 10.5, Apple introduced launchd, which changed the way the system manages daemons and the login interface, so a lot of the tutorials that described this process on 10.4 and earlier will no longer work.

Luckily for us, it's not so hard to get working with newer versions, and Apple has provided a launchd definition for this that just has to be enabled:

To do this, edit /System/Library/LaunchDaemons/com.apple.getty.plist and and change the following:

    <key>Disabled</key>
    <true/>

to

    <key>Disabled</key>
    <false/>

Turning the graphical login interface off is almost as straightforward. The following services need to be disabled:

To each of the following files: Add the following lines:

    <key>Disabled</key>
    <true/>

Once you've done this, restart your system and it should come back up with a text mode login prompt.

Note: On systems running 10.12 and 10.11, SIP will prevent you from modifying these system files, even as root. To get around this, you need to do the following:

  1. Boot into Recovery mode with a Cmd-R at startup (or boot from an install DVD) and run
    csrutil disable

2. Restart and make the modifications above.

3. Boot back into Recovery mode and run

   csrutil enable

4. Finally, boot back normally.

Note: I've verified that this works beautifully on MacOSX 10.9 Mavericks and 10.10 Yosemite. It does not seem to work on 10.12; the login prompt is displayed but no input is accepted from the keyboard. I think this is a system bug because the old trick of using >console as the username to get a text terminal behaves the same way in 10.11 and 10.12. I am certain that if Apple fixes the problem with getty, this technique will work here as well.

Update: I spent some time on this and it seems that if you disable com.apple.configd and com.apple.hidd, the login works. I noticed that a lot of commands (such as ps and who) hang, so it's possible something else needs to be disabled.

On a final note, it's probably best to assume that all kinds of services won't work properly in this setup, such as software updates and iCloud syncing. But really, you were likely not interested in such things anyway, right?

Not categorized | RSS Feed | BackLinks

comments powered by Disqus