Virtual Machines in Linux

Posted by John
on Sunday, 20 July 2008
Download VirtualBox

Download VirtualBox, binary link will redirect you to Sun's site.

Installing

For me, I needed to install libqt3-mt before I could successfully install the 64bit package,

sudo aptitude install libqt3-mt

Now Install your download with...

sudo dpkg -i virtualbox_1.6.2-31466_Ubuntu_hardy_amd64.deb

Further note, you may need to recompile the VirtualBox kernel module if a previous install failed or you didn't have the necessary dependencies first time; this is done by:

sudo /etc/init.d/vboxdrv setup
Permissions
  • Goto System / Administration / Users and Groups
  • Click 'Unlock'
  • Enter your password and click to 'Authenticate'
  • Click 'Manage Groups'
  • Find the 'vboxusers' group and click properties for it
  • Make sure there's a checkbox next to your name within that group, so you are part of the 'vboxusers' group

You will have to reboot your machine for the change to take effect.

USB Support

By default USB support is disabled, to enable it;

sudo nano /etc/init.d/mountdevsubfs.sh

Inside you'll find a block looking like;

# Magic to make /proc/bus/usb work
#
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount --rbind /dev/bus/usb /proc/bus/usb

Edit it to look like;

# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

(basically uncomment the last four lines)

Save changes and close the file (CTRL+X and Y)

Create a VM

Applications / System Tools / Sun xVM VirtualBox

Scroll down and click 'I Agree' on the licence agreement, then fill in the registration information to use VirtualBox, first time.

The rest is pretty self-explanatory if you've used other VM packages like OSX Parallels or Microsoft Virtual Machine.

  • Click 'New'
  • Enter a name for your VM, choose the target platform you're going to use it for
  • Choose Base Memory
  • Create a new Virtual Disk Image, click 'New'
  • Click 'Fixed Size' (for simplicity), 8GB should be enough for starters, you can choose 'Dynamic' which will grow or shrink the disk image based on usage
  • Click 'OK' then 'Finish' to build the Virtual Disk Image
  • Once the image has been created (may take 5+ minutes) it will show the new disk image in a listbox for selection, make sure it's selected and click 'Next' then 'Finish'

You now have a virtual machine ready for whichever ISO or CD-ROM install you wish to place on it. You can hit Machine / Settings / CD-ROM to select an ISO image to boot from so you can install from a disk image.

Note: Even if you're running on a 64bit machine, the virtual machines will still operate under a 686 (32bit) platform.

All the best,

(originally based on a guide from Ubuntu Geek)

Puppet - Setup / Test Notes

Posted by John
on Wednesday, 09 July 2008

'Put simply, Puppet is a system for automating system administration tasks'

Install

Depends on Ruby (at least 1.8.2), install with:

Client:

sudo aptitude install puppet facter

Server:

sudo aptitude install facter puppet puppetmaster

A Simple Manifest: Managing Ownership of a File

Step one: Create /etc/puppet/manifests/classes/sudo.pp
sudo nano /etc/puppet/manifests/classes/sudo.pp

class sudo {
    file { "/etc/sudoers":
        owner => "root",
        group => "root",
        mode  => 440,
    }
}
Step two: Create /etc/puppet/manifests/site.pp
sudo nano /etc/puppet/manifests/site.pp

import "classes/*"

node default {
    include sudo
}
Step three: Start the Puppetmaster
master % sudo puppetmasterd --mkusers

master % sudo /etc/init.d/puppetmaster restart  (for ubuntu / debian)
Step four: Run a client
client% sudo puppetd --verbose

master% sudo puppetca --list

master% sudo puppetca --sign <client>

Ubuntu Gets Firefox 3 Early?

Posted by John
on Friday, 13 June 2008

I'm probably wrong and everything, but last night I got an update of Firefox 3 thru the Synaptic package manager on Ubuntu Hardy and now it sort of looks like it's out early.

Firefox3

Any ideas?

Keeping track of resources with Monit

Posted by John
on Sunday, 08 June 2008

