Turnkey Linux

I’m often asked what is my favorite open source project.  My favorite open source project is Turnkey Linux.  They make virtual appliances that are prebuilt and ready to run.  These are turnkey solutions using the best names in open source software.

Just to name a few…

  • WordPress
  • Joomla
  • Drupal
  • MediaWiki
  • MySQL
  • PostgreSQL
  • Zimbra
  • Bugzilla
  • phpBB

Their virtual appliances are easy to install and configure within a few minutes.  Whether you are looking for a solution for your enterprise or just wanting to dabble and “try-out” a new product,  you are only minutes away from your next open source solution.

If you are interested in building your own virtual appliance, why reinvent the wheel?  Turnky Linux has a Core and a LAMP appliance that you can start with and outfit the way you want.

Advertisements

Running VirtualBox Guest VMs In Headless Mode

If you are new to VirtualBox, you might not be aware that you can run your guest VMs without having a console window to them on your desktop.  IOW, run your guest VMs in the background and unseen.  This is called headless mode.  I’ll show you how to do that and a little more.

In headless mode, your guest VMs run in the background and you have the option to connect to them using the RDP protocol should you need a console to them.  This is great for uncluttering your desktop particularly if you run many guest VMs and you don’t care to see their console.  I have one server where I normally run at least five guest VMs at all times.  Headless mode is great when you need to log  into your host server remotely using ssh and start a guest VM.  This can be handy if you are on the road, away from your server.

Here is an example to demonstrate some common tasks.

Log into your host server using ssh.  Get a list of all VMs.

$ VBoxManage list vms

Start a guest VM named mywiki with RDP enabled and listening on port 3390.  If you plan to run multiple guest VMs in headless mode with RDP enabled, you will need to choose a unique port for each to listen on.  If you don’t specify a port, the default port is 3389.

$ nohup VBoxHeadless -s mywiki -v on -p 3390 &

Now if you want to check that your guest VM is among your running VMs

$ VBoxManage list runningvms

If you should need to connect to the console on that running VM named mywiki.  Lets assume it’s IP address is 192.168.139.10.  We are going to use rdesktop, which is a good RDP client found in most linux distros.

$ rdesktop -g 1024x768 -a 16 -5 192.168.139.10:3390 &

That should open up an nice 1024×768 window to your guest VM.  If the resolution 1024×768 is too big for you, then adjust the size to fit your needs.  The rdesktop settings “-a 16 -5” use a 16bit color depth and RDPv5.  Those settings work well for me and look good.

To view the properties of your VM use the showvminfo option.  This is handy if you want to connect your RDP client to a running VM and you don’t remember which port your VM is listening on.

$ VBoxManage showvminfo mywiki

Ok, now lets assume you have a rogue guest VM that want to shut-down and it is not responding to your request for a normal orderly shut-down.  You can power it off using VBoxManage.

$ VBoxManage contolvm mywiki poweroff

One of the things I love about VirtualBox is the amount of control you have from the cmdline.  Pretty much anything you can do from the management console can be done from the cmdline.  That is great especially if you enjoy writing scripts and want to automate some of these VirtualBox tasks.

Hopefully this will be enough to get you going.

Converting vmdk files to vdi using VBoxManage

Lets say you want to convert a VMware vmdk disk image to a VirtualBox vdi disk image.  It’s super easy. First let me mention that VirtualBox already supports vmdk files and can use them as is.  However lets continue with the original idea of converting.  I assume you already have VirtualBox installed.

If your vmdk image file is already connected to a guest VM.

  • shutdown the VM
  • remove the vmdk file from the guest VM (you can’t convert it while it is attached to a VM)

From the cmdline, use VBoxManage.   It’s a swiss army knife type of program.  You will see it used for a variety of things.

$ VBoxManage clonehd --format VDI myserver.vmdk \
/srv/d1/VirtualBox/HardDisks/myserver.vdi

That is all there is to it.

If you merely want to make a copy of a vdi disk image file, you can leave out the “–format VDI” option.  The vdi disk image files contain a UUID.  The clone process will make sure that the new output file has a different and unique UUID from the original.  If you use “cp” to make a copy of the vdi image file, you will find that the output file is unusable because it contains the same UUID as the original file.  A duplicate UUID is not acceptable to VirtualBox.

The Android emulator

Launching the emulator

In my previous post I demonstrated how to install the Android SDK, how to create a virtual Android device and how to install an Android application.  Once you have created an Android virtual device and named it, you don’t have to run the full SDK manager each time.  You can run your android device directly by starting just the emulator.   The emulator is another tool in the SDK.

First, lets add the tools folder from the android SDK to our $PATH for convenience.   Add the following to the end of your ~/.bashrc file.

export PATH=${PATH}:~/android-sdk-linux_86/tools

Run the emulator from the cmdline and give it the name of your saved Android virtual device.  If you remember from my previous post, I named mine fakeDroid.  Notice that you have to use the @ symbol with the name of your device.


$ . ~/.bashrc

$ emulator @fakeDroid

To make this even easier you can create a launcher on your Gnome desktop.  Right click on your Gnome desktop and select “Create Launcher…”.  For the command, put the full path to the emulator program and then the name of your saved Android device @fakeDroid.

That will create an icon on your desktop, that will launch your Android virtual device.

Creating SD cards

If you want to create virtual SD cards to use with your Android emulator, there is a tool for doing that called mksdcard.  The tool will create a blank FAT32 image file, that will emulate an SD memory stick.

The following command creates a 1GB SD card with a label “stick1”.


$ mksdcard -l stick1 1024M ~/sd_card_1G.img

You can copy files into your SD card by mounting it with the loop device.


$ sudo mount -oloop ./sd_card_1G.img /mnt

$ sudo mkdir /mnt/Pictures

$ sudo cp /opt/Pictures/*.jpg /mnt/Pictures

$ sudo umount /mnt

You can start your Android device with your SD card already mounted


$ emulator -sdcard ~/sd_card_1G.img @fakeDroid

One thing you may notice is the poor performance you get reading and writing the virtual SD card with your emulator.  You can boost performance dramatically by storing your SD image file in tmpfs.  I’ll demonstrate that in my next post.