2007-03-20

Virtualization

Let’s face it : windows is still the best OS for doing pretty cheap/bad things in the minimum amount of effort (non exhaustive list : printing document on a un-collaborative shared printer, making a presentation (Powerpoint rules !), and so on.) Nonetheless, when it comes to serious computing you’ll want a real partner ! Someone you had faith in, like a unix/linux box ! You can do it a) with efficiency b) with panache


A) The vmware approach ( some variation might reside on the dark side of the legal frontier)

- Solution 1 (maximal efficiency - require a registration step):

Tools of the trade (I had to stop reading hacker’s stories):
vmware player (free) :
http://www.vmware.com/products/player/
vmware workstation (evaluation copy) : http://www.vmware.com/download/ws/ and http://www.vmware.com/download/ws/eval.html
Note: currently there is the beta 6 out there for testing purpose here : http://register.vmware.com/content/beta/ws/registration.html

Your unix/linux installation cd

Here are the process for a Debian Sarge (Note : I had to choose the default 2.4 kernel to install vmtool or I had to cope with compilation pb - and no time to solve them.)

Step a. install workstation, create a new virtual guest (at least 256Mo of RAM) with bridged network if your on a lan with a dhcp server somewhere or nat if you want a stealth mode :). Choose a adequate storage space you can not alter it afterward (3-4 Go for a functional debian). Fortunately, vmware is smart enough to adapt the size of the corresponding file to what is really needed.

Step b. insert the install cd

Step c. boot your new guest and follow the installation process. Install the kernel headers (if you do this after this step use : apt-get install kernel-headers-`uname -r`).

Step d. install X. choose the vmware drivers for the screen. The mouse is an ibm/ps2 (/dev/psaux). Choose 24 bits 1280x1024 and lower resolutions. Here is a sample of my X11 configuration file prior to vmtools:

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "keyboard"
Option "CoreKeyboard"
Option "XkbRules" "xfree86"
Option "XkbModel" "pc105"
Option "XkbLayout" "fr"

EndSection
Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "Emulate3Buttons" "true"
Option "ZAxisMapping" "4 5"

EndSection
Section "Device"
Identifier "VMWare Inc [VMWare SVGA II] PCI Display Adapter"
Driver "vmware"

EndSection
Section "Monitor"
Identifier "Écran générique"
HorizSync 28-50
VertRefresh 43-75
Option "DPMS"
EndSection
Section
"Screen"

SubSection "Display"
Depth 24
Modes "1280x1024" "800x600" "640x480"
EndSubSection

Step e. once the installation is complete, choose to install vmtools (this option is available in one of the menu. Once actuve it create a CD) [it improves the graphic performance and so on. It is not mandatory but it’s way cool !) See http://www.vmware.com/support/ws55/doc/new_guest_tools_ws.html for additional détails. Mount the CD; find the vmtoolsxxx.tar.gz; gunzip; untar; launch the installer. It will compile vmtools for your kernel. A sample of X11 post installation:

Section "Monitor"
Identifier "Écran générique"
HorizSync 1-10000
VertRefresh 1-10000
Option "DPMS"
ModeLine "800x600" 100 800 900 1000 1100 600 700 800 900
ModeLine "1280x768" 100 1024 1100 1200 1300 768 800 900 1000
# ModeLine "1280x1024" 100 1280 1300 1400 1500 800 900 1000 1100
ModeLine "1280x1024" 135 1280 1312 1416 1664 1024 1027 1030 1064
ModeLine "1600x1200" 100 1600 1700 1800 1900 1050 1100 1200 1300
EndSection

Use the rest of your evaluation period to install other guests OS :)

Step f. When your done uninstall workstation and install vwmplayer instead.

Job complete !

The only purposes of the workstation was to a) create all the file requested to install the guest OS b) provide vmtools. Solution 2 get rid of a). Note : it seems that keeping vmtools after step f is legal (I’ve read somewhere that vmtools comes from vmware server which if freely available). . .

- Solution 2:

Tools of the trade:

Qemu : “a generic open source machine emulator and virtualizer” http://fabrice.bellard.free.fr/qemu/
Qemu Accelerator module : same url
vmtools (if you consider that keeping it when using the player is legal) : http://taltan.free.fr/index/2007/02/06/61-vmware-tool-toujours-sur-la-main
vmplayer

The goal is to build all the files needed by vmplayer without workstation. The process comes form i) http://johnbokma.com/mexit/2005/10/26/vmware-player-windows-xp.html, ii) http://cri.ch/linux/docs/sk0020.html, iii) http://www.hackaday.com/2005/10/24/how-to-vmware-player-modification

