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:

No comments:

About Me

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