Monday, 27th April 2009

Changes…

Posted by David @ 18:42

Some may have noticed that I’ve recently outright deleted half the content of my site. Most of it was pretty old and generally not very interesting. I’m working on a new site which will have less random/rubbish/irrelevant content, but will incorporate lots of nice web 2.0-ey features. If I manage to find some way to produce nice graphics despite not having any graphical-design ability, it may even look nice ;-)

I’ve also taken a few tentative steps into microblogging with Identi.ca (mirrored on Twitter if you’re that way inclined).

It’ll all be coming Real Soon Now™.

Sunday, 18th January 2009

New Year’s Resolution #367

Posted by David @ 17:04

Must stop buying things I read about in Wired

Saturday, 25th October 2008

Installing Debian with root on iSCSI

Posted by David @ 13:21

You know, if a normal person wanted a diskless Debian install, they’d use NFS – a widely supported way to have a root filesystem on a network share and therefore reasonably easy to set-up. I however, wanted to have the root filesystem on iSCSI since it’s a nice, fast way of achieving the same thing. I’m now going to document how I achieved this for those who wish to do the same, but first: if you want an easy solution, use NFS. Seriously. You need to have some experience as a Linux sysadmin, developer and Debian user to make this work.

HERE BE DRAGONS

You’re still reading? OK then, here goes.

The first step is to configure your iSCSI target, which I won’t go into here. You may find my previous post, Playing with iSCSI, helpful. Now grab a copy of the Debian netinst CD image, burn it to CD and boot from it on the machine you want to install on. Note: it’s essential that you have another machine already running the version of Debian that you’re installing.

Using another machine, you now need to get a copy of the open-iscsi sources. You should do this on a Debian system running the same version of Debian, with the same kernel on the same architecture as you are installing. Simply run:

apt-get source open-iscsi

You now need to make some modifications to the open-iscsi source to make it work in the Debian Installer environment (and in initramfs, which we’ll come to later). The changes are minimal, but for convenience I’ve produced a patch:

open-iscsi-initrdfix.patch

Change into the directory containing the open-iscsi source, and apply the patch as follows:

patch -p1 < /path/to/open-iscsi-initrdfix.patch

Now simply type make to build open-iscsi. This will build the open-iscsi userspace applications and the necessary kernel modules. If you find that open-iscsi refuses to build kernel modules with a complaint like the following:

make[1]: *** No rule to make target `linux_2_6_26′, needed by `kernel_check’. Stop.

Then don’t worry – this simply means that you can avoid compiling the modules, and will need to copy them from the running kernel instead.

You now need to copy some files, plus a few modules from the running kernel, to a USB pen-drive. From the open-iscsi directory you need the following (ignore the .ko files if the kernel modules didn’t build):

usr/iscsid
usr/iscsiadm
kernel/libiscsi.ko
kernel/iscsi_tcp.ko
kernel/scsi_transport_iscsi.ko

Plus the following files from your running kernel:

/lib/modules/`uname -r`/kernel/crypto/crc32c.ko
/lib/modules/`uname -r`/kernel/lib/libcrc32c.ko

If the open-iscsi kernel modules didn’t build before, copy the following too:

/lib/modules/`uname -r`/kernel/kernel/drivers/scsi/iscsi_tcp.ko
/lib/modules/`uname -r`/kernel/drivers/scsi/libiscsi.ko
/lib/modules/`uname -r`/kernel/drivers/scsi/scsi_transport_iscsi.ko

Now on the machine you’re installing on, begin the Debian installation and continue normally until after the stage where the network is configured. Now switch to a console (Alt+F2), insert your USB pen-drive and mount it. Copy the files off it and place them in /tmp.

You now need to create /etc/iscsi/initiatorname.iscsi with content like the following:

InitiatorName=iqn.1993-08.org.debian:01.665f5fd03076

The actual name isn’t important, just make something up (as long as it’s in the above format).
Now remove your USB pen-drive (important!) and run the following commands to get iSCSI going:

insmod /tmp/libiscsi.ko
insmod /tmp/scsi_transport_iscsi.ko
insmod /tmp/iscsi-tcp.ko
insmod /tmp/libcrc32c.ko
insmod /tmp/crc32c.ko
/tmp/iscsid
/tmp/iscsiadm -m discovery -t sendtargets -p <iscsi target ip address>:<port>
/tmp/iscsiadm -m node -L all

