This are my notes in the fields of computer science and technology. Everything is written with ABSOLUTE NO WARRANTY of fitness for any purpose. Of course, feel free to comment anything.

Sunday, September 13, 2009

My virtual linux server

In the windows installation on my laptop, I also run a linux server in background. Here is how I setup my virtual linux server.

As a virtualization software I installed Sun VirtualBox. I created a virtual machine. I gave it a little less than the half of my memory and turned on support for AMD-V extensions (as I did also in my host machine BIOS). As HD controller I selected SATA (the default is IDE). For networking I use the NAT configuration. I forwarded the SSH port as described in the virtual box manual (backlinux is the name of my virtual machine):
VBoxManage setextradata "backlinux" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "backlinux" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "backlinux" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
Then I followed the suggestion of Sebastian Bauer's blog: I installed the ntwind software's hidden start tool (homepage) and created two one-liner batch files that I use to start and stop the virtual machine. There are also more sofisticated approaches to run the machine as a windows service, however I found this very simple and I chose it for this reason.

Here is the start.bat file: (paths are specific to my machine)
"c:\Program Files\standalone\hstart\hstart" /NOCONSOLE ""c:\Program Files\Sun\VirtualBox\vboxheadless" -s backlinux -vrdp off"
while the stop.bat file contains:
"c:\Program Files\Sun\VirtualBox\VBoxManage.exe" controlvm backlinux savestate
I created two hard disk images for the machine, called backlinux.vdi and backlinux.home.vdi. I set both to dynamical 8 Gb. I later attached backlinux.home to /home. I keep /home on a separate disk, so that I can make use of the snapshots feature of Virtualbox, without loosing the data in /home. To do this I changed the type of backlinux.home.vdi to write-through using:
"c:\Program Files\Sun\VirtualBox\VBoxManage.exe" modifyhd backlinux.home.vdi --type writethrough
Then I installed ubuntu-server (jaunty, i.e. 9.04) with the option "minimal virtual machine" (press F4 by the installation) and I added some software packages I need/like using aptitude (for example: libncurses-dev, libcairo2-dev, ruby1.9, git-core, gitk ... and relative dependences). The machine has no x-server installed, but I have an X server installed under Windows (Xming), so I can start also graphical software using X-forwarding.

To allow the virtual machine to access the host disk (C:), I installed the VBoxLinuxGuestAdditions from the shell script in the virtual CD image (.iso) provided with virtual box (you need to install linux-headers package for your kernel for that). Then I created a shared folder "c" using the virtual box gui. In Linux then I mounted the folder, creating a /C folder, adding this line to /etc/fstab:
c    /C    vboxsf
As last step, I created two icons starting from NewTux.svg of Wikimedia Commons (author: Larry Ewing). I resized it to a 48px square and overlayed a green triangle (start icon) and a red square (stop icon). I created then links to my batch files to my desktop and assigned the icons to the links.

Here is the result:

VirtualBox

There are several available platform virtual machines available. I generally use the Sun VirtualBox. I usually run a Linux server in my Windows-running laptop, using a virtual hard disk for it and accessing it with PuTTY and WinSCP.

VirtualBox is able to run a virtual machine also without an output terminal/window (headless). I use this for my Linux server.

Another possibility it offers is to run a machine booting from a real partition instead of a virtual hard disk. However this makes things quite difficult and is an experimental feature. The hardware found by the operating system will be different in a virtual box and booting as host, so this will lead to several problems. For example I was unable to run a deployed Vista from Linux and I could only run a deployed Ubuntu in Windows with command line interface.

Developer: Sun
Version: 3.0.6 (September 9, 2009)
Platform: Cross-platform

PuTTY

A terminal emulator using ssh or telnet connections to remote servers. I always use this for ssh connections from a Windows machine to a Linux machine (usually using WinSCP for file exchanges) - including my virtual linux server I run in background.

In Windows the program settings (including the saved sessions) are stored in the registry at the position: Computer\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY .

Developer: Simon Thatam
Version: 0.60 (April 29, 2007)
Platform: cross-platform
License: open source

About Me

My photo
Hamburg, Hamburg, Germany
Former molecular biologist and web developer (Rails) and currently research scientist in bioinformatics.