Template:DebianOnLinkStationMini

= Install   on Buffalo LinkStation Mini =



Prerequisites

 * Buffalo LinkStation Mini (this process worked on model LS-WS1.0TGL/R1, but other models should work as well)
 * Computer with SATA drive interface and internet capability which can also boot a CD-ROM (most modern computers meet this requirement)
 * Ubuntu 9.04 Desktop Edition CD-ROM (download and burn from http://releases.ubuntu.com/jaunty/ubuntu-9.04-desktop-i386.iso)

Overview

 * First Phase
 * Remove the hard drives from the LinkStation and connect them to the SATA interface of a PC.
 * Use a live CD-ROM of Ubuntu to partition and format the hard drives, install Gentoo, and prepare the bootstrap files.
 * Second Phase
 * Reassemble the LinkStation, boot it, and login as root to complete the bootstrapping process.
 * Third Phase
 * Remove the hard drives from the LinkStation (again) and connect them to the SATA interface of a PC.
 * Use a live CD-ROM of Ubuntu to remove Gentoo and install Ubuntu from the completed bootstrapping process.
 * Fourth Phase
 * Reassemble the LinkStation and boot into a fresh system.


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

On Linkstation

 * Move power switch to "off" position
 * Disconnect power cable
 * Disconnect network cable
 * Remove cover (per instructions at Disassemble_the_LS_MINI)
 * Use a pen to mark hard drive near ethernet port (this is /dev/sda)
 * Remove both hard drives

On Computer

 * Shutdown
 * Power off
 * Attach both hard drives to SATA interface
 * Ensure that marked hard drive (/dev/sda) is connected to the first SATA interface
 * Ensure that second hard drive (/dev/sdb) is connected to the second SATA interface


 * Boot Ubuntu 9.04 Desktop Edition CD-ROM
 * Specify language (English)
 * Enter live mode ("Try Ubuntu without any change to your computer")
 * Open a new terminal window (Applications | Accessories | Terminal)

sudo bash
 * Start a new bash shell with root privileges


 * The following commands will delete all existing partitions on both hard drives and reconfigure them as follows...

PARTITION1_SIZE=128MB PARTITION2_SIZE=256MB PARTITION3_SIZE=12GB swapoff -a 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 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
 * Remove all existing partitions and repartition both drives

mkswap /dev/sda2 mkswap /dev/sdb2 swapon /dev/sda2 swapon /dev/sdb2
 * Activate swap partitions

Ignore any "/dev/MAKEDEV not found" failure message -- it is a bug which does not affect this process. export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -q -y install mdadm unset DEBIAN_FRONTEND
 * Install mdadm package (for administering software raid configuration)

cd /mnt umount /mnt/md13/boot umount /mnt/md13 umount /mnt/md14 mdadm --stop /dev/md11 mdadm --stop /dev/md13 mdadm --stop /dev/md14 echo "y" | mdadm --create --verbose /dev/md11 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 echo "y" | mdadm --create --verbose /dev/md13 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3 echo "y" | mdadm --create --verbose /dev/md14 --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4
 * Create RAID devices (/dev/md11, /dev/md13, and /dev/md14)

cd /mnt umount /mnt/md13/boot umount /mnt/md13 umount /mnt/md14 mkfs.ext3 -F /dev/md11 mkfs.ext3 -F /dev/md13 mkfs.ext3 -F /dev/md14
 * Format RAID devices

mkdir -p       /mnt/md13 mount /dev/md13 /mnt/md13 mkdir -p       /mnt/md13/boot mount /dev/md11 /mnt/md13/boot mkdir -p       /mnt/md14 mount /dev/md14 /mnt/md14
 * Mount RAID devices and create required directories

''' Do not change the order of the next 3 blocks. The correct order is Gentoo (GenLink), kernel, initrd. '''

cd /mnt/md13 rm -f /mnt/md13/GenLink-stage3.1_arm9-1.1_rc3-20080923.tar.bz2 wget http://downloads.buffalo.nas-central.org/LSPro_ARM9/Distributions/Genlink/Rootfs/GenLink-stage3.1_arm9-1.1_rc3-20080923.tar.bz2 tar --extract --verbose --same-permissions --bzip2 --file GenLink-stage3.1_arm9-1.1_rc3-20080923.tar.bz2 rm -f /mnt/md13/boot/boot
 * Install Gentoo root file system (GenLink)

cd /mnt/md13 rm -f /mnt/md13/LS-Mini-2.6.27-rc6lsmini-2008-10-09-23-39-29.tbz2 wget http://buffalo.nas-central.org/download/LSMini_ARM9/Distributions/Genlink/Kernel/LS-Mini-2.6.27-rc6lsmini-2008-10-09-23-39-29.tbz2 tar --extract --verbose --same-permissions --bzip2 --file LS-Mini-2.6.27-rc6lsmini-2008-10-09-23-39-29.tbz2
 * Install 2.6.27 kernel (uImage.buffalo) - Tried and tested, but limited modules ( no usb-storage support )

The associated kernel config file can also be found here: http://buffalo.jpfast.net/2.6.32.2/LS-Mini-2.6.32.2-2010-01-06-20-41+0900-config.bz2 cd /mnt/md13 rm -f /mnt/md13/LS-Mini-2.6.32.2-2010-01-06-20-41+0900.tgz wget http://buffalo.jpfast.net/2.6.32.2/LS-Mini-2.6.32.2-2010-01-06-20-41+0900.tgz tar --extract --verbose --same-permissions --gzip --file LS-Mini-2.6.32.2-2010-01-06-20-41+0900.tgz
 * Optionally install 2.6.32.2 kernel (uImage.buffalo) - has many more kernel modules

cd /mnt/md13 rm -f /mnt/md13/initrd-md13-armv5tejl-softfloat-1.0.tbz2 wget http://buffalo-nas-hacking.googlecode.com/files/initrd-md13-armv5tejl-softfloat-1.0.tbz2 tar --extract --verbose --same-permissions --bzip2 --file initrd-md13-armv5tejl-softfloat-1.0.tbz2
 * Install initrd (initrd.buffalo)

cp /etc/resolv.conf /mnt/md13/etc/resolv.conf
 * Configure Gentoo resolv.conf

rm -f /mnt/md13/etc/fstab echo "/dev/sda2  none      swap   sw,pri=1                     0  0" >>/mnt/md13/etc/fstab echo "/dev/sdb2  none      swap   sw,pri=2                     0  0" >>/mnt/md13/etc/fstab echo "/dev/md13  /         ext3   noatime,errors=remount-ro    0  1" >>/mnt/md13/etc/fstab echo "/dev/md11  /boot     ext3   noatime,errors=remount-ro    0  0" >>/mnt/md13/etc/fstab echo "/dev/md14  /srv      ext3   noatime,errors=remount-ro    0  0" >>/mnt/md13/etc/fstab echo "shm        /dev/shm  tmpfs  noatime,nodev,nosuid,noexec  0  0" >>/mnt/md13/etc/fstab echo "tmpfs      /tmp      tmpfs  noatime,nodev,nosuid,noexec  0  0" >>/mnt/md13/etc/fstab
 * Configure Gentoo fstab (file system table - mount points)

cd / export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -q -y install debootstrap unset DEBIAN_FRONTEND
 * Install debootstrap package (for downloading bootstrap files)

cd /mnt/md14 rm -rf /mnt/md14/bootstrap mkdir -p /mnt/md14/bootstrap debootstrap --foreign  --arch armel  --include ssh,ntp    /mnt/md14/bootstrap
 * Download   bootstrap files

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

cd /mnt umount /mnt/md13/boot umount /mnt/md13 umount /mnt/md14
 * Unmount RAID devices

shutdown -h now
 * Shutdown


 * Power off
 * Remove hard drives

On Linkstation

 * Reassemble (without cover)
 * Connect network cable
 * Connect power cable
 * Move power switch to "on" position
 * Wait for 20 minutes for Gentoo to initialize
 * Seriously, find something else to do... it takes a really long time
 * Use ssh to login as root (password = lspro)

export TZ=America/New_York date 022714172010
 * Set clock to any recent date (prevents error messages about file dates, format=MMDDhhnnYYYY)

mkdir -p /mnt/md14 mount /dev/md14 /mnt/md14 chroot /mnt/md14/bootstrap /debootstrap/debootstrap --second-stage sync
 * Complete bootstrapping process


 * Move power switch to "off" position

shutdown -h now
 * Shutdown


 * Disconnect power cable
 * Disconnect network cable
 * Remove hard drives

On Computer

 * Shutdown
 * Power off
 * Attach both hard drives to SATA interface
 * Ensure that marked hard drive (/dev/sda) is connected to the first SATA interface
 * Ensure that second hard drive (/dev/sdb) is connected to the second SATA interface


 * Boot Ubuntu 9.04 Desktop Edition CD-ROM
 * Specify language (English)
 * Enter live mode ("Try Ubuntu without any change to your computer")
 * Open a new terminal window (Applications | Accessories | Terminal)

sudo bash
 * Start a new bash shell with root privileges

Ignore any "/dev/MAKEDEV not found" failure message -- it is a bug which does not affect this process. export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -q -y install mdadm unset DEBIAN_FRONTEND
 * Install mdadm package (for administering software RAID configuration)

cd /mnt umount /mnt/md13 umount /mnt/md14 mdadm --stop /dev/md11 mdadm --stop /dev/md13 mdadm --stop /dev/md14 echo "y" | mdadm --create --verbose /dev/md11 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 echo "y" | mdadm --create --verbose /dev/md13 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3 echo "y" | mdadm --create --verbose /dev/md14 --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4
 * Create RAID devices

mkdir -p       /mnt/md11 mount /dev/md11 /mnt/md11 mkdir -p       /mnt/md13 mount /dev/md13 /mnt/md13 mkdir -p       /mnt/md14 mount /dev/md14 /mnt/md14
 * Mount RAID devices

cd /mnt/md13/lib/modules rm -f /mnt/md14/kernel-modules.tar.bz2 tar --create --verbose --preserve-permissions --bzip2 --file /mnt/md14/kernel-modules.tar.bz2.
 * Create archive of existing kernel modules

cd /mnt/md14/bootstrap rm -f /mnt/md14/bootstrap-stage2-lsmini.tar.bz2 tar --create --verbose --preserve-permissions --bzip2 --file /mnt/md14/bootstrap-stage2-lsmini.tar.bz2.
 * Create archive of bootstrap files

cd /mnt/md13 rm -rf /mnt/md13/*
 * Remove existing Gentoo installation

cd /mnt/md13 tar --extract --verbose --same-permissions --bzip2 --file /mnt/md14/bootstrap-stage2-lsmini*.tar.bz2
 * Create root file system from archive of bootstrap files

cd /mnt/md13/lib/modules mkdir -p /mnt/md13/lib/modules tar --extract --verbose --same-permissions --bzip2 --file /mnt/md14/kernel-modules.tar.bz2
 * Restore kernel modules from archive

export HOST_NAME=lsmini export HOST_ADDRESS=192.168.1.77 export HOST_NETMASK=255.255.0.0 export HOST_GATEWAY=192.168.1.1 export HOST_NETWORK=192.168.1.0
 * Prepare host settings (adjust host name and static ip as needed)

rm -f /mnt/md13/etc/network/interfaces echo "# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or" >>/mnt/md13/etc/network/interfaces echo "# /usr/share/doc/ifupdown/examples for more information." >>/mnt/md13/etc/network/interfaces echo "#" >>/mnt/md13/etc/network/interfaces echo "auto lo eth0" >>/mnt/md13/etc/network/interfaces echo "iface lo inet loopback" >>/mnt/md13/etc/network/interfaces echo "iface eth0 inet static" >>/mnt/md13/etc/network/interfaces echo " address ${HOST_ADDRESS}" >>/mnt/md13/etc/network/interfaces echo " netmask ${HOST_NETMASK}" >>/mnt/md13/etc/network/interfaces echo " gateway ${HOST_GATEWAY}" >>/mnt/md13/etc/network/interfaces
 * Configure interfaces

rm -f /mnt/md13/etc/hostname echo "${HOST_NAME}" >>/mnt/md13/etc/hostname
 * Configure hostname

rm -f /mnt/md13/etc/hosts echo "127.0.0.1 localhost" >>/mnt/md13/etc/hosts echo "${HOST_ADDRESS} ${HOST_NAME}" >>/mnt/md13/etc/hosts
 * Configure hosts

rm -f /mnt/md13/etc/hosts.allow echo "ALL : ${HOST_NETWORK}/${HOST_NETMASK}" >>/mnt/md13/etc/hosts.allow echo "ALL : 127.0.0.1" >>/mnt/md13/etc/hosts.allow
 * Configure hosts.allow

rm -f /mnt/md13/etc/fstab echo "/dev/sda2  none      swap   sw,pri=1                     0  0" >>/mnt/md13/etc/fstab echo "/dev/sdb2  none      swap   sw,pri=2                     0  0" >>/mnt/md13/etc/fstab echo "/dev/md13  /         ext3   noatime,errors=remount-ro    0  1" >>/mnt/md13/etc/fstab echo "/dev/md11  /boot     ext3   noatime,errors=remount-ro    0  0" >>/mnt/md13/etc/fstab echo "/dev/md14  /srv      ext3   noatime,errors=remount-ro    0  0" >>/mnt/md13/etc/fstab echo "shm        /dev/shm  tmpfs  noatime,nodev,nosuid,noexec  0  0" >>/mnt/md13/etc/fstab echo "tmpfs      /tmp      tmpfs  noatime,nodev,nosuid,noexec  0  0" >>/mnt/md13/etc/fstab
 * Configure fstab (file system table) Important: do not change the last column for on RAID (md) devices, any other values will prevent the device from initializing!

cp --archive /etc/resolv.conf /mnt/md13/etc/resolv.conf
 * Configure resolve.conf

rm -f /mnt/md13/etc/apt/sources.list
 * Configure sources.list

export SED_FILE='/mnt/md13/etc/shadow' export SED_SEARCH='^\s*root\:\*?\:' export SED_REPLACE='root:$6$bmlbpJYn$xAgZr6KxoRLjDcPZNDBcnMF52gZrU7xkib43LhSlAvzVS4OqmiHaxB0GInPtoaPQ2FguHQQuxM95cMfvUnYn31:' sed --regexp-extended --expression="s/${SED_SEARCH}/${SED_REPLACE}/" --in-place ${SED_FILE}
 * Change root password (new password = lsmini)

cd /mnt/md13 rm -f /mnt/md14/rootfs-lsmini.tar.bz2 tar --create --verbose --preserve-permissions --bzip2 --file /mnt/md14/rootfs-lsmini.tar.bz2.
 * Create archive of root file system

cd /mnt/md14 rm -rf /mnt/md14/bootstrap
 * Remove bootstrap files

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

cd /mnt sync umount /mnt/md11 umount /mnt/md13 umount /mnt/md14
 * Sync and unmount RAID devices

shutdown -h now
 * Shutdown


 * Power off
 * Remove hard drives

On LinkStation

 * Reassemble
 * Connect network cable
 * Connect power cable
 * Move power switch to "on" position
 * Wait for 15 minutes for initialization to complete (later reboots will be ready much faster)
 * Login with ssh as root (password = lsmini)

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

dpkg-reconfigure tzdata
 * Select timezone

date
 * Ensure that date and time are correct

passwd root
 * Change root password to something hard to guess

export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -q -y install mdadm unset DEBIAN_FRONTEND
 * Install mdadm package (ignore MAKEDEV not found failed message)

mdadm --add /dev/md11 /dev/sdb1 mdadm --add /dev/md13 /dev/sdb3 mdadm --add /dev/md14 /dev/sdb4
 * Add /dev/sdb partitions to RAID devices (/dev/sdb is intentional-- the device names get switched somehow)

export USER_NAME=visitor adduser ${USER_NAME}
 * Add user (never login as root, use sudo command instead)