Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mid9commander/535033 to your computer and use it in GitHub Desktop.
Save mid9commander/535033 to your computer and use it in GitHub Desktop.
It is great to be able to run Linux on OSX in headless mode, this serves me very well because I have no choice but to use a Mac at work,
and there are many occasions where I need to have a Linux machine.
There are a couple reasons I don't like running virtual machines in regular mode.
1. It consumes way too much memory and CPU than I am willing to give up
2. It consumes way too much "attention" than I am willing ti give, for example, when you tab into your VM,
your mouse and keyboard gets captured and you have to hotkey out of it, it is just disruption to my work flow.
Headless mode comes in handy and solves the problems above because
1. It consumes about half of the memory and CPU because it does not handle monitor,
mouse and keyboard so the system resources are dedicated to the core functionality.
2. It only takes a terminal/shell to run it in headless mode so it doesn't really disrupt you in anyway.
You can start it and forget about it, it is sort of like a daemon.
This comes in very helpful when I ran Oracle Express in my Linux VM inside my Mac.
Here are the steps.
1. download VirtualBox, I don't know if other VM ware can do it. Virtual box is free and it is great.
2. install Linux
3. start up Linux in regular mode to install soft-wares that you need
These steps are optional, follow them only if you want to install oracle express
3.1. install oracle express
3.2. port forward Oracle express so that it could be connect to from the host machine
The best way to achieve port forwarding is just edit the <machine_name>.xml in ~/Library/Virtual Box (for OSX, for other OS, check the user manual chapter 9)
For example, this will forward port 1521 in the "guest machine" to port 1540 on the "host machine"
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/oracle/GuestPort" value="1521"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/oracle/HostPort" value="1540"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/oracle/Protocol" value="TCP"/>
To check that the port gets forwarded correctly, you can simply use telnet
6. Set the ubuntu VM to turn on remote desktop connection and listens on 3389.
VBoxManage modifyvm "ubuntu" --vrdp on --vrdpport 3389 --vrdpauthtype null --vrdpmulticon on
7. Start Linux in headless mode
VBoxHeadless --startvm ubuntu
8. To verify that Oracle Express works, do
telnet localhost 1540
from your Mac and make sure it accepts connection
9. In case you need to do anything that requires keyboard/mouse/monitor inside your VM, you can use
Remote Desktop Connection to connect to it on localhost:3389, I don't know if that is less resource intensive
than starting VM in regular mode, it seems to be for me. I prefer it over accessing it through regular mode anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment