Howto: Resize Xen Loop Disk Image

Win4lin, KVM, QEMU, Virtualbox and Xen are all widely used technologies, used in virtual servers. Fairly often a virtual server run from within a loop filesystem and generally start with a fairly small file (1GB is big for a normal file, but not when it is pretending to be an entire filesystem!)

However things often grow over time.

Here is a nice simple procedure for increasing the size of a loop filesystem, if the filesystem is ext2 or ext3 (the procedure should work for ext4 too, but I havn’t tested it yet)

1. Stop the virtual server that is using the loop filesystem
2. Add some extra space to your loop filesystem file
# dd if=/dev/zero bs=1024k count=1024 >> loop_image_file

This adds 1GB to the end of a file called loop_image_file (make sure to use the append output redirector >> not a single >, otherwise you’ll have an empty 1GB file!)

3. Force a check on the resized/increased filesystem
# e2fsck -f loop_image_file

4. Resize the filesystem within the loop filesystem file
# resize2fs loop_image_file

5. Start the virtual server again

Comments off

Howto: Office 2007 on Linux with Wine

Microsoft Office 2007 is the most recent Windows version of the Microsoft Office system, Microsoft’s productivity suite. Formerly known as Office 12 in the initial stages of its beta cycle, it was released to volume license customers on November 30, 2006 and made available to retail customers on January 30, 2007.

New Features in Office 2007
Office 2007 contains a number of new features, the most notable of which is the entirely new graphical user interface called the Fluent User Interface (initially referred to as the Ribbon UI), replacing the menus and toolbars that have been the cornerstone of Office since its inception with a tabbed toolbar, known as the Ribbon. Office 2007 requires Windows XP with Service Pack 2 or 3, Windows Server 2003 with Service Pack 1 or higher, or Windows Vista.

The ‘Ribbon User Interface’ is a task-orientated Graphical User Interface (GUI). It features a central menu button, widely known as the ‘Office Button’. The Ribbon Interface has been rumored to be introduced into Microsoft Office 14.

The new user interface (UI), officially known as Microsoft Office Fluent, has been implemented in the core Microsoft Office applications: Word, Excel, PowerPoint, Access, and in the item inspector used to create or edit individual items in Outlook. These applications have been selected for the UI overhaul because they center around document authoring. The rest of the applications in the suite will also be upgraded to the new UI in subsequent versions. The default font used in this edition is Calibri. Original prototypes of the new user interface were revealed at MIX 2008 in Las Vegas.

Getting Wine Ready for Office 2007

Wine Configuration
The following guide is based on a clean configuration directory and running in a 1024×768 virtual desktop.

Wine version used:
Windows version emulated:
Windows XP
Office version:
Microsoft Office 2007

Download and install the latest Wine available by following this guide.

$ winecfg

When the configuration dialog appears set the virtual desktop in the graphics tab and click OK.

Then download winetricks using wget:

$ wget

sh winetricks msxml3 dotnet20 gdiplus riched20 riched30 vcrun2005sp1 allfonts

Installing Microsoft Office 2007
Office 2007 requires a libraries, which are not included in a plain Wine-installation. These libraries could be obtained from CrossOver Games, which is a derived version of Wine made to support games under Linux.

Download and install CrossOver Games either by hand or by using the official Ubuntu or Debian package.

After the install then

Copy into Wine:

$ sudo cp /opt/cxgames/lib/wine/ .wine/drive_c/windows/system32/

Rename the native Wine-dll version:

$ sudo mv .wine/drive_c/windows/system32/rpcrt4.dll .wine/drive_c/windows/system32/rpcrt4.dll.bak

Rename CrossOver Games version into the original name:

$ sudo mv .wine/drive_c/windows/system32/ .wine/drive_c/windows/system32/rpcrt4.dll

Moreover you will need to rename msxml3.dll into *.bak too:

$ sudo mv .wine/drive_c/windows/system32/msxml3.dll .wine/drive_c/windows/system32/msxml3.dll.bak

After the renaming it is time to run winecfg again and set msxml3.dll andrpcrt4.dll to “native windows” select save and exit.

Now it is time to mount the Office 2007 cd media and start the actual Office 2007 installation.

$ sudo mount -o loop -o unhide Office-2007.iso /mnt

Now cd into the mounted directory

$ cd /mnt
$ wine setup.exe