Another handy tool i've grown to like is Monit, which makes keeping tabs on memory-hungry processes much easier.

Basically once configured it helps keep an eye on particular process (e.g PostFix, PostGreSQL, Apache or your disk space). If one is starting to use too much memory, your running low on disk space or it's just no longer responding it can automatically restart it for you and alert you in the process; making system administration that little bit easier.

Installing

Install with Aptitude using,

sudo aptitude install Monit

After which it will tell you it's won't start until it's been configured,

Starting daemon monitor: -e monit won't be started/stopped
  unless it it's configured
  -e  please configure monit and then edit /etc/default/monit
  -e  and set the "startup" variable to 1 in order to allow
  -e  monit to start

Configuring

First make a backup copy of it's initial config, in case you need to rollback:

sudo cp /etc/monit/monitrc /etc/monit/monitrc.orig

Now edit it with:

sudo nano /etc/monit/monitrc
  • uncomment set daemon 120, so monit will run every two minutes.
  • uncomment set alert and enter the email address you want to use for email alerts.
  • uncomment include /etc/monit.d/* so it will read in all config files within that directory.
  • save and create the monit.d directory,

    sudo mkdir /etc/monit.d

By using a wildcard for that last config change you can build up separate .monitrc files for each service you want to monitor, making future modifications easier.

For example, monitor disk usage using:

sudo nano /etc/monit.d/system.monitrc

check system mysite.com
  if loadavg (1min) > 4 then alert
  if loadavg (5min) > 2 then alert
  if memory usage > 85% then alert

check device rootfs with path /dev/sda1
  if space usage > 85% then alert

Starting

After making your changes, check the syntax you used is correct with,

sudo monit -t

...if you uncommented the last line include /etc/monit.d/* and you've got no config files in there you'll get an error stating it can't find any config files there. don't worry too much about that, no need running it if you haven't got anything for it to do.

Now edit,

sudo nano /etc/default/monit

And change startup=0 to 1 to enable it, save the file and run,

sudo /etc/init.d/monit start

To start the service, stop it with,

sudo /etc/init.d/monit stop

...based partly on an example from Monit for Peace of Mind & Monitoring Ubuntu Services with Monit. More info at the official Monit site.

Plus a good example pastie here,

IE6 on Linux + Safari / WebKit

Posted by John
on Friday, 23 May 2008

webkit

IE 4 Linux

For cross-browser testing you can thankfully run IE6 (and 5/4) on Linux with the handy IE4Linux package.

Assuming you've got WINE you'll also need cabextract, so add a repository to your distro,

sudo gedit /etc/apt/sources.list
deb http://wine.budgetdedicated.com/apt hardy main

sudo aptitude update && sudo aptitude install cabextract

Installing IE6 on Linux is a little tricky, the best way i've found to get it working is doing;

su root
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

Click to create icon on Desktop, it'll run thru downloading packages and prefixes for Wine after which you should have IE on your Linux distro, which will be accessible (if you lose the desktop shortcut) from,

/root/bin/ie6
Safari / WebKit

Apple's Safari browser is powered by the WebKit rendering engine, which thankfully is an opensource project and can be installed and tested against on your Linux machine via a few steps (yep, i've run thru this and it does work).

First get the dependencies,

sudo aptitude install autoconf automake libtool bison flex 
gperf libicu-dev build-essential libxt-dev libsqlite3-dev 
libjpeg62-dev libpng12-dev libglibmm-2.4-dev libgtk2.0-dev 
libcurl4-openssl-dev libxslt1-dev

Now goto http://nightly.webkit.org/ and grab the latest nightly build.

Unzip and Terminal into the archive dir and build the source,

./autogen.sh
./configure --enable-svg-experimental
make

Once that's all done (which will take a while) you should now have a mini-WebKit browser in which to test against via...

./Programs/GtkLauncher

Navigate to the ACID3 website to test for standards compliance here http://acid3.acidtests.org/.

You should get 100/100, WebKit is pretty on when it comes to standards.

acid test