A Lubuntu LAMP VM

I wrote previously about the pre-made OpenSUSE 10.2 LAMP Server for Windows Virtual PC and it has been helpful in brushing up on command line Linux with a LAMP stack. After playing around it dawned on me that if I had a virtual LAMP server with a more recent version of PHP I could have a development mirror of this WordPress blog. So starting with the Lubuntu VM I created I’ve added a LAMP solution stack and a cloned copy of this blog.

Installing the LAMP Stack

Most of the pages I found about installing a LAMP stack on Lubuntu where very old (in Linux years) so they had far more steps than necessary. The fastest way I found was in a Comment on the Installing LAMP On Ubuntu For Newbies page.

Its really easy to install LAMP with ONE single command in ubuntu:

sudo apt-get install lamp-server^ phpmyadmin

When the installation nears the end you’ll be prompted to do these steps. Continue reading “A Lubuntu LAMP VM”

Compacting a Linux VHD

When you compact a Linux dynamic virtual disk in Windows Virtual PC you’ll find that almost no space is saved. This is because the compact routine only compacts disk area that is filled with zeros. For Windows guest OS’s Microsoft provides a Precompactor tool that zeroes out the unused space so that compaction works.

I thought I’d found a solution in  Ben Armstrong’s MSDN Blog, Compacting the virtual hard disk of a Linux virtual machine. You run the following command, turn off the VM and then run the Compact virtual hard disk function.

cat /dev/zero > zero.dat ; sync ; sleep 1 ; sync ; rm zero.dat

It didn’t work for me then I thought, probably needs a sudo before the commands but that didn’t seem to work either. Searching around the net I found many sites suggesting the same or similar commands and others suggesting dd to do the job. After reading a lot of information I came to the conclusion that these methods are more of a hack than an elegant solution and there are quite a few technical reasons why they are sub-optimal.

That’s when I learned about the zerofree program for Linux from Ron Yorston. Read about this nice utility at his Keeping filesystem images sparse page.

Searching for use case examples for zerofree yielded many different recommendations most of which involved what seemed like unnecessary complications. These include installing zerofree on the system you want to run it, restarting in single user mode and remounting the file system read-only to run it.

Then I saw some sites saying to run zerofree from a Linux live CD and that struck me as the smartest and fastest way to do this process. The SystemRescueCd, a great live CD that I’ve used before, includes zerofree and nearly every other Linux disk utility there is.

Here is the process I came up with that is fast and really shrinks your Linux virtual hard disk.

  1. Shut down the virtual machine and if you have the undo disk feature enabled apply or discard the changes and then disable the feature.
  2. Backup the VHD file because low level manipulation of the disk file system could break it.
  3. Boot the virtual machine from the SystemRescueCd ISO.
  4. Check the file system before zeroing it out.
    fsck /dev/sda1
  5. Zero out the file system, it took 13 minutes to complete on my VHD.
    zerofree -v /dev/sda1
  6. Check the file system after zeroing it out.
    fsck /dev/sda1
  7. Shut down the VM.
    poweroff
  8. Compact the VHD, Settings -> Hard Disk 1 -> Modify button -> Compact virtual hard disk button and remove the ISO from the DVD Drive setting.

That’s all there is to it, I think this is by far the fastest and easiest way of getting this done.

A Virtual Puppy Named Slacko

I first played around with Puppy Linux about eight years ago to extend the useful life of an old PC for relatives. With Puppy’s low PC resource requirements and my previous experience it was a natural choice for my second distro to run in WVPC. In addition to getting Slacko Puppy running in WVPC I also wanted to have it on a USB thumb drive to use for rescue operations on other PCs. Since most PCs I deal with currently are fairly new I chose to use the PAE version of Slacko. Before I dig into the WVPC implementation a quick note on the standard usage of Slacko Puppy. Read the release notes before you start! I did not do this and it cost me about a half hour of head scratching trying to get my main workstation to boot on the CD (it needed the radeon.modeset=0 boot option).

