Archive for December, 2009

Debian domU on CentOS 5.4 Dom0 using debootstrap

I’m hoping to essentially follow this:

Essentially, create LVs and format them (look at the previous posts for the how to), and have debootstrap installed on the CentOS host.

Mount the LV in which you’re going to install Debian on by running mount <LV location> <mount location>. I did mount /dev/mapper/debian /mnt/debian.

The command to run is debootstrap --arch ARCH lenny <mount location of LV> <mirror to download from>. For me, this should be debootstrap --arch i386 lenny /mnt/debian because my local mirror (by local, I mean Singapore) is

chroot to the install root.

Add 7:2345:respawn:/sbin/getty 38400 hvc0 to /etc/inittab. (While you’re at it, you can comment out the rest of the console entries – they’ll remain unused.)

Add the Xen drive config to /etc/fstab:
proc /proc proc defaults 0 0
/dev/xvda1 / ext3 defaults,errors=remount-ro 0 1
/dev/xvdb1 none swap defaults 0 0

Mount /proc. (So there are no complaints later about /proc/modules not existing.)

To get around the grub bug (, run echo '(hd0) /dev/xvda' > /boot/grub/ && cd /dev && mknod xvda b 202 0. (If you have your disk mounted as something other than /dev/xvda, then replace xvda with your appropriate drive location.)

Run apt-get install locales and dpkg-reconfigure locales to build the correct language support for your region. (Gets around the “locale not detected” error messages if you didn’t run export LANG=C.)

Create networking info in /etc/network/interfaces:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

echo "debianlenny" > /etc/hostname && echo " localhost localhost.localdomain debianlenny" > /etc/hosts

Run aptitude install libc6-xen

Run aptitude install linux-image-xen-ARCH grub (To get the kernel installed and grub – in order to use PyGrub. ;))

Run aptitude install openssh-server screen (Personal preference. =))

To-do: Kill the wallclock stuff.


Ubuntu 9.10 domU on CentOS 5.4 Dom0 using debootstrap

I’m hoping to essentially follow this: and this:

Essentially, create LVs and format them (look at the previous posts for the how to), and have debootstrap installed on the CentOS host.

Mount the LV in which you’re going to install Ubuntu on by running mount <LV location> <mount location>. I did mount /dev/domU/ubuntu /mnt/ubuntu.

The command to run is debootstrap --arch ARCH karmic <mount location of LV> <mirror to download from>. For me, this should be debootstrap --arch i386 --include=linux-image-virtual,libc6-xen,grub --components=main,universe,multiverse karmic /mnt/ubuntu because my local mirror (by local, I mean Singapore) is (Note: Don’t use the ‘release’ mirrors – they won’t work.)

Once debootstrap comes back ok, run chroot /mnt/ubuntu

Setup the Xen console – cd /etc/init and cp tty1.conf hvc0.conf. Change tty1 in the file to hvc0 – cat tty1.conf |sed 's/tty1/hvc0/g'>hvc0.conf.

You must do this before starting any of the installs. The debootstrap install fails because it tries to start rsyslog, then fails when it can’t connect to upstart, causing dpkg to fail!

upstart (the new service manager in 9.10) doesn’t like chrooted environments, so we have to apply a workaround – dpkg-divert --local --rename --add /sbin/initctl && ln -s /bin/true /sbin/initctl

For good measure, do dpkg --configure -a just make sure everything is successful.

dpkg will complain about missing locales – run aptitude install language-pack-en to stop the complaints.

Edit /etc/fstab to reflect the drives:
[email protected]:/# cat /etc/fstab
proc    /proc   proc    defaults        0 0
sys /sys sysfs defaults 0 0
/dev/xvda1      /       ext3    defaults,errors=remount-ro      0 1
/dev/xvdb1      none    swap    defaults        0 0

Create a Xen enabled kernel – download the kernel source from the Ubuntu repos and set it up for Xen. (See below for the current steps.)

