Install Debian on the Linkstation Pro/Live
Starting with Debian 6.0, "Squeeze", Debian supports the LinkStation Pro/Live out of the box and can be installed using debian-installer. The following guide was started by Alan Dennis (adennisa15), based on an earlier guide by Ryan Tandy (tarpman), who produced the Debian Installer for the LinkStation. The first guide was based on the Debian on Kurobox Pro Installation Guide by Martin Michlmayr (tbm) and Per Andersson (avtobiff).
- 1 Introduction
- 2 Preparation
- 3 Run the Debian preparation script
- 4 Install Debian
- 5 Success!
- 6 Tips
This guide can be used to install Debian 6 ("Squeeze") on a LinkStation Pro or LinkStation Live NAS. The process does not normally require any hardware modifications (such as a serial lead) or disassembly of the LinkStation, although you may need to resort to these and other recovery methods if things go wrong during the install.
With care, the process can preserve the existing contents of the disk (just updating "Linux"), or it can be used to wipe everything and return to a clean disk. It is the ideal way to bring a FreeLink installation, which is based on Debian 4.0 "Etch" from 2007, up to date and is a simple way of getting around the problems caused by the architecture change, from "arm" (FreeLink/Etch) to "armel" (Lenny, Squeeze etc), which prevents use of a simple "dist-upgrade".
To use the process, the LinkStation needs to already be running either an "open" Linux distribution or "opened stock firmware". FreeLink (as installed by following the excellent guide at FreeLink_for_the_LinkStation_PRO/LIVE) is used as the starting point for this guide. If the LinkStation is running stock firmware or some other Linux distribution and you want to switch to Debian Squeeze, then these instructions should be OK, but you may need to adapt them slightly to your configuration. There are no promises, but, exercise caution and you should be fine.
As you can see from the contents above, the process is broken down into a number of preparation steps, followed by the debian-installer steps themselves. Not all of the preparation steps are strictly necessary to achieve a successful installation, but they will be required if something goes wrong and you end up with a LinkStation that will not boot. Skip them at your own risk!
It is well worth becoming familiar with the Debian Installation Guide. Several references below link to specific sections of the English version of this document, but the previous link also has translations in many other languages as well as PDF and plain text formats in addition to HTML. Use the "EABI ARM" architecture versions.
The first thing to do it is to find out just where you are starting from. If this is the same place as this guide then you know you will be able to follow this guide very closely. If not, then you will know that you may have to adapt some of the instructions. Providing an accurate description of the starting point will also help guys provide help in the forum if you need it. Keep a record of all information obtained as you will need it later. Your ssh or telnet client will probably have a way of logging all output to a file - it is a good idea to use this to keep a record of everything that happened!
First, connect and login to the LinkStation and become root (you should have a # prompt rather than a $ prompt).
Enter the commands uname -a and cat /etc/debian_version :
root@LINKSTATION1:~# uname -a Linux LINKSTATION1 18.104.22.168-arm1 #77 Tue Dec 5 22:23:46 CST 2006 armv5tejl GNU/Linux root@LINKSTATION1:~# cat /etc/debian_version 4.0 root@LINKSTATION1:~# fw_printenv ... buffalo_ver=BOOTVER=1.10 ... root@LINKSTATION1:~#
If the kernel version is 2.6.12 and the Debian version is 4.0, then you have got the original FreeLink which is Debian 4.0 ("Etch"). If /etc/debian_version does not exist, then it is something other than Debian / FreeLink.
Next we will look at the disk layout. This information is important if you want to retain the data and just update Linux to Squeeze. It is not so important if you are just going to wipe everything and start again.
Enter the commands fdisk -l and df -Th :
root@LINKSTATION1:~# fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 37 297171 83 Linux /dev/sda2 38 1254 9775552+ 83 Linux /dev/sda4 1255 60801 478311277+ 5 Extended /dev/sda5 1255 1291 297171 82 Linux swap / Solaris /dev/sda6 1292 60801 478014043+ 83 Linux root@LINKSTATION1:~# df -Th Filesystem Type Size Used Avail Use% Mounted on rootfs rootfs 9.3G 702M 8.7G 8% / /dev/root.old ext2 13M 11M 2.3M 83% /initrd /dev/root xfs 9.3G 702M 8.7G 8% / tmpfs tmpfs 100K 0 100K 0% /lib/init/rw tmpfs tmpfs 62M 0 62M 0% /dev/shm tmpfs tmpfs 10M 224K 9.8M 3% /tmp /dev/sda1 ext3 282M 15M 253M 6% /boot /dev/sda6 ext3 449G 20G 430G 5% /mnt/disk1 root@LINKSTATION1:~#
The important things to note are:
- /dev/sda1 is mounted at /boot, is ext3 and is 282M
- /dev/root is 9.3G
- /dev/sda6 is mounted at /mnt/disk1, is ext3 and is 449G and has 430G free
- /dev/sda5 is the swap partition and is the same size as /dev/sda1 - 297171 blocks or 282M
(For completeness, sda2 is the root partition, although it does not explicitly say so above. sda4 is an extended partition that contains sda5 and sda6, it is not an extra 400+GB of free space!)
To retain the data, "manual partitioning" will be used in the debian-installer and the partition table will not be changed. This means that the existing partitions need to be big enough for Squeeze. If they are currently too small, you will either have to resize things, or just accept that you will have to wipe everything and start again.
Once installed, Squeeze only requires about 20M for /boot, although it makes sense to have a fair bit more than this for working space during upgrades etc. The 282M here is fine.
For the root partition, the installation guide requires an absolute minimum of 650MB, but recommends at least 1GB as being more realistic. Appendix C provides more detail about what is required for general Debian partitioning. Note however that the instructions below for the LinkStation simply put everything (except boot and swap) into the root partition. Appendix D.2 provides details of space needed for installing various tasks (web server, print server, mail server etc). The 10G here is fine.
As a rough rule of thumb, a swap size of twice the memory size (which is 128M - look at MemTotal in the output of cat /proc/meminfo) is adequate. So 282M here is fine.
As part of manual partitioning, the existing boot and root partitions will be reformatted and any data in them will be lost. It is a good idea to back these up as they will likely contain valuable configuration information that will prove useful when it comes to configuring stuff in Squeeze once installation is complete. If there is enough free space on sda6 then that can be used as the backup space. If not, then you will either need to backup to an external USB drive or another area over the network somewhere.
Finally, have a look at /etc/fstab :
root@LINKSTATION1:~# cat etc/fstab # /etc/fstab: static file system information. # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=20 0 0 tmpfs /tmp tmpfs size=10M,mode=1777 0 0 /dev/sda5 swap swap defaults 0 0 /dev/sda1 /boot ext3 defaults,noatime,errors=remount-ro 0 1 /dev/sda6 /mnt/disk1 ext3 defaults,noatime,nodiratime 0 0 root@LINKSTATION1:~#
The important thing to note is how sda6 is mounted. You will need to put this information back into the Squeeze version of this file to get the data partition mounted again once the installation is complete.
Have a look at the network configuration with ifconfig and cat /etc/network/interfaces:
root@LINKSTATION1:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:16:01:FC:1E:AF inet addr:192.168.1.130 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2658309 errors:0 dropped:0 overruns:0 frame:0 TX packets:2887441 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:512 RX bytes:392877956 (374.6 MiB) TX bytes:738735567 (704.5 MiB) Interrupt:21 eth0:0 Link encap:Ethernet HWaddr 00:16:01:FC:1E:AF inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:21 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:278852 errors:0 dropped:0 overruns:0 frame:0 TX packets:278852 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:35281886 (33.6 MiB) TX bytes:35281886 (33.6 MiB) root@LINKSTATION1:~# cat /etc/network/interfaces # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth0:0 iface eth0:0 inet static address 192.168.1.12 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 22.214.171.124 126.96.36.199 root@LINKSTATION1:~#
It is quite likely that your interfaces file may look very different!
The important thing here is that debian-installer will use DHCP to obtain an ip-address. If your interfaces file contains the line iface eth0 inet dhcp then you are already fine. Instead, if it contains iface eth0 inet static then the LinkStation is using a static ip-address and it will be a good idea to get the LinkStation using DHCP before you run debian-installer. A safe method (suggested by Andre in the forum) is to add an alias to eth0 so that it has two addresses, one static and one DHCP as shown above. (This would not work for me with eth0:0 as DHCP, only with eth0 as DHCP and eth0:0 as static.) After modifying the interfaces file, use /etc/init.d/networking restart to restart networking and then ifconfig again to see the DHCP ip-address. Test that you can establish new ssh connections to both the static and DHCP ip-addresses. If you lose contact with the LinkStation, have a look for which ip-address has been assigned by the DHCP server (which may be part of a home DSL/Cable router etc) by looking in the DHCP server for your HWaddr that was shown earlier in the ifconfig output. This will often be called the MAC Address or similar in the DHCP server.
Make a backup
If you are planning to wipe the disk and start again during the install and you have any data you want to keep, then you will need to backup to an external USB drive or another space somewhere on the network. If you are planning to keep the data and just update the Linux then you could just backup the partitions that will get wiped onto the data partition. However, even in this case, an external backup will provide insurance against things going wrong and you accidentally trashing the data partition.
If you have space and just want to backup to the data partition something like this will do it :
root@LINKSTATION1:~# dd if=/dev/sda1 of=/mnt/disk1/backup-boot-20101114 bs=65536 4643+1 records in 4643+1 records out 304303104 bytes (304 MB) copied, 22.2649 seconds, 13.7 MB/s root@LINKSTATION1:~# dd if=/dev/sda2 of=/mnt/disk1/backup-root-20101114 bs=65536 152743+1 records in 152743+1 records out 10010165760 bytes (10 GB) copied, 949.257 seconds, 10.5 MB/s root@LINKSTATION1:~#
Clearly, you can substitute whatever path and file in the of= part you need for wherever your data partition is. This will create a bit-by-bit exact copy of the partitions. These can be used to restore the partitions if necessary (just switch the input file (if=) and output file arguments around), or they can be loop mounted somewhere else and their contents accessed, for example :
mkdir /mnt/boot-bu mount -o loop /mnt/disk1/backup-boot-20101114 /mnt/boot-bu
will mount the boot backup at /mnt/boot-bu. Note that backing up the root partition takes a while and if the LinkStation is doing things that write to the partition, then you may end up with an inconsistent backup containing a mixture of areas before and after the write. It is a good idea to test loop mounting the backup to make sure it is usable before you continue. Something like diff -qr /mnt/boot-bu /boot can be used to verify the backup against the source if you really want to make sure.
Also, note that if the root partition is xfs, then you will probably encounter the error mount: wrong fs type, bad option, bad superblock etc along with XFS: Filesystem loop1 has duplicate UUID - can't mount in the kernel logs (dmesg | tail). In this case, add -o nouuid to the mount command.
There are many methods for backing up externally. Google is your friend if you are unsure (other search engines are available).
Another thing that you may want to backup is the Debian package configuration, doing so may make re-installation of packages and their customisation easier after the Squeeze install :
root@LINKSTATION1:~# dpkg --get-selections > /mnt/disk1/dpkg-get-selections-20101114 root@LINKSTATION1:~# debconf-get-selections > /mnt/disk1/debconf-get-selections-20101114 root@LINKSTATION1:~#
debconf-get-selections is in the debconf-utils package and may need installing first (aptitude install debconf-utils).
dpkg --get-selections provides a list of all the installed/deinstalled packages. The opposite commands to use in Squeeze are :
dpkg --set-selections < /mnt/disk1/dpkg-get-selections-20101114 apt-get dselect-upgrade
However, this is probably a bad idea as there will be many versioned packages in FreeLink/Etch that do not exist in Squeeze as they have been replaced by a newer version or you may not want to install the old version. gcc-3.3 and libdb4.x are examples that spring to mind. A better idea might be to perform a --get-selections in Squeeze and use a diff between the two lists as the basis for manually installing packages or maybe modifying the FreeLink list before using it automatically as above.
debconf-get-selections provides a list of all the answers that were provided when installing/configuring packages. The opposite command to use in Squeeze is debconf-set-selections, before installing any packages. But again, this may be a bad idea because of the differences between packages in FreeLink and Squeeze. However, it may be useful to look in the generated file to find how a package was previously configured when re-installing it in Squeeze.
Note that you will need to re-install all of your existing packages in Squeeze. It is not usually possible to re-use binaries from FreeLink/Etch as these will be arm binaries and these are not usually compatible with the armel binaries used in Squeeze.
Download the installer
The installer for the LinkStation platform is provided as a kernel (uImage.buffalo) and ramdisk (initrd.buffalo) that contain a minimal installation environment. Most of the installer components are downloaded from the Internet on an as-needed basis.
On your LinkStation, make a backup of the existing kernel and ramdisk and download the installer images:
cd /boot mv uImage.buffalo uImage.buffalo.old mv initrd.buffalo initrd.buffalo.old wget http://http.us.debian.org/debian/dists/stable/main/installer-armel/current/images/orion5x/network-console/buffalo/lspro/uImage.buffalo wget http://http.us.debian.org/debian/dists/stable/main/installer-armel/current/images/orion5x/network-console/buffalo/lspro/initrd.buffalo wget http://http.us.debian.org/debian/dists/stable/main/installer-armel/current/images/orion5x/network-console/buffalo/lspro/config-debian
If you prefer, you can use a local mirror in place of http.us.debian.org.
Note that you should probably copy the backed up kernel and ramdisk to an external location because if things go wrong, they will be needed to perform a TFTP recovery.
DNS in Buffalo firmware
If your LinkStation is still running the original Buffalo firmware, DNS resolution may not work. To fix this, edit /etc/nsswitch.conf and change the line
hosts: files dns
An easy way to make the change is to issue the following command which overwrites the entire file:
echo "hosts: files dns" > /etc/nsswitch.conf
If you do not have a working system on your LinkStation or you do not want to put the installer on your hard disk, the images can also be booted via TFTP.
Run the Debian preparation script
The config-debian script checks the LinkStation and prepares it for booting the installer.
While still in /boot on the LinkStation, the following command will run the script:
You should see:
Saving U-Boot environment to ubootenv.bak... done. Changing U-Boot environment... done. Please reboot your LinkStation.
However, you may see one of these error messages (or similar) :
- You have to create an ext2 filesystem on /dev/sda1
- Fix: U-Boot requires /dev/sda1 to be ext2 or ext3 in order to boot from it.
- You have to download the uImage.buffalo file from the debian-installer for LinkStation Pro/Live, and put it in /boot
- You have to download the initrd.buffalo file from the debian-installer for LinkStation Pro/Live, and put it in /boot
- Fix: You need to perform the wget commands above in "Download the installer".
- Program fw_setenv not found, cannot modify U-Boot environment...
- Configuration file for fw_printenv not found.
- No tool found for modifying U-Boot environment...
- Fix: U-boot tools are missing, see below.
- Unable to detect Buffalo bootloader version. Please ensure that your bootloader supports automatic initrd position/size detection.
- Fix: The bootloader being used has not been recognised. You are on your own from this point on! If you continue, please post your experiences (good or bad) in the forum as any information about other bootloaders will be useful in updating the preparation script in the future.
- Incompatible bootloader version detected. Please update to the latest firmware version.
- Fix: If the U-Boot version is not 1.10 or later, then it will need to be updated. Firmware can be obtained from Buffalo's downloads site, however, it cannot be installed with FreeLink, only with stock firmware. To find out which version is installed, run the command fw_printenv and look for the value of buffalo_ver:
root@LINKSTATION1:~# fw_printenv ... buffalo_ver=BOOTVER=1.10 ... root@LINKSTATION1:~#
Missing U-boot tools
The preparation script depends on having tools available for modifying the U-boot configuration. If you don't have those (for example, you are currently running FreeLink) there are a couple of ways to obtain them.
Install uboot-envtools from Lenny
This method will not usually work for FreeLink. fw_printenv will work, but fw_setenv with the 2.6.12 kernel and drivers is unable to erase the flash when writing the modified U-Boot configuration. It may work with other versions and it is worth giving it a go as it is easier than the alternative TFTP/Foonas-em method below.
The uboot-envtools package from Lenny can be installed on an Etch system by ignoring the libc6 dependency:
wget http://ftp.debian.org/debian/pool/main/u/uboot-envtools/uboot-envtools_20080520-4_arm.deb dpkg --force-depends-version -i uboot-envtools_20080520-4_arm.deb cp /usr/share/doc/uboot-envtools/examples/linkstation_pro_live.config /etc/fw_env.config
If the above commands completed correctly, you should be able to view your u-boot configuration:
Try sh config-debian again and see if it works. If it does not, then you will have to use the TFTP/foonas-em method below.
If you get a message like this:
MTD erase error on /dev/mtd0: Inappropriate ioctl for device Error: can't write fw_env to flash done. Please reboot your Linkstation.
DO NOT reboot your Linkstation! You still need to modify the bootargs_root parameter which didn't work in config-debian because the fw_setenv command doesn't work. Please try the nvram-method below.
Use nvram from the buffalo-initrd
If you're running FreeLink, chances are that the original buffalo-initrd is mounted at /initrd. Type mount and check for a line like this:
/dev/root.old on /initrd type ext2 (rw)
Change into this environment with
# chroot /initrd/
Now you can use the nvram command to modify bootargs_root:
bash-2.05b# nvram -c get bootargs_root # check current value bootargs_root=root=/dev/sda2 rw initrd=0x00800040,15M panic=5 bash-2.05b# nvram -c set bootargs_root "root=/dev/sda2 rw panic=5" >nvram_set:bootargs_root = root=/dev/sda2 rw panic=5 bash-2.05b# nvram -c printenv # verify settings ... 33: [bootargs_root=root=/dev/sda2 rw panic=5] ...
Now you're good to go and you can reboot your linkstation.
If you don't have any commands installed for modifying the U-boot configuration (the script checks for nvram and fw_setenv) you can use foonas-em as a platform for running the script, since it includes fw_setenv.
Briefly (see the full instructions at foonas.org) you will need a tftp server running on a Windows or Linux PC, configured with an ip-address 192.168.11.1. (A wi-fi laptop with an unused Ethernet port is ideal.) Disable any firewalls (or add appropriate rules for TFTP port 69). Copy initrd.buffalo from the LinkStation to the base directory that the tftp server is using. Download the foonas-em image to the same place and call it uImage.buffalo. Execute the following commands on the LinkStation :
root@LINKSTATION1:~# cd /boot root@LINKSTATION1:/boot# mv uImage.buffalo uImage.buffalo.temp root@LINKSTATION1:/boot# mv initrd.buffalo initrd.buffalo.temp root@LINKSTATION1:/boot# poweroff
Connect the LinkStation to the PC with either a "straight-through" or "crossed" Ethernet cable and power it on. The LinkStation will be unable to boot (because uImage.buffalo and initrd.buffalo are now missing) and will indicate this with a repeated "nee-naa-nee-naa" emergency tone and much front panel light flashing! Eventually, it should fetch both files from the tftp server (the TftpD32 server on Windows includes progress dialogs so you can see this happening) and boot into foonas-em. Telnet to the LinkStation on 192.168.1.150 (assuming it has not picked up some other address using DHCP from the PC) using the username root and password hydr0g3n. You can then :
mount /dev/sda1 /boot cd /boot mv uImage.buffalo.temp uImage.buffalo mv initrd.buffalo.temp initrd.buffalo sh config-debian poweroff
Then reconnect the LinkStation back to the network normally, power-on and continue with the Debian installation.
Once the uImage and initrd are in /boot, rebooting the LinkStation will automatically start debian-installer. The installer takes 1-2 minutes to start and beeps once when it is ready. The LinkStation acquires an IP address using DHCP (picking up static IP configuration from the Buffalo firmware is not possible at this time). It starts network-console automatically and is reachable over SSH with username installer and password install.
From this point on the installation takes about 50 minutes and follows the standard Debian procedure as laid out in the installation guide. The installer automatically performs tasks needed to make the LinkStation bootable, including updating uImage.buffalo and initrd.buffalo and installing micro-evtd for fan and watchdog control.
Choose the option Guided - use entire disk to automatically partition the disk, erasing any data already on it. The installer automatically creates a layout that is compatible with U-boot's requirements.
Choose the Manual option if you want to re-use the existing partitions and keep the main data partition untouched.
The partition table shown should look something like this:
SCSI (0,0,0) (sda) - 500.1 GB ATA SAMSUNG HD501LJ > #1 primary 304.3 MB B F ext3 /boot > #2 primary 10.0 GB F ext3 / > #5 logical 304.3 MB F swap swap > #6 logical 489.5 GB ext3
If not, select each partition in turn and configure as follows:
Partition #1 Use as: Ext3 journaling file system Format the partition: yes, format it Mount Point: /boot Mount options: defaults Label: none Reserved blocks: 5% Typical usage: standard Bootable flag: on
Partition #2 Use as: Ext3 journaling file system Mount Point: / Mount options: defaults Label: none Reserved blocks: 5% Typical usage: standard Bootable flag: off
Note that U-Boot ignores the Bootable flag on partition #1, but the debian-installer will display a warning if it is not set so it is easiest to set it for a quiet life.
Do not attempt to mount or format partition #6 (the data partition) if you want to keep the data on it.
Select the OpenSSH server task to guarantee that you can log into the LinkStation via SSH after the installation completes.
By default the Standard task is selected for installation. This includes 80+ common packages you might expect to find installed, including dnsutils, exim4, ftp, perl, python, telnet etc. It also includes the bash-completion package, which can make logins take a very long time on the slow LinkStation. Leave it selected or deselect it, as you prefer.
After following these steps you should have a Debian system running on your LinkStation and you can use apt-get or aptitude to install additional software. See Chapter 8 of the Installation guide for "next steps and where to go from here".
- If the bash-completion package was installed and logins are taking a long time, temporarily disable it with mv /etc/profile.d/bash_completion.sh /etc/profile.d/bash_completion.sh.no or remove it completely with aptitude remove bash-completion.
- Install ntp or ntpdate to synchronise the LinkStation clock with clocks on the internet.
- Install samba to allow access to the LinkStation as a Windows network share.
- If a web-server (apache2 etc) is installed, install dpkg-www for browser based package management and dwww for browser based access to the Debian documentation and manuals.
- Use cron-apt for automatic updates.