Install Linux From NFS

How to upgrade the LinkStation HD-HLANv2 (Mipsel) to 2.6 Linux Debian using NFS (edit. This could actually be used for any Server with "debootstrap")

It took me a couple of fits and starts to plow my way through this procedure. Hopefully this write-up will help someone else.

Before starting, we need to have "telnet" access to the LinkStation and have NFS installed on it as well. Get the U-Boot package and install it. I have to compliment the developers of u-boot and say what a great bit of software it is. It's like having an OpenBoot PROM on the LinkStation and probably the last time flashing is required on the box. Being able to run a full scale OS on this little box makes you realize how powerful this thing really is. Again, my compliments.

On the LinkStation, create a "/boot" directory and copy both a 2.4 and a 2.6 kernel there as well as add the 2.6 modules to the /lib/modules directory. In the /boot directory : rename the original 2.4.20 kernel to vmlinux-2.4.20_mipsel_linkstation.gz       ln -s vmlinux-2.4.20_mipsel_linkstation.gz vmlinuz

U-boot is hardcoded to use addresses 192.168.11.150 and 192.168.11.149. If the network is not 192.168.11.0, re-compile u-boot OR add logical addresses to the servers, i.e. "ifconfig eth0:0 192.168.11.149 up" for the console server and any other address on the "11" subnet for the NFS server if they are not one and the same.

Setup NFS on a Linux Server box and apt-get install "debootstrap". Just to make it easier, here is an example /etc/exports file : /mnt/export1   *(rw,sync,no_subtree_check,no_root_squash) /mnt/export2   *(rw,sync,no_subtree_check,no_root_squash) /mnt/export3   *(rw,sync,no_subtree_check,no_root_squash)

On the Linkstation, mount "/mnt/export3" and copy the root filesystem to there. - mkdir /mnt/servername - mount serveraddress:/mnt/export3 /mnt/servername - cd / - tar -cf - (*list of directories*) | (cd /mnt/servername ; tar -xvf -) *list of directories* is everything except "mnt, proc and sys" and any other mounted file system. We just want what's on the root partition. i.e. - bin boot dev etc home ... - cd /mnt/servername - mkdir proc sys Recreate the mount points from /etc/fstab. - mkdir -p mnt/existing_mounting_points - edit etc/fstab and comment out the "/" mount point      # Not /etc/fstab but /mnt/servername/etc/fstab - cd boot - rm vmlinuz - ln -s vmlinux-2.6.22.gz vmlinuz

NFS boot the OS from /mnt/export3 - Launch u-boot. - setenv serverip 192.168.11.148 - setenv rootpath /mnt/export3 - setenv nfsfile boot/vmlinuz - run nfsload - setenv bootargs root=/dev/nfs rw nfsroot=192.168.178.148:${rootpath} ip=192.168.178.150:192.168.178.148:192.168.178.254:255.255.255.0:LShostname::off - bootm
 * 1) My NFS server is different from my Console server
 * 1) And my network block is different than u-boot defaults

At this stage you should be running exactly the same except booting via NFS and we have the ability to recover, whatever happens to the system. We are also running a 2.6 kernel which we need in order to be able to run the bootstrap from a chroot environment.

Make sure you have backups !.

Make sure you have backups !.

Make sure you have backups !.

Go back to the NFS server and create a soon to be exported partition "/mnt/export1". Create a 2Gig file in the /mnt/export1 directory. - cd /mnt/export1 - dd if=/dev/zero of=./file bs=1k count=1000k Create a filesystem on that file. - mkfs -t ext3 ./file Loop mount the file. - mount -o loop ./file /mnt/export2 Add the base installation packages. - debootstrap --arch mipsel lenny /mnt/export2 http://ftp.us.debian.org/debian

debootstrap will exit with an error : "Unable to chroot /mnt/export2 mount -t proc proc /proc" It's expected.

Mkdir /mnt/export2/boot and copy the 2.6 Mipsel kernel to /mnt/export2/boot and the modules to /lib/modules/"kernel name and version". In the /mnt/export2/boot directory. - cd /mnt/export2/boot - ln -s vmlinux-2.6.22.gz vmlinuz

Copy the bootstrap files to /mnt/export1 - cd /mnt/export2 - tar -cf - * | (cd /mnt/export1 ; tar -xvf -) Export both /mnt/export1 and /mnt/export2 - exportfs -av

Telnet into the LinkStation and let's get ready to rumble : - mkdir /mnt/servername - mount serveraddress:/mnt/export1 /mnt/servername - mkdir /mnt/servername/proc - mkdir -p /mnt/servername/dev/pts - chroot /mnt/servername mount -t proc proc /proc - chroot /mnt/servername mount -t devpts devpts /dev/pts - chroot /mnt/servername

- mkdir /mnt/bootstrap - mount -o loop ./file /mnt/bootstrap - mkdir /mnt/bootstrap/proc - mkdir -p /mnt/bootstrap/dev/pts - chroot /mnt/bootstrap mount -t proc proc /proc - chroot /mnt/bootstrap mount -t devpts devpts /dev/pts - chroot /mnt/bootstrap - touch /var/lib/dpkg/diversions - touch /var/lib/dpkg/statoverride

Edit /etc/apt/sources.list and insert : deb http://ftp.us.debian.org/debian/ lenny main contrib non-free deb-src http://ftp.us.debian.org/debian/ lenny main contrib non-free We can also edit this file from the NFS server side at /mnt/export2/etc/apt/sources.list

We now need to install the package "aptitude" using dpkg which will complain about unresolved packages. Give it what it needs till aptitude is able to run.

Run aptitude, select whatever packages we think we need and don't forget to install telnet, openbsd-inetd, ssh and login.

Reboot but this time use /mnt/export2 as our rootpath. - setenv rootpath /mnt/export2

Do realize that we can look at all the log files on servername:/mnt/export2 in order to debug the installation if we need to, which in some ways is almost better than having a console and no access to the filesystem.

When everything works to our liking, overwrite /dev/hda1 which is our original root filesystem. - mkfs -t ext3 /dev/hda1 - mount /mnt/hda1 /dev/hda1 - cd / - tar -cf - (*list of directories*) | (cd /mnt/servername ; tar -xvf -) - mkdir /mnt/hda1/proc /mnt/hda1/sys

Reboot.

Congratulations! That little box is now a full blown Server.

N.B. We need to create the files diversions and statoverride because dpkg will complain and be unable to continue at some point. We also mount /dev/pts because though dpkg would work, it will whine about it. The whole business about the loop back mount is dpkg (again) unable to work over an NFS mounted file system without rpc.lockd.