Debian Sarge on a IBM x206m

IBM x206's are going cheap at the moment, so we got a few. One of my tasks was to install Debian Linux on one of these servers. This page is a quick HOWTO on how I went about doing this. I used this page as a reference, so all credits go to this guy.

This HOWTO assumes you have a basic idea of kernel compiles, partitioning disks, and using Debian Linux.

The general setup is Debian Sarge with Software RAID-1 mirroring on two Serial ATA 70GB disks. The system will have a 10GB root partition and a /var partition of around 69GB. Swap will be 2GB, using 1GB on each disk (see Step 4).

Step 1

Boot to a recent Knoppix CD. (If you boot using knoppix 2, you don't need to wait for the graphical interface to load).

Step 2

Setup identical partitions on both SATA disks (/dev/sda and /dev/sdb) The layout I used was:

sda1   Primary   FD (Linux raid autodetect)    10000MB
sda2   Primary   82 (Linux Swap)               1000MB
sda3   Primary   FD (Linux raid autodetect)    69000MB

The intention is to setup a base root partition of 10GB, and a var partition of 69GB and a 1GB swap partition.

IMPORTANT: It is very important to ensure you have the correct partition types for the raid'd partitions. The partition type should be FD for Linux raid autodetect.

Step 3

Now set up the software RAID. First we need to insert the driver and create the base dev entries:

modprobe raid1
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2

Now to create both the RAID arrays.

mdadm --create /dev/md0 --level 1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm --create /dev/md1 --level 1 --raid-devices=2 /dev/sda3 /dev/sdb3

The system will take some time setting up the raid devices, you can monitor the progress by inspecting /proc/mdstat. You can continue with the remaining steps and let the system sync the disks in the background, but you should ensure the system is synch'd before rebooting.

Step 4

Now we set up the RAID devices with filesystems and mount them.

First, we need to put a filesystem on both RAID devices.

mke2fs -j /dev/md0
mke2fs -j /dev/md1

But swap isn't RAID'd (It could be, but if you mount two swap partitions, Linux will use them like a RAID-0 array, giving slightly better read/write performance. You could RAID-1 them and give reliability.

mkswap /dev/sda2 
mkswap /dev/sdb2

Now we need to mount the partitions, since we are mounting one partition as being /var, and the other as the root partition (/), we obviously mount root first.

mkdir /mnt/root
mount /dev/md0 /mnt/root

Then mount the var partition.

mkdir /mnt/root/var
mount /dev/md1 /mnt/root/var

Step 5

Now we setup a basic debian root filesystem, and start the debian installer.

Run debootstrap. The parameters of the program are the debian version, the location of the root filesystem, and the mirror respectivily.

debootstrap sarge /mnt/root http://ftp.nz.debian.org/debian/

Now we wait while debootstrap downloads and installs the packages. Go make two cups of coffee, I like mine black with one sugar thanks.


Mmmm, good coffee, now we enter the new debian root filesystem and prepare it for boot.

chroot /mnt/root/

Mount the usual suspects

mount -t sysfs sys /sys
mount -t proc proc /proc
mount -t devpts -o gid=5,mode=620 none /dev/pts

We need to create the md device nodes again.

mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2

Now we run the debian base-config, the DEBIAN_LOWPRIORITY environment variable ensures we aren't bugged with mindless questions. Go through each of the questions, answer how you like.

DEBIAN_PRIORITY=low base-config

At this stage we have a working barebones debian filesystem, but we need to install a few packages to make it boot.

Note: When mdadm installs, debian will ask two questions. You should answer No to the first question re modules and yes to the second question. If your kernel image does not contain the MD driver built in statically, then you'll need to answer Yes to the first question.

apt-get install vim mdadm grub ssh

Now edit the /etc/fstab to reflect the system. The root device is /dev/md0 and /var is /dev/md1. If you have decided not to RAID swap, don't forget to include both swap partitions.

vim /etc/fstab

Step 6

Now comes the time to install the new kernel.

At this point you should compile a custom kernel that is suited for the system. The prefered method with Debian is to use a debianized kernel by using make-kpkg. You will need the kernel-package package for make-kpkg, libncurses-dev for the ncurses based make menuconfig and bzip2 for the bzip'd kernel package. See below for what config options you need for the x206m.

apt-get install wget kernel-package libncurses-dev bzip2
cd /usr/src
wget http://ftp.nz.kernel.org/pub/linux/v2.6/linux-<version>.tar.bz2
tar -xjf linux-<version>.tar.bz2
cd linux-<version>
make menuconfig
make-kpkg clean
make-kpkg kernel_image

You should choose the all usual kernel config components, but some of the vital components for an IBM x206m are (note: all should be compiled in (not as a module)):
  • Processor type and features
    • CONFIG_X86_PC (Subarchitecture Type = PC-Compatible)
    • CONFIG_MPENTIUM4 (Processor family = Pentium 4 Processor)
    • CONFIG_SMP (Symmetric multi-processing support) For hyperthreading
    • CONFIG_SCHED_SMT (SMT (Hyperthreading) schedular support)
  • Power managerment options
    • CONFIG_ACPI (ACPI Support and associated modules) are usually helpful.
  • Bus options
    • CONFIG_PCIEPORTBUS (PCI Express support)
  • Devices Drivers
    • ATA/ATAPI/MFM/RLL Support
      • CONFIG_BLK_DEV_IDE (Enhanced IDE support)
      • CONFIG_BLK_DEV_IDEDISK (Include IDE/ATA-2 DISK)
      • CONFIG_BLK_DEV_IDECD (Inlcude IDE/ATAPI CDROM support)
      • CONFIG_BLK_DEV_IDEPCI (PCI IDE chipset support)
      • CONFIG_BLK_DEV_IDEDMA_PCI (Generic PIC bus-master DMA support)
      • CONFIG_BLK_DEV_PIIX (Intel PIIXn chipsets support)
    • SCSI Device support
      • CONFIG_RAID_ATTRS (RAID Transport Class).
      • CONFIG_SCSI (SCSI Device Support)
      • CONFIG_BLK_DEV_SD (SCSI Disk Support)
      • SCSI Low level
        • CONFIG_SCSI_SATA (Serial ATA)
        • CONFIG_SCSI_SATA_AHCI (AHCI SATA support)
    • CONFIG_MD (Multiple devices driver support)
      • CONFIG_BLK_DEV_MD (RAID Support)
      • CONFIG_MD_RAID1 (RAID-1 (Mirroring) mode) Handy.
    • Network Device support
      • Ethernet (1000 Mbit)
        • CONFIG_TIGON3 (Broadcom Tigon3 support).
    • I2C Support (This isn't strictly necessary)
      • CONFIG_I2C (I2C support)
      • I2C Hardware Bus support
        • CONFIG_I2C_I801 (Intel 82801 (ICH))
    • USB Support (This isn't strictly necessary)
      • CONFIG USB (Support for Host-side USB)
      • CONFIG_USB_EHCI_HCD (EHCI HCD (USB 2.0) support)
      • CONFIG_USB_UHCI_HCD (UHCI HCD support)

So now, assuming you have your kernel compiled, install the kernel. If you are using a debianized kernel package, then note that when you run the dpkg command, you may get heaps of errors regarding depmod, just ignore them. To install a debianized kernel package:

dpkg -i kernel-image-<version>.deb

Now we will need a basic /dev filesystem to boot.

cd /dev
./MAKEDEV generic

Step 7

Now it comes time to set up grub. Since the disks are, according to the BIOS two seperate physical disks, we simply install grub onto the MBR of both. This way when the BIOS boots, it loads grub from the MBR of one of the disks.

Grub, in turn, gets its configuration from the first partition of the disk. Grub can't understand MD partition, but RAID 1 (mirrored) partitions appear as a standard disk to any system. This would cause a problem if a non MD aware system was to write to one of the partition, but grub doesn't write to partitions, so we are safe.

In the event of a disk failure, in theory, the BIOS will simply boot the 2nd of the disks (assuming the 1st failed) and the boot would continue as normal. I have yet to test this though.

Now, on to the instructions. First, we create the basic grub layout

cd /boot
mkdir grub
cd grub
cp /lib/grub/i386-pc/* .

Now we will install the grub bootloader. I found debians grub-install didn't perform well, so we will do it manually using the grub shell.

grub

Now, inside the grub shell:

device (hd0) /dev/sda
root (hd0,0)
setup (hd0)
device (hd1) /dev/sdb
root (hd1,0)
setup (hd1)
quit

We are now back in the bash shell, so now we need to update the grub menu.lst:

update-grub -y

Step 8

Booting time....

NOTE: Ensure the system has synchronised the RAID'd disks before continuing. Inspect /proc/mdstat to see the RAID configuration

Once the system is ready to reboot, stop some of the services that may have started:

/etc/init.d/exim4 stop
/etc/init.d/ssh stop
/etc/init.d/mdadm stop

Unmount the filesystems

umount /proc /sys /dev/pts /var

Exit the chroot jail, and unmount the root filesystem.

exit
umount /mnt/root

Now comes the time for magic.

reboot

Hopefully that worked. I ran into some trouble around about here, and found a grub boot cd to be very handle (a CD with the grub bootloader installed). This system doesn't come with a floppy drive, so you need to use bootable CDs.

I found grub was able to install itself correctly when booted from the CD using the grub shell.

Hopefully you now have a working debian system on an IBM x206m. Any comments, tips, ideas or corrections, please email me.

Author Nick 'Zaf' Clifford
Date 7 July 2006