That will load all the required modules, discover your target and then connect to it. All being well, it will appear as a SCSI disk (check dmesg). Now you can continue the install normally. At the final stage of the install DON’T allow the system to reboot – the installed system can’t boot yet.

I decided that I wanted to boot using BOOTP and TFTP. You might want to boot from USB, a flash card or something else, in which case you’re on your own – I’m going to document how to boot using BOOP and TFTP. On your iSCSI target machine (or any machine, actually) configure the required daemons and drop in the Debian netboot files – you may wish to use Preparing Files for TFTP Net Booting as a guide.

Now that your installation is finished, you need to copy some files off the installed system to your pen drive. You need the initramfs and the kernel from /mnt/target/boot/ directory, named initrd.img-<kernelversion> and ‘vmlinuz-<kernelversion>. You also need the entire /etc/iscsi directory.

Now copy the files onto the machine you configured as your TFTP server, and put the kernel image into your tftp directory (probably /tftpboot). You now need to modify the initramfs image to add the iSCSI bits.

First, decompress the initramfs image into an empty directory:

gzip -dc <initramfs image> | cpio -id

Now, you need to copy in the contents of the pen drive to the right places. Copy the /etc/iscsi directory from the pen drive to etc/ in the directory containing the decompressed initramfs image. Also copy the iscsid binary to sbin/, and the iscsiadm binary to bin/.
Now you need to add the following to the end of scripts/init-premount/udev (we need to add it to one of the scripts run at the start of the boot process, and this is as good a place as any):

/bin/ipconfig -c dhcp -d eth0
/sbin/iscsid -f &
/bin/iscsiadm -m node -L all

You also need to copy in the kernel modules, into the correct paths:

lib/modules/<kernelversion>/kernel/crypto/crc32c.ko
lib/modules/<kernelversion>/kernel/lib/libcrc32c.ko
lib/modules/<kernelversion>/kernel/drivers/scsi/iscsi_tcp.ko
lib/modules/<kernelversion>/kernel/drivers/scsi/libiscsi.ko
lib/modules/<kernelversion>/kernel/drivers/scsi/scsi_transport_iscsi.ko

And finally, you need to edit the init script to reference the root partition, e.g:

export ROOT=/dev/sda1

Now re-create the initramfs image by running the following in the root of the directory in which you decompressed the image, and save it to your tftp directory:

find . | cpio -H newc -o > /tftpboot/initrd.img-<kernelversion>

That’s it. Ensure your TFTP server is fully configured, modify the PXE configuration to point to your kernel and initramfs image, then you can restart your system and hopefully you’ll get root on iSCSI…

Sunday, 31st August 2008

Cutting the grass

Posted by David @ 15:28

Oh how I hate cutting the grass. Not only is it the amount of physical effort it requires and the fact that it has to be done during the few warm, dry days we get each year when I’d much rather be doing other things, but it feels very much like I’m destroying an entire ecosystem (yes, I always let it get too long). Last time a seemingly endless array of wildlife was dislocated – from next doors’ cat which likes to sleep in the long grass, to a frog which very nearly met an unpleasant end (after much fun attempting to catch it, I eventually managed to shepherd it away to some long grass I wouldn’t be cutting).

What I really need is for something vaguely endangered to start living there, then I’d have a pretty good excuse for never cutting it. Unfortunately, Google suggests the frog was just a Common Frog, which I’m guessing isn’t endangered…

Sunday, 13th July 2008

Flickr coolness

Posted by David @ 18:10

Decided to have a play with Flickr today. I haven’t really bothered uploading stuff to it before, since I have my own photo album, but just wanted to have a play. Then I saw a ‘blog this’ button alongside my first upload, hence this post. The fact that it can blog direct to my Wordpress blog using it’s API is also a great example of the coolness that is Flickr.

I will need to give some serious thought to using it instead of the photo album I spent ages coding…

Edit: Required lots of editing to fix brokenness in the generated-HTML, which made a bit of a mess on the page. A small amount of fail is OK.

linky