Install Gentoo Linux on VMWare Player on Windows XP

(Update: Actually, there is no point setting up QEmu, playing around with VMX file, etc to try to bootstrap the disk image. There is actually no point getting VMWare Player. Just go an install the free VMWare Server -- it is so much better.)

Me. I am stuck. On Windows.

Well, not really by choice. My work relies on running Windows XP Professional on this Dell laptop. It runs a few important applications that I need (Internet Explorer, Outlook), and the user interface is "reasonable" in classic mode.

However, I also would like to run Linux on the lappy, as all my tool chains for work were coded for posix environment. With the things I do, I find myself doing faster on command-lines. The shared Linux boxes at work were overloaded by the developers (no one seem to like working on Windows), and cygwin just does not feel like the "real thing".

VMWare Inc released its free VMWare Player last week. It provides ability to run a guest operating system inside another OS, which would be perfect for my needs -- running Linux inside a virtual machine, on top of my existing Windows XP system.

And here is my guide on how to get it working.

Installing Gentoo Linux on VMWare running on Windows

Problem

You cannot use VMWare Player to create virtual machine images -- VMWare requires you to get their Workstation or Server version to do that. It can be overcome by downloading an existing VM, and then re-install it with the OS of your choice. Or alternatively, use QEMU to create VM images in VMWare's virtual disk file format.

Operating Systems

My host operating system is Microsoft Windows XP SP2. Installed by techies at work, and I don't even have Administrator password for it. It is running on a Dell Latitude D600 notebook with 1Gb of RAM and 60Gb on IDE0.

I chose Gentoo Linux as my guest operating system. It is the operating system I use on this server box. It is very versatile, easy to upgrade, has huge number of packages, very well supported and Gentoo just gives you that "cool" factor. Doesn't real man compile his operating system?

At the same time, Gentoo might not be the best choice for a VMWare guest OS, as a simple emerge world inside the virtual machine is going to put heavy tax on the CPU. I will recommend Ubuntu Linux if compiling the OS is not your thing.

We are also assuming the guest OS will be installed on "C:\linux\gentoo.vmdk", where the VMWare configuration file will be called "C:\linux\gentoo.vmx".

Downloads

Get these ready before starting out.

  • VMWare Player
  • QEMU -- we actually just need qemu-img.exe to create the VM image.
  • Gentoo Linux -- you will need:
    • /releases/x86/2005.1/installcd/install-x86-minimal-2005.1.iso -- LiveCD to boot the VM into Gentoo Linux.
    • /releases/x86/2005.1/stages/i686/stage3-i686-2005.1.tar.bz2 -- Stage 3 to bootstrap installation.

Installation

  1. Install both VMWare Player and QEMU. You will need to restart Windows afterwards.

  2. Assuming you have installed QEMU in "C:\Program Files\QEMU", fire the following command inside a Windows console to create the virtual machine image allocating 10Gb of space:

    C:\> "C:\Program Files\Qemu\qemu-img.exe" create -f vmdk c:\linux\gentoo.vmdk 10G
    Formating 'c:\linux\gentoo.vmdk', fmt=vmdk, size=10485760 kB
    C:\>
    

    It actually does not create a 10Gb file in that directory, as space will only be allocated when needed. So it might be wise to create something a bit bigger, depending on your need.

  3. Create a virtual machine configuration file (using notepad.exe will do), and save it as "C:\linux\gentoo.vmx":

    config.version = "8"
    virtualHW.version = "4"
    memsize = "256"
    ide0:0.present = "TRUE"
    ide0:0.fileName = "c:\linux\gentoo.vmdk"
    ide1:0.present = "TRUE"
    ide1:0.fileName = "c:\linux\install-x86-minimal-2005.1.iso"
    ide1:0.deviceType = "cdrom-image"
    ethernet0.present = "TRUE"
    ethernet0.connectionType = "nat"
    usb.present = "TRUE"
    sound.present = "TRUE"
    sound.virtualDev = "es1371"
    displayName = "Gentoo Linux"
    guestOS = "other26xlinux"
    nvram = "gentoo.nvram"
    scsi0:0.redo = ""
    ethernet0.addressType = "generated"
    uuid.location = "56 4d d9 96 08 47 ef ee-bf f2 48 a8 ce 89 7f 68"
    uuid.bios = "56 4d d9 96 08 47 ef ee-bf f2 48 a8 ce 89 7f 68"
    ide1:0.autodetect = "TRUE"
    ethernet0.generatedAddress = "00:0c:29:89:7f:68"
    ethernet0.generatedAddressOffset = "0"
    checkpoint.vmState = "gentoo.vmss"
    tools.remindInstall = "TRUE"
    ide0:0.redo = ""
    

    You should also save Gentoo Linux's LiveCD ISO image inside C:\linux (referred by ide1:0.fileName in the configuration file). Now it is almost ready to go!

  4. Double click on the VMX file. Windows might prompt you, asking which application it should use to open the VMX files. Associate that with VMWare Player. VMWare might ask you about the UUID -- just create a new one as it is a new image. You'll then see the virtual machine POSTs, booting off the CD, and eventually give you a root prompt!

    Now, you can just install Gentoo Linux like installing it on any other PC's. Preparing the disk (it would be /dev/hda), unpacking the installation stage tarball, chroot, and start emerge sync && emerge system!!

Well, I know this installation guide is sort of incomplete, as it stops at the stage where the OS is not even on the partition. I guess the important part is just documenting the hack using qemu-img.exe to create virtual machine image, and Linux is now ready to be installed inside this prepared VM. However, if you have not installed Gentoo Linux before, I will recommend their quick installation guide which contains almost everything you need to get bootstrapped (if you already know Linux). There are other documentations on Gentoo's website worth checking out.

Frequently Asked Questions

Err. Actually, no one has asked any question yet. However I will just share some notes here in a dialogue manner.

Q: How do I copy the stage 3 tarball onto a running virtual machine?

A: Although the minimal LiveCD has smbfs included as kernel module, I could not seem to mount my Windows share. You can however,

  • Use wget inside the VM to pull the tarball from Gentoo mirrors, or
  • Start sshd,
    livecd root # /etc/init.d/sshd start
    
    And then use scp to copy the tarball over.

I am sure there are plenty of ways, but these are the two I used.

Q: Is there an easier way?

A: Apparently you can just download the VMWare Workstation evaluation version, create as many images you want (you really only need 1 if you are running Gentoo) within its 30 days evaluation period, and then use VMWare Player to run those images afterwards.

I should have done that. Doh.

Elsewhere on the Net

To be Continued...

Yeah. I will try to clean up this post, after emerge has finished...