If you don’t want to roll your own virtual machine you can can download an archive containing the virtual disk and settings files. Simply extract the files to your virtual machines folder (usually C:UsersxxxxxxAppDataLocalMicrosoftWindows Virtual PCVirtual Machines where xxxxxx is your user name) and then run the VM. The archive, Slacko_Puppy_5_6_0_PAE.7z, contains Slacko_Puppy_5_6_0_PAE.7z.vmc (settings) and Slacko_Puppy_5_6_0_PAE.7z.vhd (virtual disk).

Continue reading “A Virtual Puppy Named Slacko”

Lubuntu on Windows Virtual PC

For my second Linux distro to try out in Windows 7 Virtual PC I wanted to try an X-Windows based desktop distro. I chose Lubuntu for two reasons, it is very lightweight and I am somewhat familiar with recent Ubuntu installations.

Searching around the web I found that many people never get X-Windows running at greater than 800×600 resolution. There also appears to have been a problem with using 24bit color on earlier versions of Virtual PC. Having done quick test installs for a few different distros I found that X installs on WVPC end up at 800x600x24 and run OK. For my usage 800×600 is just too small and 24 bit color is not needed (I don’t expect to watch video or view/edit images in a VM). So I’ve set a target of getting X to run at 1024x768x16 for all desktop client distros that I’ll use. The larger screen size makes it practical to use multiple windows for finding solutions on the web and copying text from the web browser to a terminal or text editor to save on typing.

Another common problem I see people having is getting the middle mouse button (X button 2) and scroll wheel (X buttons 4 & 5) to work. Scrolling with the wheel and opening new Firefox tabs with a middle button click have become essential to me so this is the other major target for all my VMs. Unless I can get the mouse wheel/button and 1024×768 working I won’t consider a distro to be functional for me in WVPC.

The final problem I’ve seen many web sites mention is the use of dynamic virtual disks. A dynamic disk saves space on your host PC by keeping the file small while still allowing it to grow as needed. Most sites say to only use the fixed disk type in VPC however these sites are working with older versions of VPC, not WVPC, and older distros. The first VM I documented using was created with a dynamic disk and all of the VMs I’ve created myself work fine using a dynamic disk. I suspect the problem no longer applies to recent distros/kernels and WVPC. I did find one case where a dynamic disk did not work, I tried to expand the size of the Q&D LAMP VM by creating a larger virtual disk and using Clonezilla to copy the old disk into the new one. Clonezilla said it worked but when I looked at the size of the new dynamic disk it was clear it hadn’t worked. In that situation I had to use a fixed size virtual disk to make the cloning work.

The rest of this post is primarily a description of the steps I took to get Lubuntu 13.10 running in Windows Virtual PC. If you don’t want to perform these steps yourself you can download an archive containing the virtual disk and settings files. Simply extract the files to your virtual machines folder (usually C:UsersxxxxxxAppDataLocalMicrosoftWindows Virtual PCVirtual Machines where xxxxxx is your user name) and then run the VM. The archive, Lubuntu_13_1_upd8.7z, contains Lubuntu_13_1_upd8.vmc (settings) and Lubuntu_13_1_upd8.vhd (virtual disk). For this pre-made VHD I used these settings for names and password:  Name: W7VPC, PC Name: w7vpc-Virtual-Machine, Username: w7vpc, Password: w7vpc2014, and set it to Log in automatically.

Continue reading “Lubuntu on Windows Virtual PC”

A LAMP Server for Windows Virtual PC

My first Linux VM was a very easy one to setup because the setup had already been done. It’s a  Downloadable Quick & Dirty LAMP Server from Tim Wray.

While it works to simply extract out the settings and virtual hard drive files and run the VM, I noticed that the setting XML file is substantially different for Windows Virtual PC than it was for Microsoft Virtual PC 2007. This includes the amount of video RAM so I decided to create a new settings file and, with Tim’s great instructions on how to fix the one problem that crops up, it is painless. The following instructions assume you know how to use basic Linux commands as well as the openSUSE text mode Yast configuration program.

  1. Extract the OpenSUSE 10.2 LAMP Server (PHP 5.2.11 MySQL 5).vhd file to the location for your installation. Should be C:UsersxxxxxxAppDataLocalMicrosoftWindows Virtual PCVirtual Machines where xxxxxx is your user name.
  2. Open Windows Virtual PC.
    Capture00
    Continue reading “A LAMP Server for Windows Virtual PC”

