http://www.adamsinfo.com/apnic-box-linux-on-a-mikrotik-532a-part-3-installing-debian-prebuilt-disk-image/
Follow on from 01 Oct 08 APNIC Box - Linux on a Mikrotik 532a, Part 2
The device runs a 2.4.30 kernel on a debian woody (mipsel) environment. If anyone can contribute anything for 2.6.x and debian etch, that would be great.
In this part, I’m going to provide a download link to a prebuilt image which you can write directly onto your own CF card with dd or similar tool. I’m also going to provide a step by step to installing debian yourself without my prebuilt disk image.
Prebuilt image is here: http://www.adamsinfo.com/download.php?file=apnicbox-deb-110607.img.bz2 MD5: 8a13e1e5bec61a732065525b82409c45
The prebuilt image also contains a number of scripts and tools that I’ll comment on and come to in later parts.
Now installation instructions: #prepare your local cross compile environment apt-get install toolchain-source apt-get remove autoconf apt-get install autoconf2.13 apt-get install fakeroot tpkg-make mipsel-linux apt-get install debhelper apt-get install dpatch debuild -uc -us debinano -w /usr/bin/tkpg-install-libc >>SERVER=${TPKG_SERVER:-”ftp://ftp.debian.org”} >>wget $SERVER/debian/dists/stable/main/binary-${debarch}/Packages.gz -O $TDIR/packageset.gz || exit 2 tpkg-install-libc mipsel-linux
mv config.mipsel .config make ARCH=mips menuconfig #Turn ON CONFIG_PACKET / CONFIG_FILTER
nano -w Makefile #Change kgcc to gcc make ARCH=mips CROSS_COMPILE=mipsel-linux- dep make ARCH=mips CROSS_COMPILE=mipsel-linux- vmlinux
cp vmlinux linuxrc echo “root=/dev/ram0 ramdisk_size=8192″ >kernel.params echo “root=/dev/cfa2″ >kernel.params mipsel-linux-objcopy –add-section kernparm=kernel.params vmlinux mipsel-linux-objcopy –add-section initrd=initrd.gz linuxrc mipsel-linux-strip vmlinux mkdir /rb/ cp vmlinux linuxrc /rb/
mkdir test cd test dd if=/dev/zero of=initrd bs=1024 count=8192 /sbin/mke2fs -F -b 1024 initrd mkdir mnt mount initrd -o loop ./mnt cd mnt wget http://archive.debian.org/debian-archive/dists/woody/main/disks-mipsel/current/root.tar.gz tar -xzf root.tar.gz mv debian-mipsel-root/* . rm -f debian-mipsel-root rm linuxrcmknod dev/cfa b 13 0 mknod dev/cfa1 b 13 1 mknod dev/cfa2 b 13 2 mknod dev/cfa3 b 13 3 mknod dev/cfa4 b 13 4 sed -e s/delo// usr/lib/debootstrap/scripts/woodycd .. umount mnt gzip initrd mv initrd.gz /rb/
Prepare dhcpd and tftpd on your host machine so that the routerboard can network boot it’s setup apt-get install dhcp nano -w /etc/dhcpd.conf >>default-lease-time 21600; >>max-lease-time 2100;>>host rb500 { >> hardware ethernet 00:0C:42:0A:6A:7A; #mac address of your routerboard’s eth0 >> filename “/linuxrc”; >> fixed-address 192.168.0.10; >>}
subnet 192.168.0.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; next-server 192.168.0.2; #tftp server ip option broadcast-address 192.168.0.255; option routers 192.168.0.1; }
apt-get install atftpd remove atftpd from /etc/inetd.conf killall -HUP inetd atftp –daemon /rb/
Set your machine up for masquerading so the device has network access for setup. echo “1″ > /proc/sys/net/ipv4/ip_forward iptables -F iptables -X iptables -t nat -I PREROUTING -i eth0 -j ACCEPT #internal interface iptables -I FORWARD -j ACCEPT iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE #external interface
At this point, you’re ready to start your routerboard and begin the setup. You have an initrd (initrd.gz) and a kernel (linuxrc), as well as the host serving these via DHCPD/TFTPD. Connect your RB via serial console and ensure that the it is set to Ethernet boot. The vmlinux that you made will be used after setup. You can use gtkterm/minicom on Linux, or PuTTY/Hyper Terminal on Windows. If you’re seeing nothing or a load of junk output to your console, a) make sure that the cable is correct and connected, b) Make sure your connection settings are: 57600 8N1
For the installation process via your serial terminal:
Run through installer Create 4M partition on /dev/cfa1 (0×27) Create 475M linux partition on /dev/cfa2 (ext3) Allocate remaining space to /dev/cfa3 (swap)Once install is complete of base system, execute a shell. Generate a new kernel on the host machine cd /var/www cp /usr/src/linux-2.4.30/vmlinux ./vmlinux echo “root=/dev/cfa2″ > kernel.params mipsel-linux-objcopy –add-section kernparm=kernel.params vmlinux mipsel-linux-strip vmlinux
Edit /target/etc/inittab with nano-tiny Add: t0:23:respawn:/sbin/getty -L console 115200 vt100
cd /target/ mknod dev/cfa b 13 0 mknod dev/cfa1 b 13 1 mknod dev/cfa2 b 13 2 mknod dev/cfa3 b 13 3 mknod dev/cfa4 b 13 4 reboot
And you’re done. 8-)
These are the notes that I took and corrected throughout my own installation process. I’m sure that there are corrections and a number of explainations required – please do contribute or comment. Thanks!
linux
532a
User:davidapnic
mknod
initrd
cf
mount
Kernel
Debian
ip_forward