If you are running Debian_4_edge, another method (wget + dpkg) is listed below.

If you are running Debian_4_edge, another method (wget + dpkg) is listed below.

−

Debian_6_installer suppose your LS-GL_pro is using the Buffalo default environmental variables and values before this installation.

+

Debian_6_installer supposes your LS-GL_pro has the Buffalo default environmental variables and values before this installation.

In Buffalo stock firmware, Debian_4_edge and Debian_6_squeeze_installer, the linux kernel is named as uImage.buffalo. So in U-boot environments,

In Buffalo stock firmware, Debian_4_edge and Debian_6_squeeze_installer, the linux kernel is named as uImage.buffalo. So in U-boot environments,

Revision as of 01:24, 16 June 2011

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).

The Debian Installer is currently working for the LS-GL series only. So no support for the LS-XHL and LS-VL or any of the RAID LS-Pro models.
This may change in the future, but depends on the development of Debian.

Introduction

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.

Preparation

Starting Point

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).

LS-GL is a ARM Debian box. There are 3 important files to boot this Debian box. They are u-boot, uImage.buffalo and initial.buffalo.

1, The U-boot bootloader and its environment are the only files in the flash memory on the board. If the u-boot bootloader were messed up, only a JTAG cable could de-brick this headless box.

2, uImage.buffalo is the linux kernel. In Buffalo stock firmware, Debian_4_edge and Debian_6_squeeze_installer, the linux kernel is named as uImage.buffalo. In Debian_5_lenny, uboot will look for uImage, and this uImage is just a link to the true kernel, e.g. uImage.2.6.29.*

3, Both uImage.buffalo and initial.buffalo are saved in /dev/sda1 EXT2 partition and this /dev/sda1 EXT2 partition is for booting only. Bebian is installed in /dev/sda2 partition. /dev/sda2 partition is not for booting.

U-boot bootloader Version and environmental variables

Debian_6 requires your uboot is higher than v1.10. All available user-built u-boot are based on v1.09. So the Buffalo stock u-boot 1.10 is the only choice. But the stock u-boot has some commands missing and other limitations. All U-boots were released in around 2008, and since that time hard-drives have changed from GB volume with 512B sectors to TB volume with 4K sectors.

If you are running Debian_5_lenny, please apt-get install uboot-envtools to configure/check U-boot.

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.

Disk Layout

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.

/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.

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.

Network

Have a look at the network configuration with ifconfig and cat /etc/network/interfaces:

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 :

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 :

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 :

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:

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.

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:

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:

Foonas-em

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 :

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 :

Then reconnect the LinkStation back to the network normally, power-on and continue with the Debian installation.

Install Debian

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.

Partition layout

Guided partitioning

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.

Manual partitioning

Choose the Manual option if you want to re-use the existing partitions and keep the main data partition untouched.

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.

Package selection

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.

Success!

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".

Tips

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.