Kill the hardware clock, apparently it causes the domU to lock up – update-rc.d -f hwclockfirst remove && update-rc.d -f hwclock remove
Add a user – adduser myusername
Create an admin group if you want – addgroup --system admin && adduser myusername admin – this doesn’t add you to the sudoers file though. Still have to add yourself manually. I just added my user account to the sudo usergroup, and allowed the sudo group to run all commands with sudo. (From the chroot environment, run visudo.)

Set the hostname – echo 'name' > /etc/hostname
Setup the network devices in /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Setup the routing – add localhost localhost.localdomain hostname to /etc/hosts

Grub/boot stuff:

Modify /boot/grub/menu.lst and change the “indomU” to “true”. (Also, enable memtest as a boot option if you want, but it’s not much use in a domU system.)

Then, run update-grub to update the bootloader to use the Xen-enabled kernel.

ALSO: The Xen domU configuration file needs to be changed – this will store the MAC address of the network  interface, script used to create the interface, and the bridge to which the interface will be joined As well as all the memory sizes and what not.

The kernel compilation stuff

Based on
echo "deb-src karmic main" >> /etc/apt/sources.list && apt-get update
apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package
apt-get build-dep linux

Find the version of the kernel source in the apt repo. Using the “$(uname -r)” trick doesn’t work because we’re in a chrooted environment.
apt-cache search linux-image
In my case, it was linux-image-2.6.31-14. So,
apt-get build-dep --no-install-recommends linux-image-2.6.31-14-virtual
mkdir kernel && cd kernel && apt-get source linux-image-2.6.31-14-virtual
apt-get install libncurses5-dev
cd linux-2.6.31
make menuconfig

Go to Processor type and features -> High Memory Support and change it to something other than 4GB. (The xen option won’t appear till you do so.)
Then, go back to Paravirtualised Guest Support and enable Xen support.
Now, just keep searching for Xen options (Hint: Hit ‘/’ and type ‘xen’) and enabling all of them. Also, you can probably disable stuff that you don’t need and set the processor architecture too, while you’re at it.
As a note, for some strange reason, Xen doesn’t show up under the Virtualization sub menu in the root menu. My guess is that the Virtualization menu refers to stuff that the OS will virtualize, as in the newly created kernel will be the dom0. Ubuntu doesn’t support this in its sources, so makes sense that it’s not included.

