Installing Debian Squeeze on a headless Soekris, using debootstrap

Jurjen Bokma

November 2011

PXE doesn't always work, and it requires some work to set up. If you're not doing many installs (more than one), then debootstrap can be used...

  1. I have a Linux machine with 64-bit Ubuntu Lucid. The Soekris (a net5501) is 32 bit, but that's no problem. I put the SSD CIFS card in a card reader and edit the partition table to look like:


    Of course, you shouldn't make the beginners' mistake of editing the wrong device here. If you happen to think the SSD card is on /dev/sda, chances are that you don't know what you are doing. Think again.

    apprentice@lucid-box:~$ sudo fdisk /dev/sdd

    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
          switch off the mode (command 'c') and change display units to
          sectors (command 'u').
    Command (m for help): p

    Disk /dev/sdd: 4224 MB, 4224761856 bytes
    128 heads, 63 sectors/track, 1023 cylinders
    Units = cylinders of 8064 * 512 = 4128768 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Device Boot      Start         End      Blocks   Id  System
    /dev/sdd1   *           1        1000     4031968+  83  Linux
    /dev/sdd2            1001        1023       92736   82  Linux swap / Solaris

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    As you see, we use a single partition for the system, and a small one for swap.

  2. apprentice@lucid-host:~$ sudo mkfs.ext4 /dev/sdd1

  3. apprentice@lucid-box:~$ sudo mkdir /mnt/debootstrap/
    apprentice@lucid-box:~$ sudo mount /dev/sdd1 /mnt/debootstrap/
    apprentice@lucid-box:~$ sudo debootstrap --arch=i386 squeeze /mnt/debootstrap/
    I: Retrieving Release
    <lots of output snipped>
    I: Base system installed successfully.

  4. This is only needed for installation of GRUB several steps later, but we do it now so we don't have to exit the chroot then.

    apprentice@lucid-box~$ sudo mount -o bind /dev/ /mnt/debootstrap/dev/

  5. apprentice@lucid-box:~$ sudo emacs -nw /mnt/debootstrap/etc/fstab
    apprentice@lucid-box:~$ cat !$
    cat /mnt/debootstrap/etc/fstab
    /dev/sda1       /               ext3    defaults                0       0
    /dev/sda2       none            swap    sw                      0       0
    tmpfs           /tmp            tmpfs   size=128m,mode=1777     0       0
    proc            /proc           proc    defaults                0       0
    sys             /sys            sysfs   defaults                0       0

    apprentice@lucid-box(chrooted):~# sudo touch /etc/mtab
    root@lucid-box(chrooted):~# sudo -c "echo soekris-box > /etc/hostname"

  6. apprentice@lucid-box:~$ sudo -s
    root@lucid-box:~# chroot /mnt/debootstrap/
    root@lucid-box(chrooted):~# apt-get install debian-keyring
    root@lucid-box(chrooted):~# apt-get update
    root@lucid-box(chrooted):~# apt-get install locales
    root@lucid-box(chrooted):~# apt-get install emacs sudo
    root@lucid-box(chrooted):~# adduser apprentice
    root@lucid-box(chrooted):~# chmod u+w /etc/sudoers && echo "apprentice ALL=(ALL) ALL" >> /etc/sudoers && chmod u-w /etc/sudoers && sudo echo blah #just to test
    root@lucid-box(chrooted):~# apt-get install linux-image-2.6-686 linux-headers-2.6-686

  7. root@lucid-box(chrooted):/# apt-get install grub2


    Make sure that the boot parameter console=ttyS0,115200 is appended to any kernel line. Otherwise, you won't be able to log in.


    The device to put a master boot record on is /dev/sdd in my case. But the disk of my Lucid machine is also still visible. Remember that we bindmounted /dev/ into the chroot? You almost certainly don't want to put a new MBR in /dev/sda. If you do make a mistake, you may render the machine you're working on unbootable.

    [ ] /dev/sda (250059 MB; Hitachi_HDS721025CLA382)
    [ ] /dev/sdb (1500301 MB; WDC_WD15EARS-00Z5B1)
    [*] /dev/sdd (4224 MB; USB_CF_Reader)
    [ ] - /dev/sdd1 (4128 MB; /)

    Installation finished. No error reported.
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.32-5-686
    Found initrd image: /boot/initrd.img-2.6.32-5-686

  8. root@lucid-box(chrooted):/# sudo sed -i '/^#GRUB_TERMINAL=/ s/^#//g' /etc/default/grub

    Make absolutely sure that the line GRUB_CMDLINE_LINUX="console=ttyS0,115200" is in /etc/default/grub:

    # If you change this file, run 'update-grub' afterwards to update
    # /boot/grub/grub.cfg.
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    # Uncomment to enable BadRAM filtering, modify to suit your needs
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    # Uncomment to disable graphical terminal (grub-pc only)
    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    # Uncomment to disable generation of recovery mode menu entries
    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"

    Now GRUB make Linux use the serial console, but GRUB itself needs to use the serial console as well. That's configured in /etc/grub.d/00_header:

    function load_video {
    if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
      cat <<EOF
    insmod ${GRUB_VIDEO_BACKEND}
      # Insert all available backends; GRUB will use the most appropriate.
      for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
          cat <<EOF
    insmod ${backend}
    cat <<EOF
    # These three lines added -Apprentice
    serial --unit=0 --speed=115200
    terminal serial

    Now run update-grub and you should be fine.

  9. root@lucid-box(chrooted):/# umount /sys
    root@lucid-box(chrooted):/# umount /tmp/
    root@lucid-box(chrooted):/# umount /proc
    root@lucid-box(chrooted):/# exit
    root@lucid-box:/# exit
    root@lucid-box:/# sync
    root@lucid-box:/# sudo umount -l /mnt/debootstrap

  10. ... and power it up. This should get you a running Soekris.

  11. the file /etc/udev/rules.d/70-persistent-net.rules generated when debootstrap ran doesn't contain the NICs of the Soekris, and when the Soekris is booted, there will be no eth0. Edit said file and give the right name to the right MAC address, then reboot.

    #commented-out, is from debootstrap# ## PCI device 0x8086:0x10ef (e1000e)
    #commented-out, is from debootstrap# #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="f4:ce:46:30:14:b2", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    # PCI device 0x1106:0x3053 (via-rhine)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:ca:65:d4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    # PCI device 0x1106:0x3053 (via-rhine)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:ca:65:d5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
    # PCI device 0x1106:0x3053 (via-rhine)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:ca:65:d6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
    # PCI device 0x1106:0x3053 (via-rhine)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:ca:65:d7", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
    # PCI device 0x100b:0x0020 (natsemi)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:c9:b0:10", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
    # PCI device 0x100b:0x0020 (natsemi)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:c9:b0:11", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
    # PCI device 0x100b:0x0020 (natsemi)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:c9:b0:12", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth6"
    # PCI device 0x100b:0x0020 (natsemi)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:24:c9:b0:13", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth7"

    You could've done this before putting the SSD in the Soekris, if you knew the MAC addresses beforehand...

  12. root@soekris-box:/# apt-get install openssh-server
    root@soekris-box:/# apt-get install postgresql-8.4

    If PostgreSQL doesn't run, maybe put in /etc/postgresql/8.4/main/postgresql.conf a line:

    listen_addresses = '*'

    Then (re)start the server and create the OpenERP database:

    su - postgres -c "createuser --createdb --no-createrole --pwprompt openerp"

    Now install OpenERP, and sshd too:

    root@soekris-box:/# apt-get install openssh-server openerp-server graphviz ghostscript postgresql postgresql-client python-imaging python-matplotlib python-openssl python-pyparsing


    You may have to comment out

    'interface = localhost'

    in /etc/openerp.conf and restart the daemon.