Mac OS X in Linux via VirtualBox (as guest OS)

I recently installed a Windows virtual machine on my Linux laptop. I wanted to test out a virtualized Mac OS X machine via VirtualBox as well (just in case I ever needed to do something that can only be done on a Mac). My main references are this post and this post. Although they virtualize on a Windows host machine, it also worked on my Ubuntu 10.10 host laptop.

Things I needed:

  1. A Mac OS X 10.6 (snow leopard) installation dvd (RETAIL version, not the one that comes with the Apple machine). Buy a copy and rip it to iso.
  2. nawcom ModCD to be able to boot the installation DVD. The EFI that came with VirtualBox and the Empire EFI from the first post did not work.
  3. The latest myHack. I used version 1.1 (r123). Install this before the Apple update.
  4. Mac OS X 10.6.5 Update. Don’t do OS upgrade via the Automatic Updater, and don’t update without consulting the myHack website; things can break.

Some notes to myself:

  1. When creating the hard drive, use “dynamic” and just make it as big as possible. I originally did 20gigs and had to re-do to 100gigs. Since it is dynamic, you won’t take up space on your host system until you the space get filled up on the guest. Although there is a way to resize the hard drive on a Windows guest, I wasn’t able to do so on the Mac guest (different filesystem and there is that boot loader issue). Looking back in hindsight, I should’ve just made it 500gigs and move the virtualization on an external disk if I ever reach that (I highly doubt it!).
  2. To access files on the host, set up samba on the host and connect to it on the guest.
  3. I used dmg2img to convert dmg to iso (when needed).
  4. Follow the second post to change the resolution (modify /Extra/ and run =VBoxManage setextradata “MacOSX64″ “CustomVideoMode1″ “1366x768x32″= on the host). “1366x768x32″ is the resolution on my Toshiba Portege R705 running Ubuntu 10.10. Now I can go fullscreen.
  5. Sound most likely won’t work. I have no use for it anyways.

Good luck. I hope I won’t have to use it much, but it’s nice to do everything in one machine, running inside of Linux (as opposed to having multi-boot).

Virtualization with VirtualBox (running Windows inside Linux)

I recently re-installed Windows on an old laptop to use Adobe Acrobats and the likes. Some Windows programs just aren’t accessible on Linux via Wine (although MS Office works). I’ve decided to set up Windows as a virtual machine on my Linux laptop; let’s see if virtualization will take the separate Windows machine out of the picture. I went with VirtualBox since it is open source, free, and was mentioned on Linux Journal. My initial reaction is VERY favorable. It seems everything works flawlessly (internet, cd drive, accessing files from the host machine; usb supported only through PUEL proprietary version.). I’ll jot down what I would like to be able to do with VirtualBox but have not been able to yet later in the post.

For the remainder of this post, host machine refers to my Linux laptop, and guest machine refers to the virtual machine with Windows XP.


## open-source version
sudo apt-get install virtualbox-ose ## install on debian/ubuntu
## PUEL version -- needed for usb support
echo "deb maverick non-free" >> /etc/apt/sources.list
wget -q -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-3.2 ## usb support

Start VirtualBox and create a new machine. I kept most of the default configs, such as dynamic hard drive space. Then pop in my Windows XP cd and install.

This post shows how to do certain things with VirtualBox on Ubuntu.

Access files from Host machine

Start the machine, click on the “Devices” menu -> “Install Guest Additions”. Download the iso and install it on the Guest machine (should be automatically mounted; if not, click on on it under “Devices”).

On the host:

mkdir ~/VirtualBoxShare
## shutdown virtual machine
VBoxManage sharedfolder add "WinXP" -name "vqnportege-share" -hostpath /home/vinh/ ## "WinXP" is the name of my virtual machine, I'm making my home directory accessible on the guest machine, calling this path "vqnportege-share"
## start virtual machine
## on guest, Run -> cmd -> net use x: \vboxsvrvqnportege-share
## x drive should be accessible on the guest machine I can access files from my Linux home directory.

After installing Guest Additions, copy/paste for text between host and guest should work.

USB Support on PUEL version

Got the following here (for Ubuntu 10.10 Maverick):

sudo usermod -G vboxusers -a vinh

Restart host machine. Enable USB controller in for the windows machine (click settings in VirtualBox). After plugging usb device onto the host, click on the usb icon on the bottom of the virtual machine and select the device that you want to use in the guest machine. See this post for more details.

It’s that easy to set up a Windows virtual machine that is highly integrated with the host Linux machine.

Backup and Restore

According to this thread, you need to backup 3 files (“WinXP” is the name of the machine):

  1. ~/.VirtualBox/HardDisks/WinXP.dvi,
  2. ~/.VirtualBox/VirtualBox.xml, and
  3. ~/.VirtualBox/Machines/WinXP/WinXP.xml.

You can also “Take Snapshot” of the machine at a point in time. The file will be in ~/.VirtualBox/Machines/WinXP/Snapshots/{0001....}.vdi (this file analogous to the WinXP.dvi file).

To restore the virtual machine on a different system, place the files in the same path.

If you want to backup the machine and have it used in the same host machine (so two virtual machines that are identical), you will need to clone it to get a new id according to this post:

VBoxManage clonehd ~/.VirtualBox/HardDisks/WinXP.vdi ~/WinXP_Backup.vdi

Wish List

With VirtualBox, the user interface is a machine within a machine. I think with either VMWare and/or Parallels on Mac OS X (I saw on another person’s), each app window can be like a regular app’s window, ie, freely moving on the host’s desktop (not in a box). Also, you can access files between the two very seamlessly. The best part is file integration. If a file is set to open default by an app on the guest machine, then doubling clicking the file on the host will launch the virtual machine, open the app, and the file is opened. It is as if the the Windows apps were installed on the host machine. I don’t know if this is possible with VirtualBox or not yet. I’ll look more into this.