Once the config’s finished, run make-kpkg clean
If you have a multi-core system, run export CONCURRENCY_LEVEL=(1+number of cores) I have a 4 core system (dual dual core P4 era Xeons), so I ran export CONCURRENCY_LEVEL=5
Finally, create the kernel. fakeroot make-kpkg --initrd --append-to-version=-xen-p4xeon kernel-image kernel-headers
Once the packages are created, do dpkg -i ../*.deb


Formatting LVs for dom0 guests

Installing paravirtualized guests is interesting in the sense that you’re essentially copying over a minimal system, then telling it to install itself. Supposed to be fun. XD


Now, after setting up the logical volumes for the domU guest, you have to setup the filesystem. Which isn’t as hard as it sounds, all the information I’ve found is similar, which should mean it’s fairly accepted.

The basic gist of it is you have to use mkfs.ext3 <LV location> (if you want ext3), followed by mkswap <LV swap location>.

So, I created a LV called debian and debian-swap to run a debian domU guest off of. (Wow. Such an imaginative naming scheme! =D)

For some reason, CentOS has all the LV locations in /dev/mapper. It’s probably different on some other distro, so you have to find out where yourself. But, this meant that my commands were mkfs.ext3 /dev/mapper/debian and mkswap /dev/mapper/debian–swap. (No, that double dash isn’t a typo.  I think a dash is a protected character, so LVM has to escape it.)

Also, upon redoing it, found out that CentOS also has individual LV volumes in /dev/<vgname>/<lvname>, not just /dev/mapper. Makes more sense I think. And more convenient too.

(As a side note, the Debian guidelines include the command swapon <LV swap location>. I don’t believe that this is necessary, but who knows. I have yet to successfully install any domU guests.)

No Comments

LVM management for guests

Current setup on my test server is 1 20GB drive for all the dom0 stuff, and a larger drive which will hold all the domU images. There will be 2 images for each system – 1 20GB partition which will be mounted as / and 1 512MB partition which will be used as swap.

Because I’ve now gone through 3 drives, I think I know how to do this very well. First off, use fdisk and change the partition type of the drive to 8e, or Linux LVM. (Just to make things simple, the entire disk is partitioned as one large partition, I’ve decided to use LVM is manage partitions instead.)

Then, run pvcreate /dev/[h|s]d[a-z], where [h|s]d[a-z] is the name of your disk – for some reason, it’s not possible to do this on a partition by partition basis, probably because this physically prepares the drive somehow. Not too sure how. Just tried it with a new drive. It works now for some reason.

After that, run vgcreate <vg name> <partition(s)>. I just used vgcreate domU /dev/hdc . (This is where the partition-by-partition basis comes in.) It seems to work if you specify an entire drive. I shall just chalk it up to not remembering properly.

To finally prepare the logical volumes, run lvcreate -L<size> -n <name of lv> <name of vg>. I used lvcreate -L20G -n <distroname> domUs and lvcreate -L512M -n <distroname>-swap domUs

The best resource I found on LVMs (with a quick Google search) was this:

No Comments

Getting debootstrap on CentOS5.4

Mysterious references were found to a debootstrap RPM built for Fedora that should also work on CentOS5.4. Google searches are helpful in finding working links though – it pulled up Which seems to work – the fc11 and fc12 version have weird dependencies which CentOS couldn’t handle. (As an aside, CentOS seems to be incredibly poor in terms of software that seems to work with it. It can’t seem to find any program which I search for. I think I’ll need to find additional repos for it.)

Anyway, installing debootstrap once the rpm was found was simple – rpm -ivh debootstrap-etc, done.

No Comments

Getting Xen 3.4 on CentOS5.4

First problem – The version of Xen it had was 3.1.something. The latest one is 3.4.2.

Followed the directions here to grab 3.4. (Essentially, add a repo with the 3.4 rpms built, then yum groupremove virtualization, yum groupinstall virtualization. No idea why a bunch of stuff was dependent on Xen, but it was – stuff like gnome-volume-manager, of all things. And pcmciatools or similar.)

Trying to get ubuntu 9.10 and debian setup and running. Complicated by my drive having bad sectors that were only discovered when I tried to mount the filesystem for debootstrap and ran into read errors.

DBANing a new disk to make sure that that disk is fine now though. See how it goes. *crosses fingers*

No Comments

Xen on OpenSolaris 32bit w/out hardware virtualization

Turns out, it’s an utter failure. Xen kernel won’t even boot. And the package management system has been timing out really really badly. Though I think that’s just SingNet, not me.

Anyway, the commands used:

pfexec su –

pkg install xvm-gui (This grabs all the dependencies too…)


For some reason, it also removed the grub entry for the original kernel. No clue why it did it, but it left the system in an unbootable state.


So moved to CentOS 5.4. Except that’s a whole other deal.

No Comments

New project: ImageGallery!

I’ve started a new project called ImageGallery. It’s essentially a revamp of a gallery script to allow it to use caching.

More info here.

No Comments

Notice: Development on IRCbot has stopped

Development on IRCbot has stopped due to the base PircBot package being tripped up by new anti-bot protections. (Most notably by Inspircd.)

I’ve personally moved to using SupyBot, which seems to be an acceptable replacement. (Except that it’s lacking !playback, but the !last module could probably be hacked to do this.)

No Comments

“Updates yearly”

I knew it. Somehow, I knew that I’d only get around to updating the blog once a year.
Except some code related stuff to be up soon though.

No Comments