How to run OSX in a VM on VirtualBox


Would it not be great to be able to run OSX on a virtual machine? Now you can*! All you need is a disk image of the retail DVD of “Apple Mac OSX Snow Leopard 10.6” and you can install it inside VirtualBox. Alternatively if you have a Mac (or know somebody who does) you can create a bootable image of (the free) “Apple Mac OSX Yosemite 10.10” and install that version. Instructions below.

Apple Mac OSX Snow Leopard 10.6

You need:

  1. VirtualBox 4
  2. ISO of retail DVD for “Apple Mac OSX Snow Leopard 10.6” (buy here)
  3. Follow instructions carefully

Open VirtualBox and create a virtual machine named “osx”. Then close the entire VirtualBox application and go to the command line. Run:

VBoxManage modifyvm osx --cpus 1
VBoxManage modifyvm osx --vram 128
VBoxManage setextradata osx VBoxInternal2/EfiGopMode 5
VBoxManage setextradata osx "VBoxInternal2/SmcDeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"

Open VirtualBox again and start the virtual machine. Mount “Apple Mac OSX 10.6 Snow Leopard Retail.iso” and install. After installation (30 minutes) the system will reboot and it is ready for use.

Apple Mac OSX Yosemite 10.10

You need:

  1. VirtualBox 4
  2. Bootable image of “Apple Mac OSX Yosemite 10.10” (using “iesd”)
  3. Follow instructions carefully

The latest version of Apple’s OSX can also be run under VirtualBox. Download it for free from the “Apple App Store”. You do need a Mac with a valid Apple-id for this. Make sure you have the “XCode Command-Line tools” installed on this Mac. Then run the following commands to convert the download into a bootable disk image:

gem install iesd
iesd -i /Applications/Install\ OS\ X\ -o Desktop/yosemite.dmg -t BaseSystem

Move “yosemite.dmg” to your Virtualbox environment and use it instead of the Snow Leopard DVD image. Note that this image does support multiple CPUs, so this will allow you to speed things up.

*) Known issues

Here are the issues on the various platforms:

  • OSX 10.6 [Linux] can only be used with a single CPU
  • OSX 10.6 [Linux] sound is not working properly
  • OSX 10.10 [Linux] cannot login on Linux
  • OSX 10.10 [Linux] graphics are very slow
  • OSX 10.10 [Linux] sound is not working

Note that Apple only allows and supports running OSX in a VM on OSX. As you can see I only tested on Ubuntu 14.04 as a host (which is not supported). Let me know whether or not the above instructions work for you (on Windows or OSX).


It is not working very well (out-of-the-box), but it does work a little. Enough to get you started. With some serious tinkering you may even fix it to an acceptable level. If you do, please let me know!



File name has � (invalid encoding) and CRLF issues


On Linux you sometimes you get a “�” in a file name and a trailing “(invalid encoding)” in the filename. This is something that can happen when moving files from Windows to Ubuntu Linux. When uploading files to a Linux box you basically need two Linux tools to “repair” any incompatibility: “convmv” and “dos2unix”. The following commands will install them (on a Debian based Linux):

sudo apt-get install convmv
sudo apt-get install dos2unix

Character encoding

To remove the “(invalid encoding)” you use the “convmv” tool. It is a tool that will convert the character encoding used in the file name. You can try the conversion of file names from different character set to UTF-8 using the following commands:

convmv -r -f windows-1252 -t UTF-8 .
convmv -r -f ISO-8859-1 -t UTF-8 .
convmv -r -f cp-850 -t UTF-8 .

These are the three most popular character encodings (for Western Europe). If you need another character encoding use the “locale -m” command for a full list of options. Check out the Wikipedia character encoding page to find the characteristics of each of them.  After you confirmed that the conversion is correct you can run the actual conversion by adding the “notest” flag. A typical run would look like this (use “-r”  for recursive):

$ convmv -r -f windows-1252 -t UTF-8 .
Your Perl version has fleas #37757 #49830
Starting a dry run without changes...
mv "./jag f�rst�r inte.txt"    "./jag förstår inte.txt"
No changes to your files done. Use --notest to finally rename the files.
$ convmv -r -f windows-1252 -t UTF-8 . --notest
Your Perl version has fleas #37757 #49830
mv "./jag f�rst�r inte.txt"    "./jag förstår inte.txt"