Type the serial number and click install.

Comments off

MySQL Optimization and Performance Tips

    • Store IP addresses as INT, not CHAR – by using INET_ATON to convert from a string to an integer and by using INET_NTOA to convert from an integer to a string
    • Use non-persistent connection, since they are light-weight – much faster create than compared Oracle or PostgreSQL
    • Use the right storage engine; this means for example the ARCHIVE-engine for logs and other kind of INSERT-only operations, and the MEMORY-engine for fast in-memory data that should go away on server restart

More general MySQL optimization and performance tips are available in this Slideshow.

Comments off

Howto: Create your own Debian or Ubuntu package repository

The Debian package management system (called Advanced Packaging Tool or APT) is by far the most well-designed and is one of the top killer features on the Linux platform.

This short Howto describes howto establish a Debian package repository for home-grown deb-packages or like (could be used for Ubuntu as well, since Ubuntu uses the Debian package management system).

Establish repository structure
Create the repository structure in a directory. E.g. in ~/public_html directory exposed to the web.

cd public_html
mkdir my-repository
cd my-repository
mkdir binary
mkdir source

Copy your deb-packages into the repository

Like this
cp src/bzr_0.11-1.1_all.deb public_html/my-repository/binary/

Install the tools to be able to create a repository index

sudo aptitude install dpkg-dev

Create a repository index
cd my-repository
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz

Using the repository

# Add these two lines into the /etc/apt/sources.list
deb binary/
deb-src source/

Feel free to comment – easier methods and tips are more than welcome ;)

For a more professional package management setup, use reprepro


Ubuntu Howto: Install Oracle

Installing Oracle on Ubuntu is fairly easy, since Oracle has created a Debian and Ubuntu package repository, so it is possible to download and install the Oracle database softwareusing apt-get and aptitude.

Howto use the Oracle Debian and Ubuntu Repository:

Add the following lines to the /etc/apt/sources.list

# Oracle Repository
deb unstable main non-free

Update the package repository database with:

cc@ray:~$ sudo apt-get update

Now you should be able to install the following Oracle software:

  • libaio
  • oracle-xe-client
  • oracle-xe
  • oracle-xe-universal

Install the Oracle Express packages

sudo aptitude install oracle-xe oracle-xe-client

Configure using:

sudo /etc/init.d/oracle-xe configure

Access the nice Oracle web interface by pointing your Firefox to:


The installation process might report that the Oracle packages are not gpg signed, but you should be able to install the packages anyway.

You can avoid this report by added the Oracle gpg-public key to your apt-key chain

wget -O- | sudo apt-key add -

Read more on Oracle and Debian and Ubuntu here

Comments off

Howto Install Sun Java on Debian Etch

This small guide shows how to install the original Sun Java 2 Platform Standard Edition 5.0 JRE (Java Runtime Environment) and JDK (Java Developer Kit) on Debian 4.0 Etch

The original Sun Java 2 is available in the ‘non-free’ section of the Debianrepositories. To enable this section first add the non-free repository to the apt sources file – the /etc/apt/sources.list should look like, – important parts are in bold:

deb etch main contrib non-free

Now, update apt:

sudo apt-get update

Then install the Java debian packages.

sudo apt-get install sun-java5-jre

Or this for installing the JDK ( the Java SDK )

sudo apt-get install sun-java5-jdk

Comments off

Xen Howto: Install Windows

This short guide describes how to install Windows XP orWindows 2003 Server on Xen. It provides an overview of theDebian Linux Etch installation, and detailed steps for installing and configuring Xenand starting the Windows XP or Windows 2003 Server


  • CPU with either Intel’s Vanderpool (IVT – Intel Virtualization Technology) orAMD’s Pacifica Technology (AMD virtualization)
  • Windows iso-image

First you need to install Xen on Debian Etch:

sudo apt-get install xen-linux-system-2.6.18-4-xen-686 libc6-xen bridge-utils

Boot into the newly installed Xen enabled Linux kernel

sudo reboot

Then adjusted the network settings in /etc/xen/xend-config.sxp. Enabling the network bridge:

(network-script network-bridge)

Install Xen IO Emulation tools:

sudo apt-get install xen-ioemu-3.0.3-1

Create a directory for the virtual machine files e.g. /home/xen/domains/win01 and create a disk image for the virtual machine’s primary disk.