Linux as a Guest OS in Windows Virtual PC

To be absolutely clear what I’ll be writing about in this and future posts is the Windows 7 Pro (and higher) add-on Windows Virtual PC (WVPC). It is a descendant of the general purpose Microsoft Virtual PC but is different in that it was modified specifically to facilitate the Win7 XP Mode feature. Basically Microsoft intends WVPC to allow the running of XP, Vista and Windows 7 guests on a Windows 7 host, they do not support any other guest OSs. However they did not remove the capability to run other OSs they simply did not update some useful features for other OSs and they removed the integration components for Windows versions older than XP.

Getting any Linux distro setup on WVPC is not something the average user should attempt. If you want to try out different Linux distros and have all their features work you should definitely use different virtualization software. VirtualBox and VMWare are much easier to use and will let you properly evaluate distros.

I decided to play around with Linux on WVPC for a number of reasons.

  1. I already use it for XP Mode and when an app is running it isn’t obvious that VPC is running. If I had another virtualization platform installed I could accidentally run it at the same time which could crash Windows badly. So to be safe only VPC will ever be installed on my Win7 PC.
  2. I occasionally need to run software that is only available on Linux e.g. the libpst library
  3. Having played around with Linux on and off since 1998 I actually find it fun to dig into the OS guts to get it working on unsupported hardware. I still remember the thrill of compiling a newer version of the kernel for the first time and it making a new system work.

In later posts I’ll detail how I got specific distros running but for now I just want to cover a few generic tips. The first tip is don’t expect to find a lot of useful information on the net. Most discussion threads about this topic quickly end with the person asking for help being convinced to give up and just use VirtualBox or VMWare. Most of the blog posts you’ll see are for Microsoft Virtual PC 2004 or 2007, products that officially supported Linux as a guest OS so they often are not applicable to WVPC.

Tip number two is lower your expectations, don’t expect to run X-Windows in high resolution, watch video or listen to music. Much of the problem stems from the fact that there are no integration components supplied for newer Linux distros. If you look in  “C:\Program Files\Microsoft Virtual Server\Virtual Machine Additions” you’ll see that the old additions for Linux are there but since they have not been updated since 2007 they are basically useless.

The third tip is to expect that you will need to add kernel boot parameters to get any install going reliably and then you may need to manually add some of them to the GRUB configuration after a successful install. In my playing around so far I have found that noreplace-paravirt, i8042.noloop and clocksource=pit (clock=pit for older kernels) are the minimum. In some cases you may also need a vga=788 option as well. There is an old blog post from 2009 that explains the first options fairly well. In addition to what is said in that old post about the clocksource option, Ben Armstrong of Microsoft posted in 2006 about how the clock option prevents a key repeat problem. For even greater detail on the clocksource option read this Microsoft Knowledge Base article.

The next tip is only if you are a die hard numeric keypad user like me. I hate when Num Lock gets turned off, an accountant at work showed me how much more efficient data entry is with the keypad way back in the 1980s. After all this time my hand instantly goes to the keypad anytime I’m entering more than a couple digits so I find I just can’t live without it. To ensure the Num Lock stays on you have to set the VM BIOS option and usually set it in the OS as well. To set the BIOS option, press the Delete key as soon as the VM window opens to access the VM BIOS settings. Change the Advanced-Boot Setting Configuration-Bootup Num-Lock setting to On. Then press F10 to save and exit the BIOS settings.

Capture04

A final note on Num Lock, some guest OSs will toggle Num Lock on/off during the boot process. If the VM window looses focus during this time the Num Lock state may end up set incorrectly.

The last tip is about WVPC video RAM, the default setting when you create a new VM is 16 meg, the maximum supported, but it can be decreased by manually editing the XML file if you wish to save on host RAM. Although the VM has 16M, so far I’ve found that the amount detected by Linux is never 16MB. Some query mechanisms have returned 64M but all the ones that count always seem to detect only 4MB. I suspect the only way to resolve this would be to write a custom display driver, a task that presently I don’t think is worth the effort.