Line endings

Different operating systems have different line endings. The line endings are marked by one or two ASCII characters. These are the common styles:

  • CRLF: for the DOS\Windows world
  • CR: for the pre-OSX Mac world
  • LF: for the Unix and Unix-like world (including OSX)

Where the CR and LF characters are defined as such:

  • CR: Carriage Return is ASCII character 13 (0x0D)
  • LF: Line Feed is ASCII character 10 (0x0A)

To detect what line endings a file has you can use “vi” and look for ^M (control-M) characters:

$ vi jag\ förstår\ inte.txt
Do you understand IT?^M
Yes I do!^M
"jag förstår inte.txt" 2 lines, 34 characters

Or you can use the “file” command:

$ file jag\ förstår\ inte.txt
jag förstår inte.txt: ASCII text, with CRLF line terminators
$ dos2unix jag\ förstår\ inte.txt
dos2unix: converting file jag förstår inte.txt to Unix format ...
$ file jag\ förstår\ inte.txt
jag förstår inte.txt: ASCII text

To do the conversion of line endings from Windows to Linux

$ file jag\ förstår\ inte.txt
jag förstår inte.txt: ASCII text, with CRLF line terminators
$ dos2unix jag\ förstår\ inte.txt
dos2unix: converting file jag förstår inte.txt to Unix format ...
$ file jag\ förstår\ inte.txt
jag förstår inte.txt: ASCII text

Alternatively you can use an editor that supports conversion of line endings. Examples of open source text editors that support conversion of line endings are:

  • “TextMate” on OSX
  • “Notepad++” on Windows
  • “Gedit” on Ubuntu Linux

When I committed files from my OSX laptop to the Git repo, the “git diff” command showed way too many lines (since the line endings were changed). My colleagues showed me how to use the above commands to avoid any problems.


Synergy between different operating systems


At LeaseWeb, developers like to work on Linux, business people like to work on Apple, but almost everybody runs Windows. One of the reasons it is hard to work without Windows is that our calendar and email system only works well under Windows (it is Microsoft Outlook). I have seen several ways to work around this problem. One is to have multiple computers at the office, one running Windows that can be used as an email and calendar system and another Linux or Apple computer to do the actual work on. Multiple computers means multiple screens, which is also a big plus, but it also means multiple mice and keyboards. And that is something less convenient.

Well, there is an App for that… And it is free and open source! It has the appropriate name “Synergy” and makes your Linux/OSX and Windows play along very well. Download it here. One of your computers becomes the “Server” and the other(s) become the client(s). The server has a keyboard and mouse and if you move the cursor off the screen it automatically appears on the other computers screen and you can continue working with the same mouse and keyboard. The clipboard is conveniently shared as well. The computers use the network to communicate. There is only one very big problem with this nice software and that is that its security is very weak (non-existent). The Synergy wiki says:

“Synergy does not do any authentication or encryption. Any computer can connect to the synergy server if it provides a screen name known to the server, and all data is transferred between the server and the clients unencrypted which means that anyone can, say, extract the key presses used to type a password. Therefore, synergy should not be used on untrusted networks.” – source:

So if you use Synergy over the wireless network and you type important passwords, the wireless network encryption is the only thing keeping hackers (hiding in a mini-van in your street) from retrieving those passwords. If you use a cabled network the security risk might a little bit lower. Fortunately you can make it secure, as described in the same wiki, by adding a SSH tunnel for TCP port 28400 from the client to the server. For Windows you can use the Bitvise Tunnelier software or MyEnTunnel (which is a front-end for the less user-friendly PuTTY applicaton) and for OSX you can use the SSH Tunnel Manager. To make this work you have to enable SSH logins on the machine that acts as your Synergy server. If you want to install an SSH server on Linux you can install the “openssh-server” package. On OSX you can find the OpenSSH server under sharing and on Windows you can install the user friendly Bitvise WinSSHD or FreeSSHd.

Conclusion: Synergy… It is a cool tool, but use it responsibly!