mkdir /home/xen
mkdir /home/xen/domains
mkdir /home/xen/domains/win01
sudo dd if=/dev/zero of= /home/xen/domains/win01/disk.img bs=1M count=4096

Establish a Xen machine Configuration file (/etc/xen/win01.cfg) like this

kernel = '/usr/lib/xen/boot/hvmloader'
builder = 'hvm'
memory = '256'

# Disks
disk = [ 'file:/home/xen/domains/win01/disk.img,ioemu:hda,w',
'file:/home/cc/iso-images/WindowsXP-SP2/image.iso,ioemu:hdc:cdrom,r' ]

# Hostname
name = ‘win01′

# Networking
vif = ['type=ioemu, bridge=xenbr0']

# Behaviour

The ready to fire up the new machine and start the Windows installation in a vnc terminal.

xm create win01.cfg

After the virtual machine is started – a VNC server port should be available on port 5900 at the Xen server’s IP, e.g. – A VNC XEN Client session is depicted here.

If an error like this shows up

Error: Device 0 (vif) could not be connected. Backend device not found.

You should check your that you have enabled the network bridge, “(network-script network-bridge)”, in /etc/xen/xend-config.sxp and restarted the xen deamon by /etc/init.d/xend restart

For more on creating Xen virtual machines read this guide, which outlines the features of the xen-tools package.

Comments off

Installing Xen on Debian Etch 4.0

For a long time I have tested many different virtualization techniques; Xen, VMWare, and Microsoft VM. Until now I’m able to conclude that all of them are usable on my desktop machine, but bothVMWare and Microsoft’s VM are more sluggish that Xen. This weekend I deployed my first server based on the upcoming Debian Etch andXen. Everything worked out of the box.

Here is what I did to install Xen on Debian Etch:

sudo apt-get install xen-linux-system-2.6.18-4-xen-686 libc6-xen bridge-utils

Boot into the newly installed Xen enabled Linux kernel

sudo reboot

Then adjusted the network settings in /etc/xen/xend-config.sxp. Enabling the network bridge:

(network-script network-bridge)

Install xen-tools:

apt-get install xen-tools

Xen tools is a collection package containing different tools related to Xen, a virtual machine creator etc.

Edit adjust the kernel and initrd parameters in /etc/xen-tools/xen-tools.conf to match the ones on your system:

Find out what the kernel image and initrd is named by:

ls /boot/vmlinuz*
/boot/vmlinuz-2.6.18-4-686 /boot/vmlinuz-2.6.18-4-xen-686


ls /boot/initrd*
/boot/initrd.img-2.6.18-4-686 /boot/initrd.img-2.6.18-4-686.bak /boot/initrd.img-2.6.18-4-xen-686

Adjust the lines

# Default kernel and ramdisk to use for the virtual servers
kernel = /boot/vmlinuz-2.6.18-4-xen-686
initrd = /boot/initrd.img-2.6.18-4-xen-686

Further adjust the xen-tools.conf to this settings:

dir = /home/xen
debootstrap = 1
size = 4Gb # Disk image size.
memory = 128Mb # Memory size
swap = 128Mb # Swap size
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = etch # Default distribution to install.
image = sparse # Specify sparse vs. full disk images.

Create a home for all the coming virtual Xen guests:

mkdir /home/xen
mkdir /home/xen/domains

And then ready to create a virtual machine – guest, simply by:

xen-create-image -hostname=mailserver -ip= -netmask= -gateway= -passwd

Afterwards I was able to fire up the newly created virtual machine with:

xm create mailserver.cfg

If an error like this shows up

Error: Device 0 (vif) could not be connected. Backend device not found.

You should check your that you have enabled the network bridge, “(network-script network-bridge)”, in /etc/xen/xend-config.sxp and restarted the xen deamon by /etc/init.d/xend restart

When up and running either “xm list” or “xentop” can be used to get an overview of what instance are currently running

debian5:# sudo xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      874     1 r-----    657.9
mailserver                                 3      128     1 -b----      8.0

Based on my experiences so far with virtualization and deploying virtualization in a enterprise setup, I really think that Xen is a very strong asset for Linux and Linux based distributions to show the world what they are up to. Virtualization is really a technique for enterprise server and data center managers to make a more robust and simplified setup, and I think that virtualization could play a significant role within the server market the coming years.