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.

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  We are going to use rdesktop, which is a good RDP client found in most linux distros.

$ rdesktop -g 1024x768 -a 16 -5 &

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.

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.

Running Android Apps on your linux box

So you want run Android applications on your linux box.  Basically you’ll need three things.  The Android SDK, Java JRE, and 32bit libraries.  If your server is already a 32bit server then you already have 32bit libraries installed.  If you server is a 64bit server then you will need to install the 32bit execution libraries, for Ubuntu that is the  ia32-libs package.

$ sudo apt-get install openjdk-6-jre

$ sudo apt-get install ia32-libs

Download the Android SDK from developer.android.com

Extract and run the Android SDK.

$ tar -zxvf android-sdk_r06-linux_86.tgz

$ cd android-sdk-linux_86

$ cd tools

$ ./android &

Click on “Installed Packages” to update your tools and APIs.  Click the “Update All…” button.

I am going to select the “Android 2.2, API 8” and click Install.  This will download and install several packages.

When it finishes downloading and installing the additional packages, you should see something like the following.

Now lets create a virtual Android device.  Select “Virtual Devices” and click the “New…” button.

Select a name for your Android device.  I chose fakeDroid.  Select an API level, SD card size, and a Skin (screen size).  The Hardware section, lets you outfit your Android with various features.  I’m going to select the following:

  • SD Card support
  • GPS support
  • Accelerometer
  • DPad support
  • Touchscreen support
  • Audo playback support

Then click “Create AVD”.

This will create a virtual android device for you.  You can select your virtual device and click the Start button.

Your virtual Android will then power-on and begin botting.  When it finishes booting you should see something like the following.

Now lets install an Android application.  Click on the button that looks like a globe to start the android web browser.  You should see a web browser like the following.

Enter the URL:  http://www.androidfreeware.org

To zoom in you can double click on the Android touchscreen.  You can pan the display by using your mouse pointer to “drag” the touchscreen.  I’m going to install the application PicSay, but you can choose whatever application you want.  You install android applications by downloading the android package files with .apk extension.   You should see a link for downloading the file.

After the download begins, click and drag downward on the top menu bar.  This is where android keeps its notifications.  Soon, you should see that the download has completed.

Click on the downloaded file and it will open the installer program for that application.  Click the Install button.

When the application finishes installing, you can click the home button to go back to your Android home page.  Then click the touch screen button which looks like a grid.  That is the launcher button.  It takes you to the screen where you can launch applications.  You should see the icon for your newly installed application (PicSay).

To start the PicSay application, click its icon.   We are done here.

Have fun experimenting with the android SDK.

Part II: VirtualBox is giving me friction about my AMD-V

This is an update to an earlier post.  In a previous post, I talked about an issue where after upgrading VirtualBox it was no longer able to run 64bit guests, on some motherboards with AMD-V capable cpus.

After digging a little more,  It seems that having the kernel modules kvm and kvm_amd loaded while running VirtualBox was causing the issue.  The presence of those two modules is causing VirtualBox to wrongly see svm as not enabled.

If you are not using kvm and kvm_amd for other things, you can blacklist those two modules to prevent them from loading.  Here is how you do that.  Create a new blacklist .conf file in the /etc/modprobe.d folder.  Then add a line to blacklist those two modules.

$ echo -e  "blacklist kvm\nblacklist kvm_amd" | sudo tee /etc/modprobe.d/blacklist-kvm.conf

Then reboot.

Before starting your guests after the reboot, first you’ll have to recompile your VirtualBox drivers.  You must do that as root.

$ sudo /etc/init.d/vboxdrv  setup
 * Stopping VirtualBox kernel module
 *  done.
 * Removing old VirtualBox netadp kernel module
 *  done.
 * Removing old VirtualBox netflt kernel module
 *  done.
 * Removing old VirtualBox kernel module
 *  done.
 * Recompiling VirtualBox kernel module
 *  done.
 * Starting VirtualBox kernel module
 *  done.

Your 64bit guests should start and run without issue as they were meant to do.   If not then make sure that you didn’t make a typo along the way.  Then verify that the two kvm modules are not loaded.  If you still can’t get it work, remember that the workaround from the previous post still works wells.

VirtualBox giving me friction about AMD-V

This is more than a little annoying.  After upgrading my VirtualBox to version 3.1.6, it now decides that my cpu’s AMD-V is not operational.  Everything was fine previously, everyone played nice together.  Now it refuses to start my 64bit guests.

VirtualBox VT-x/AMD-V Error Message

VirtualBox VT-x/AMD-V error message after upgrading

After spending some times googling for a solution or a workaround, I think I have found an acceptable workaround.

Thanks to this link.

From what I have read, previous versions of VirtualBox ignored the VT-x/AMD-V setting on my motherboard.

I had two servers which were affected.

  Motherboard: Biostar TA790GX A2+
  CPU: AMD Phenom X4
  OS: Fedora 12
  Bios: Virtualization Enabled
  Motherboard: ASUS M3A78-EM
  CPU: AMD Athlon II X2 250
  OS: Ubuntu 9.10
  Bios: Virtualization Enabled

The workaround that I have found involves setting the following environment variable.


So I appended the following to my  /etc/profile.


I logged out and logged in again and now things appear to be fixed.  I am able to start and run my 64bit guests again.

UPDATE 05/08/2010:  Part II: VirtualBox is giving me friction about AMD-V