Install Ubuntu 9.04 (Jaunty Jackalope) On Buffalo Linkstation Mini

Overview
The following process converts a Buffalo Linkstation Mini (model LS-WSxxxxGL/R1) into a fully functional GNU/Linux server running Ubuntu version 9.04 (Jaunty Jackalope) with the Linux kernel (version 2.6.32.24). Here is how the process works:
 * 1) Use ACP Commander software to establish Telnet session with device
 * 2) Uncouple secondary drive partitions from existing RAID configuration
 * 3) Partition and format secondary drive, install Ubuntu 9.04, and prepare for initial boot
 * 4) Reboot device, establish SSH session with device, and complete installation

Requirements

 * 1) Buffalo LinkStation Mini models LS-WSxxxxGL/R1 running stock firmware (LS-WSXxxxxTL/R1 models will not work)
 * 2) * If your device has already been modified to run another operating system and/or firmware, you should revert to stock firmware
 * 3) * This process was tested with model LS-WS1.0TGL/R1, but other models may work as well
 * 4) Ubuntu 10.04 Desktop Edition CD-ROM (download and burn this disc image)
 * 5) Computer which can boot the Ubuntu 10.04 Desktop Edition CD-ROM and access the network successfully (most modern computers meet this requirement)

Instructions
 Note: Do not attempt to execute the following commands as a single script. Instead, copy and paste each block of commands into a shell window and monitor the resulting output for errors 



