Posts Tagged ‘debian’

Installing Debian with root on iSCSI

Saturday, October 25th, 2008

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…

Packaging for Debian

Wednesday, April 25th, 2007

I’m now the proud maintainer of a package in the main Debian repository. This package contains isomaster, a graphical ISO image editor for Linux. I’ve been using it for a while and originally started producing unofficial Debian packages. I thought it would be impossible to actually get the package included in Debian, since the process seemed to involve a lot of bureaucracy, but actually it was more time-consuming than difficult. I just had to properly Debianise the source code (can mostly be done automatically thanks to dh-make) to allow for automatic package building then jump through various hoops to make sure the resulting package conformed to Debian Policy. Once this was done and the various automatic package-checking tools were happy I used the Debian Mentors system to get the package into Debian, which involves a Debian Developer manually checking the package, then when happy uploading it to Debian on my behalf. Once this has happened there is a final manual check by the Debian ftpteam before it moves into the main repository.

It was a long process, which is why I was so happy to see this the other day:

Accepted:
isomaster_0.8.1-1.diff.gz
to pool/main/i/isomaster/isomaster_0.8.1-1.diff.gz
isomaster_0.8.1-1.dsc
to pool/main/i/isomaster/isomaster_0.8.1-1.dsc
isomaster_0.8.1-1_i386.deb
to pool/main/i/isomaster/isomaster_0.8.1-1_i386.deb
isomaster_0.8.1.orig.tar.gz
to pool/main/i/isomaster/isomaster_0.8.1.orig.tar.gz

Override entries for your package:
isomaster_0.8.1-1.dsc – optional otherosfs
isomaster_0.8.1-1_i386.deb – optional otherosfs

Announcing to debian-devel-changes

Thank you for your contribution to Debian.

If you’re running Debian Unstable you can now apt-get install isomaster (or use your apt frontend du-jour). It should move into Testing (Lenny) in the not too distant future. Before anyone asks, no this does not mean it will appear in Ubuntu. If Ubuntu want to pick up the package and include it in one of their repositories they are free to do so, but I have no interest in submitting or maintaining it there.

Installing Debian with Attansic L1 Gigabit Ethernet

Tuesday, April 3rd, 2007

I’ve just bought myself a new motherboard and was initially quite concerned to find that the latest daily-built Debian-Installer image didn’t support the on-board Ethernet, especially when lspci couldn’t even identify it. But luckily I was able to track down the PCI ID and find a driver and equally as lucky I had another AMD64 system with the exact same kernel used on the Debian-Installer CD on which I could compile it.

Since most people won’t be so lucky, I figured I should share my compiled kernel module so people with the same problem can simply drop it in and load it. You’ll need this module if you want to install Debian Testing (Etch) using the netinst CD on an Asus M2V, P5B-E, P5L-MX or P5L-VM 1394 motherboard. It will work with the current daily built AMD64 images of the Debian Installer which use kernel 2.6.18-4.

atl1.ko

To use it, copy it to a floppy or USB drive as preferred, then boot the Debian installer. Switch to a console (Alt+F2), mount your floppy or USB device and copy the file to /tmp. Then simply ‘insmod /tmp/atl1.ko’. Now switch back to the installer (Alt+F1) and continue the install normally.

The module won’t get installed by the installer, so once your system is installed and running you’ll need to copy it into /lib/modules/2.6.18-4-amd64/kernel/drivers/net/. With any luck newer releases of the Debian kernel will include the driver, so this process won’t be necessary.

Ditch Ubuntu, embrace Freedom

Friday, February 9th, 2007

I’ve just finished a rather-risky upgrade from Ubuntu Edgy to Debian Testing (without reinstalling). Why? Because I no longer trust Mark Shuttleworth to keep his commitment to Free Software, as I see the Freedom in Ubuntu being eroded with each passing day. What with the forthcoming inclusion of binary drivers in the next release and the recent announcement of collaboration with Linspire (a company who are out to make money, no matter what the cost to the FLOSS community who they have exploited from day one), I just don’t buy it any more. It’s clear what Linspire get from the deal – a bunch of people to sell proprietary software to and some free press to drag them from irrelevance – but not what Ubuntu get out of it; it can only be £££.
What is also annoying me is the way that Ubuntu people (i.e. Canonical employees) are increasingly dismissing those who believe in Free Software as a minority group of zealots who should be ignored, as this is a convenient way for them to avoid answering the issues we raise. They’d better realise sooner or later that it’s many of these people who are writing the software they’re distributing…

Debian has the Debian Social Contract and I trust them to abide by it, so that’s why I have switched back to Debian. I decided against gNewSense simply because they’re based on the previous version of Ubuntu and I like to be on or close to the cutting edge.

For anyone else considering switching from Ubuntu to Debian without reinstalling: don’t. Just reinstall.
If you really, really want to do it, you’d better be experienced at manually resolving package conflicts and not afraid to use the potentially-hideously-dangerous ‘–force-depends’ and ‘–force-remove-essential’ dpkg command line arguments together. If you are, then it’s a simple case of swapping your sources.list for a Debian one and running ‘apt-get dist-upgrade’ and fixing the dependency problems as they arise…

The Linksys NSLU2

Thursday, December 29th, 2005

My Linksys NSLU2One of the things I got for Christmas this year was a Linksys NSLU2. It’s basically a device for attaching USB hard disks to for network attached storage (only accessible via SMB, aka Windows networking). So it’s basically a box with two USB 2.0 ports and a network interface. Not very interesting, eh? Well no, not until you realise that it runs Linux :-)

It’s actually quite easy to replace Linksys’ version of Linux with one that is accessible via SSH (a distro called OpenSlug) which makes it possible to install extra packages etc., then from there to get Debian (actually OpenDebianSlug) running on it!

So now I have a nice, silent Debian system. For some reason Linksys ship the device with the processor under-clocked, but it just requires a little targetted destruction to get it back to it’s original 266MHz. OK so that isn’t going to break any speed records, but it doesn’t mean that the device isn’t useful – far from it. People are using them for web servers, mail servers, Asterisk PBXs and iTunes servers. Should be fast enough for most simple tasks:

tiny:/home/user# cat /proc/cpuinfo
Processor : XScale-IXP42x Family rev 1 (v5b)
BogoMIPS : 263.78
Features : swp half thumb fastmult edsp
CPU implementer : 0×69
CPU architecture: 5TE
CPU variant : 0×0
CPU part : 0×41f
CPU revision : 1
Cache type : undefined 5
Cache clean : undefined 5
Cache lockdown : undefined 5
Cache format : Harvard
I size : 32768
I assoc : 32
I line length : 32
I sets : 32
D size : 32768
D assoc : 32
D line length : 32
D sets : 32

Hardware : Linksys NSLU2
Revision : 0000
Serial : 0000000000000000

So far I’ve installed an NFS server so I can actually use the device for network storage without having to mess with Samba. I’ve also bought a cheap USB webcam so I can experiment with having an Internet-connected webcam, possibly with streaming video. The possible uses for a silent Linux system with USB ports are almost endless…