Step a. create a storage file with qemu :
qemu-img.exe create -f vmdk .vmdk 4G

Step b. Create a file .vmk like this one :
config.version = "8"
virtualHW.version = "3"
#scsi0.present = "TRUE"
ide0:0.present = "TRUE"
ide0:0.filename = "Rheas.vmdk"
memsize = "256"
MemAllowAutoScaleDown = "FALSE"
#scsi0:0.present = "TRUE"
#scsi0:0.fileName = "Rheas.vmdk"
ide1:0.present = "TRUE"
ide1:0.fileName = "D:\Tmp\master.rheas3.0.iso"

ide1:0.deviceType = "cdrom-image"
#ide1 :0.fileName= "auto detect"
#ide1:0.deviceType = "cdrom-raw"
#ide1:0.autodetect = "TRUE"

floppy0.present = "FALSE"
ethernet0.present = "TRUE"
usb.present = "TRUE"
sound.present = "TRUE"
sound.virtualDev = "es1371"
sound.fileName = "-1"
sound.autodetect = "TRUE"
displayName = "RedHat2004"
guestOS = "other24xlinux"
nvram = "Other Linux 2.4.x kernel.nvram"
scsi0:0.redo = ""
ethernet0.addressType = "generated"
uuid.location = "56 4d 9e 34 6d 2f 6b 75-1f be 02 0c 1b a0 e2 7d"
uuid.bios = "56 4d 9e 34 6d 2f 6b 75-1f be 02 0c 1b a0 e2 7d"
ide1:0.autodetect = "TRUE"
tools.remindInstall = "TRUE"
ethernet0.generatedAddress = "00:0c:29:a0:e2:7d"
ethernet0.generatedAddressOffset = "0"
ide1:0.startConnected = "TRUE"
tools.syncTime = "FALSE"
ethernet0.connectionType = "bridged"
checkpoint.vmState = "Other Linux 2.4.x kernel.vmss"
ide0:0.redo = ""

Pay attention to

a)the ide1:0 if you want to install your OS from an ISO or from an real CD.
b)the guestOS must belong to the list describe in ii) but I suspect that this info is not utterly important.

Next steps. follow solution 1

B) The free way : qemu

Qemu : “a generic open source machine emulator and virtualizer” http://fabrice.bellard.free.fr/qemu/
Qemu Accelerator module : same url

Step a. Install both qemu and the accelerator (download the source package and execute the .inf)

Step b. enable the accelerator with the command : net start kqemu

Step c. create a storage file

qemu-img create –f qcow .img G

Step b. Launch qemu

qemu.exe -L . -cdrom "\\.\F:" -hda debian_sarge.img -m 256 -boot d -net nic -net user -redir tcp:5555:10.0.2.15:80 -redir tcp:5556:10.0.2.15:8080

This command tells qemu to boot with the cdrom (you can also specify an iso file) and redirect all the outgoing connections for port 80 and 8080. This way you’ll be able to download all the requested files during installation and surf the web after that ! 10.0.2.15 is the default ip returned by the qemu dhcp server. (Note : I use 8080 since I’m behind an http proxy which is listening to incoming connections on this port)

Step c. If you have to reboot from the hard drive you should stop qemu, and change the -boot parameter from d to c (you can keep the cdrom image if you had to).

Step d. Configure X11. Use the PS/2 with /dev/psaux for the mouse and the cirrus driver for the video (screen : Hsync 30-70 Vrefresh 50-160 option DPMS) I tried 1280x960 but I think I’m stuck with 800x600.

A brief note:

I had to admit that I prefer vmplayer due to it’s flexibility and ease of use:
- the 1280x1024 screen,
- switch full screen with ctrl/alt/return (I don’t remember how but it is possible to make the upper toolbar dockable… the trick is to switch to full screen then find the key combination (like CTRL+ALT) to call the host OS pointer but not exiting the full screen mode ! Then click on the pushpin … that’s all !
- access your usb pen with one click+mount and it’s done

and so on.

Final advice n°1: do not forget to set up a samba client with a windows shared folder (setting a server might look better but do not forget all the possible windows’ delay when the OS try to access your directory and your virtual machine is off (like when you configure an auto-connect shared folder)).

Final advice n°2: do not forget to alter the smb.conf ! Particularly:

domain master = no
local master = no
preferred master = no

I forgot this step and saw 2 sys admins came into my office searching for the owner of the station who continually usurp the domain master browser :(