Prepare Device
 Move device switch to "off" position  Disconnect power cable from device  Disconnect all USB devices (and keep them disconnected for the duration of this process)  Attach device to network  Connect power cable to device  Move device switch to "on" position  Wait for device to finish booting (no blinking lights)

 Open device web interface (factory default address is http://192.168.11.150, or use the IP address assigned by your network)  Login (user = admin, password = password) 

 Remove existing RAID configuration (Disk Management | RAID Setup | RAID Array 1 | Change RAID Array ...)  Create new RAID1 (mirroring) array (Disk Management | RAID Setup | RAID Array 1 | RAID Mode: RAID1 ...)  Wait for "Building RAID Array" to complete</li> You may proceed immediately after the array has been built (you do not need to wait for the drive check to complete)

 Boot Ubuntu 10.04 Desktop Edition CD-ROM on computer  Select language as desired (English)  Click on "Try Ubuntu 10.04 LTS" (to use Ubuntu without making any changes to your system)

 Open a new terminal window (Applications | Accessories | Terminal )  Start a new bash shell with root privileges sudo bash

</li>

 Install OpenJDK (for running ACP Commander software) apt-get update apt-get -q -y install openjdk-6-jre

</li>

 Download ACP Commander software (acp_commander.jar) wget http://downloads.buffalo.nas-central.org/Users/rpinchbeck/lsmini/acp_commander.jar

</li>

 Determine IP address of device and assign it to environment variable (substitute appropriate IP address) export IP_ADDRESS=192.168.11.150

</li>

 Instruct device to enable Telnet and remove root password java -jar acp_commander.jar -t ${IP_ADDRESS} -o

</li>

 Establish Telnet session with device telnet ${IP_ADDRESS}

</li>

 Login as root (no password required)

 Set recent date and time (prevent error messages about file dates, format=MMDDhhnnYYYY) date 103100002010

</li>

 Kill all unnecessary processes kill -9 $(ps | grep -vE '\[.*\]|(init)|(syslogd)|(klogd)|(getty)|(telnetd)|(-sh)|(ps)|(VmSize)|(grep)|(kill)|(awk)' | awk '{print $1}')

</li>

 Free secondary drive (/dev/sdb) partitions from RAID configuration mdadm --manage /dev/md0 --fail /dev/sdb1 mdadm --manage /dev/md1 --fail /dev/sdb2 mdadm --manage /dev/md10 --fail /dev/sdb5 mdadm --manage /dev/md2 --fail /dev/sdb6

mdadm --manage /dev/md0 --remove /dev/sdb1 mdadm --manage /dev/md1 --remove /dev/sdb2 mdadm --manage /dev/md10 --remove /dev/sdb5 mdadm --manage /dev/md2 --remove /dev/sdb6

</li>

 Make sure secondary drive is not in use if hdparm -z /dev/sdb ; then echo; echo "SECONDARY DRIVE READY (/dev/sdb)"; echo; else grep sdb /proc/mounts /proc/mdstat; echo "Please check that /dev/sdb is not in use"; fi;

</li>

The following commands will delete all existing partitions on the secondary drive and reconfigure it as follows...

 Repartition secondary drive (substitute partition sizes as desired) PARTITION1_SIZE=128MB PARTITION2_SIZE=256MB PARTITION3_SIZE=12GB echo -e "d\n1\nd\n2\nd\n3\nd\n4\nn\np\n1\n\n+${PARTITION1_SIZE}\nn\np\n2\n\n+${PARTITION2_SIZE}\nn\np\n3\n\n+${PARTITION3_SIZE}\nn\np\n\n\nt\n1\nfd\nt\n2\n82\nt\n3\nfd\nt\n4\nfd\nw\n" | fdisk /dev/sdb

</li>

<li> Create and activate swap partition mkswap /dev/sdb2 swapon /dev/sdb2

</li>

<li> Create RAID volumes echo "y" | mdadm --create --verbose /dev/md11 --level=1 --raid-devices=2 missing /dev/sdb1 echo "y" | mdadm --create --verbose /dev/md13 --level=1 --raid-devices=2 missing /dev/sdb3 echo "y" | mdadm --create --verbose /dev/md14 --level=1 --raid-devices=2 missing /dev/sdb4

</li>

<li> Format RAID volumes mkfs.ext3 -F /dev/md11 mkfs.ext3 -F /dev/md13 mkfs.ext3 -F /dev/md14

</li>

<li> Mount RAID volumes mkdir -p               /mnt/lsmini mount -t ext3 /dev/md13 /mnt/lsmini mkdir -p               /mnt/lsmini/boot mount -t ext3 /dev/md11 /mnt/lsmini/boot mkdir -p               /mnt/lsmini/srv mount -t ext3 /dev/md14 /mnt/lsmini/srv

</li>

Install Ubuntu System
<li> Install root filesystem (from archive of debootstrap stage 2 files) cd /mnt/lsmini wget http://downloads.buffalo.nas-central.org/Users/rpinchbeck/lsmini/ubuntu/9.04/bootstrap-ubuntu-9.04-armel-stage2.tar.gz tar --extract --verbose --same-permissions --gzip --file /mnt/lsmini/bootstrap-ubuntu-9.04-armel-stage2.tar.gz

</li>

<li> Install custom kernel (version 2.6.32.24-generic-lsmini) cd /mnt/lsmini wget http://downloads.buffalo.nas-central.org/Users/rpinchbeck/lsmini/ubuntu/9.04/kernel-2.6.32.24-generic-lsmini.tar.gz tar --extract --verbose --same-permissions --gzip --file kernel-2.6.32.24-generic-lsmini.tar.gz

</li>

<li> Install custom boot loader (force boot from /dev/md13) cd /mnt/lsmini wget http://downloads.buffalo.nas-central.org/Users/rpinchbeck/lsmini/initrd-md13-armv5tejl-softfloat-1.0.tar.gz tar --extract --verbose --same-permissions --gzip --file /mnt/lsmini/initrd-md13-armv5tejl-softfloat-1.0.tar.gz

</li>

<li> Prepare host settings (adjust host name and IP addresses as needed) export HOST_NAME=lsmini export HOST_ADDRESS=192.168.1.77 export HOST_NETMASK=255.255.255.0 export HOST_GATEWAY=192.168.1.1

</li>

<li> Configure network interface (/etc/network/interfaces) echo "# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or" >/mnt/lsmini/etc/network/interfaces echo "# /usr/share/doc/ifupdown/examples for more information." >>/mnt/lsmini/etc/network/interfaces echo "#"                       >>/mnt/lsmini/etc/network/interfaces echo "auto lo eth0"            >>/mnt/lsmini/etc/network/interfaces echo "iface lo inet loopback"  >>/mnt/lsmini/etc/network/interfaces echo "iface eth0 inet static"  >>/mnt/lsmini/etc/network/interfaces echo " address ${HOST_ADDRESS}" >>/mnt/lsmini/etc/network/interfaces echo " netmask ${HOST_NETMASK}" >>/mnt/lsmini/etc/network/interfaces echo " gateway ${HOST_GATEWAY}" >>/mnt/lsmini/etc/network/interfaces rm -f /mnt/lsmini/etc/udev/rules.d/[0-9]*-persistent-net.rules # remove all persistent network devices (force auto detection of eth0)

</li>

<li> Configure host name (/etc/hostname) echo "${HOST_NAME}" >/mnt/lsmini/etc/hostname

</li>

<li> Configure mapping from address to host name (/etc/hosts) echo "127.0.0.1 localhost"          >/mnt/lsmini/etc/hosts echo "${HOST_ADDRESS} ${HOST_NAME}" >>/mnt/lsmini/etc/hosts

</li>

<li> Configure mount points (/etc/fstab) echo "/dev/sdb2  none      swap   sw,pri=1                     0  0"  >/mnt/lsmini/etc/fstab echo "/dev/md13  /         ext3   noatime                      0  0" >>/mnt/lsmini/etc/fstab echo "/dev/md11  /boot     ext3   noatime                      0  0" >>/mnt/lsmini/etc/fstab echo "/dev/md14  /srv      ext3   noatime                      0  0" >>/mnt/lsmini/etc/fstab echo "shm        /dev/shm  tmpfs  noatime,nodev,nosuid,noexec  0  0" >>/mnt/lsmini/etc/fstab

</li>

<li> Configure network name resolution (/etc/resolv.conf) cp -a /etc/resolv.conf /mnt/lsmini/etc/resolv.conf

</li>

<li> Change root password (new password = lsmini) export SED_FILE='/mnt/lsmini/etc/shadow' export SED_SEARCH='^\s*root\:\*?\:' export SED_REPLACE='root:$6$bmlbpJYn$xAgZr6KxoRLjDcPZNDBcnMF52gZrU7xkib43LhSlAvzVS4OqmiHaxB0GInPtoaPQ2FguHQQuxM95cMfvUnYn31:' sed -r "s/${SED_SEARCH}/${SED_REPLACE}/" -i ${SED_FILE}

</li>

<li> Prepare for reboot (Overwrite factory-installed boot files with custom ones) cd /mnt/lsmini rm -rf /boot/* cp -a /mnt/lsmini/boot/* /boot/

</li>

<li> Wait for RAID synchronization to complete while egrep -iq '(recovery)|(resync)' /proc/mdstat; do    clear cat /proc/mdstat sleep 5 done clear cat /proc/mdstat sync

</li>

<li> Unmount RAID volumes sync cd /mnt umount /mnt/lsmini/boot umount /mnt/lsmini/srv umount /mnt/lsmini

</li>

<li> Reboot device reboot; logout

</li>

Configure Ubuntu System
<li> Wait for device to finish booting (no blinking lights)

<li> Assign new IP address to environment variable export IP_ADDRESS=192.168.1.77

</li>

<li> Use SSH to login as root (password = lsmini) ssh root@${IP_ADDRESS}

</li>

<li> Change root password to something hard to guess passwd root

</li>

<li> Configure default system locale (adjust LANG variable to suit your needs, format = language_COUNTRY.ENCODING) export LANG=en_US.UTF-8 locale-gen ${LANG} update-locale LANG="${LANG}"

</li>

<li> Select timezone dpkg-reconfigure tzdata

</li>

<li> Ensure that date and time are correct date

</li>

<li> Make sure primary drive is not in use (/dev/sda) if hdparm -z /dev/sda ; then echo; echo "PRIMARY DRIVE READY (/dev/sda)"; echo; else grep sda /proc/mounts /proc/mdstat; echo "Please check that /dev/sda is not in use"; fi;

</li>

<li> Repartition primary drive (must have same partition sizes as secondary drive) PARTITION1_SIZE=128MB PARTITION2_SIZE=256MB PARTITION3_SIZE=12GB echo -e "d\n1\nd\n2\nd\n3\nd\n4\nn\np\n1\n\n+${PARTITION1_SIZE}\nn\np\n2\n\n+${PARTITION2_SIZE}\nn\np\n3\n\n+${PARTITION3_SIZE}\nn\np\n\n\nt\n1\nfd\nt\n2\n82\nt\n3\nfd\nt\n4\nfd\nw\n" | fdisk /dev/sda

</li>

<li> Format and activate swap partition on primary drive mkswap /dev/sda2 swapon /dev/sda2

</li>

<li> Automatically mount swap partition at boot echo "/dev/sda2   none      swap   sw,pri=2                     0  0"  >>/etc/fstab

</li>

<li> Add primary drive partitions to RAID volumes (/dev/md11, /dev/md13, and /dev/md14) echo "y" | mdadm --manage /dev/md11 --add /dev/sda1 echo "y" | mdadm --manage /dev/md13 --add /dev/sda3 echo "y" | mdadm --manage /dev/md14 --add /dev/sda4

</li>

<li> Disable login terminals (prevent error messages in /var/log/syslog every 10 seconds about respawning) export SED_FILE='/etc/default/console-setup' export SED_SEARCH='(^\s*ACTIVE_CONSOLES="/dev/tty\[[0-9]\-[0-9]\]"\s*$)' export SED_REPLACE='#\1' sed -r "s~${SED_SEARCH}~${SED_REPLACE}~g" -i ${SED_FILE} rm -f /etc/event.d/tty[1-9]

</li>

<li> Configure package sources (/etc/apt/sources.list) echo "deb     http://ports.ubuntu.com    jaunty             main universe"  >/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com    jaunty             main universe" >>/etc/apt/sources.list echo "deb     http://ports.ubuntu.com    jaunty-security    main universe" >>/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com    jaunty-security    main universe" >>/etc/apt/sources.list echo "deb     http://ports.ubuntu.com    jaunty-updates     main universe" >>/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com    jaunty-updates     main universe" >>/etc/apt/sources.list

</li>

<li> Update package lists apt-get update

</li>

<li> Wait for RAID synchronization to complete while egrep -iq '(recovery)|(resync)' /proc/mdstat; do    clear cat /proc/mdstat sleep 5 done clear cat /proc/mdstat sync

</li>

<li> Restart device reboot; logout;

</li>

'''Congratulations! You should now have a working Ubuntu 9.04 server running on a Buffalo Linkstation Mini.'''

Extras
<li> Add user (never login as root again, use sudo command instead) export USER_NAME=visitor adduser ${USER_NAME}

</li>

<li> Allow user to become super user (using sudo command) echo "${USER_NAME}   ALL=(ALL) ALL" >>/etc/sudoers

</li>

</ol>