Tuesday, April 29, 2014

Debian on a Soekris Net5501

CentOS requires an i686 processor, so that's out.
Thankfully, Debian releases a distribution for older processors, thanks Debian!
Debian does require 80M of memory, so the Net4501 is out. Use a BSD distribution for those.
Add a USB to serial connector and USB to ethernet connector.
Plug USB to ethernet connector into Eth 0 on Soekris.
Bring up USB to ethernet connector with address 192.168.0.1 (mine sits at eh3).

Start a tfpt server on by making sure /System/Library/LaunchDaemons/tftp.plist looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <true/>
        <key>Label</key>
        <string>com.apple.tftpd</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/libexec/tftpd</string>
                <string>-i</string>
                <string>/private/tftpboot</string>
        </array>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <true/>
        </dict>
        <key>InitGroups</key>
        <true/>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <dict>
                        <key>SockServiceName</key>
                        <string>tftp</string>
                        <key>SockType</key>
                        <string>dgram</string>
                </dict>
        </dict>
</dict>
</plist>

and then launching it with "sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist". You stop it with "sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist" and can check if it's running with "netstat -ln -f inet -p udp | grep '\.69'" You then need to get a "netboot.tar.gz" from a "/debian/dists/wheezy/main/installer-i386/current/images/netboot/" respository. "gunzip" and "tar xf" that file into "/private/tftpboot", changing all the permissions to all everyone to read and write (!) The directory should look like

$ ls -l /private/tftpboot/
total 64
drwxrwxrwx@ 4 beaty-admin  wheel    136 Jan 29 09:47 debian-installer/
-rwxrwxrwx@ 1 beaty-admin  wheel  26474 Jan 29 09:47 pxelinux.0*
drwxrwxrwx@ 4 beaty-admin  wheel    136 Jan 29 15:13 pxelinux.cfg/
-rwxrwxrwx@ 1 beaty-admin  wheel     64 Jan 29 09:47 version.info*

You must change the pxelinux.cfg/default file

$ more pxelinux.cfg/default 
console 0
serial 0 19200 0

default install
label install
        menu label ^Install
        menu default
        kernel debian-installer/i386/linux
        append initrd=debian-installer/i386/initrd.gz -- console=ttyS0,19200n8

Now, set up the bootp server file in /etc/bootpd.plist to be

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>dhcp_enabled</key>
    <string>en3</string>
    <key>Subnets</key>
    <array>
        <dict>
            <key>name</key>
            <string>192.168.0</string>
            <key>net_mask</key>
            <string>255.255.255.0</string>
            <key>net_address</key>
            <string>192.168.0.0</string>
            <key>net_range</key>
            <array>
                <string>192.168.0.2</string>
                <string>192.168.0.254</string>
            </array>
            <key>allocate</key>
            <true/>
            <key>dhcp_router</key>
            <string>192.168.0.1</string>
            <key>dhcp_option_66</key>
            <string>192.168.0.1</string>
            <key>dhcp_option_67</key>
            <data>cHhlbGludXguMAA=</data>
        </dict>
    </array>
</dict>

That magic "cHhlbGludXguMAA=" string tell the client what to boot from, one can generate it using

$ printf 'pxelinux.0\0' | openssl base64
cHhlbGludXguMAA=

Now, you can start the bootp server via "sudo /usr/libexec/bootpd -D -d -i en3" in a differnet terminal window.
Next up, we need a http mirror. I tried the following, but it wouldn't get through the install without barfing, though I'm not sure why -- it's a simple forward of the local http port. I didn't spend the time to track this one down.

$ sudo su
$ while true; do netcat -L ftp.us.debian.org:80 -s 192.168.0.1 -p 80; done

What I did do was create a mirror on my Mac. I started up a Debian VM in VirtualBox and use apt-mirror. One needs to specify the i386 distro in "/etc/apt/mirror.list"

deb-i386 http://ftp.us.debian.org/debian wheezy main contrib
deb-i386 http://ftp.us.debian.org/debian wheezy-updates main contrib
deb-i386 http://ftp.us.debian.org/debian wheezy main/debian-installer

I linked the apt-mirror directory to one that I set up in VirtualBox:

# ls -l /var/spool/apt-mirror
lrwxrwxrwx 1 root root 31 Jan 29 13:46 /var/spool/apt-mirror -> /media/sf_VirtualBox/apt-mirror

For some reason, not all the necessary files were brought over by apt-mirror, so I did the following on the Debian VirtualBox instance:

mkdir -p /media/sf_VirtualBox/apt-mirror/mirror/ftp.us.debian.org/debian/dists/w
heezy/main/i18n
cd /media/sf_VirtualBox/apt-mirror/mirror/ftp.us.debian.org/debian/dists/wheezy/main/i18n
wget http://ftp.us.debian.org/debian/dists/wheezy/main/i18n/Translation-en.bz2

mkdir -p /media/sf_VirtualBox/apt-mirror/mirror/ftp.us.debian.org/debian/dists/wheezy/main/source
cd /media/sf_VirtualBox/apt-mirror/mirror/ftp.us.debian.org/debian/dists/wheezy/main/source
wget http://ftp.us.debian.org/debian/dists/wheezy/main/source/Sources.bz2

Having this in place, I fired off a python web server in a different terminal window as it's there and ready to go

cd ~/Desktop/VirtualBox/apt-mirror/mirror/ftp.us.debian.org; sudo python -m SimpleHTTPServer 80

Connect to the Soekris serial port via something along the lines of

sudo cu -l /dev/tty.PL2303-00* -s 19200

You'll need to turn off the firewalling.  I tried for a little while to do so via either pfctl and the application firewall (http://krypted.com/tag/socketfilterfw/) but no happiness, so I shut the whole thing down, after removing the box from the net. Lame.

Boot the Soekris, and start through the install procedure.  When you get to choosing the mirror, select the very first possbility "enter information manually".

 Then specify the interface you are using, "192.168.0.1" in my case.
Choose manual partitioning of the disk. Create a 64MB partition at the beginning for /boot and a 500MB partition at the end for swap. Use the remainder for /.
One final bit of trickiness comes at the end. When you see the last screen:

 Choose "Go Back" then:

"Execute a shell", then:
$ mount --bind /proc /target/proc
$ mount --bind /sys /target/sys
$ chroot /target /bin/bash --login
$ vi /etc/initramfs-tools/initramfs.conf

and change MODULES=most to MODULES=dep
Then:
$ vi /etc/default/grub

and uncomment GRUB_DISABLE_LINUX_UUID=true
Then
$ update-initramfs -u
$ grub-install --recheck /dev/sda
$ dpkg-reconfigure grub-pc
$ exit
$ exit

These last few steps from http://debian.takhis.net/soekris/soekris.html