Difference between revisions of "Debian Lenny on LS-WXL"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
(Created page with '{{Warning|Work in progress}} This guide will explain how to install Debian GNU/Linux "Lenny" on the LinkStation™ Duo LS-WXL using the Debian "debootstrap" procedure. The origin…')
 
m (Add category `Lenny`.)
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Warning|Work in progress}}
 
 
This guide will explain how to install Debian GNU/Linux "Lenny" on the LinkStation™ Duo LS-WXL using the Debian "debootstrap" procedure. The original kernel will be preserved, as well as the original bootloader (U-Boot).
 
This guide will explain how to install Debian GNU/Linux "Lenny" on the LinkStation™ Duo LS-WXL using the Debian "debootstrap" procedure. The original kernel will be preserved, as well as the original bootloader (U-Boot).
 +
 +
Note that there's also a page on setting up Debian Squeeze that may be derived from this one: [[Debian Squeeze on LS-WXL]]
 +
 +
For Debian Squeeze on the LS-CHLv2 see [[Debian Squeeze on LS-CHLv2]], which is largely based on this document and [[Debian_Squeeze_on_'V'_and_'X'_Series_(LS-WXL_and_others)]]
  
 
Basic idea:
 
Basic idea:
Line 8: Line 11:
 
* replace the old filesystem with the new one  
 
* replace the old filesystem with the new one  
  
This guide will ask you to reformat partitions, delete existing data, etc. All of these actions may void your warranty, destroy your data, etc. In general you can receive help from the community of from the Buffalo forums but bear in mind that every problem you may encounter is ultimately up to you to solve. You do it at your own risk.
+
This guide will ask you to reformat partitions, delete existing data, etc. All of these actions may void your warranty, destroy your data, etc. In general you can receive help from the community or from the Buffalo forums but bear in mind that every problem you may encounter is ultimately up to you to solve. You do it at your own risk.
  
 
This guide is based on the procedure for installing [[Debian_Lenny_on_LS-CHLv2|Debian on LS-CHLv2]] and was developed using the LS-WXL/E version. This guide should also work for the LS-WXL/R1 variants.
 
This guide is based on the procedure for installing [[Debian_Lenny_on_LS-CHLv2|Debian on LS-CHLv2]] and was developed using the LS-WXL/E version. This guide should also work for the LS-WXL/R1 variants.
Line 29: Line 32:
  
 
Follow [[Open_Stock_Firmware_LS-WXL|this guide]] to get telnet root console access to the LS.
 
Follow [[Open_Stock_Firmware_LS-WXL|this guide]] to get telnet root console access to the LS.
 +
 +
Follow [http://buffalo.nas-central.org/wiki/Category:LS-WXL#Gain_Root_Access this guide] to SSH as root to the LS.
  
 
==Backup the LS==
 
==Backup the LS==
Line 91: Line 96:
 
  cd /dev
 
  cd /dev
 
  MAKEDEV generic
 
  MAKEDEV generic
ln -s /bin/MAKEDEV .    # mdadm install expects to see this
 
 
  umount /proc
 
  umount /proc
  
 
This will also take some time while all device nodes are created.
 
This will also take some time while all device nodes are created.
 +
 +
===Apt setup===
 +
 +
Apt will complain about packages without verification if this step is not performed.
 +
 +
Edit /etc/apt/sources.list, use the appropriate debian [http://www.debian.org/mirror/list mirror]
 +
 +
# Debian packages for lenny
 +
deb http://ftp.us.debian.org/debian lenny main
 +
# Uncomment the deb-src line if you want 'apt-get source'
 +
# to work with most packages.
 +
# deb-src http://ftp.us.debian.org/debian lenny main
 +
 +
deb http://security.debian.org/ lenny/updates main contrib
 +
# deb-src http://security.debian.org/ lenny/updates main contrib
 +
 +
deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib
 +
# deb-src http://volatile.debian.org/debian-volatile lenny/volatile main contrib
 +
 +
 +
Perform an update
 +
 +
apt-get update
 +
 +
The final upgrade step can be performed later once the installation is finished.
 +
 +
===Install mdadm===
 +
 +
ln -s /sbin/MAKEDEV /dev    # mdadm install expects to see this
 +
apt-get --no-install-recommends install mdadm
 +
 +
Ignore the "(failed to load MD subsystem)" error.
 +
 +
Update mdadm.conf:
 +
 +
exit                                                # exit from chroot
 +
cp /etc/mdadm.conf debian-armel-rootfs/etc/mdadm/
 +
LANG=C chroot debian-armel-rootfs/ /bin/bash        # back again
  
 
===Configuring locale===
 
===Configuring locale===
Line 105: Line 147:
 
===Editing /etc/fstab===
 
===Editing /etc/fstab===
  
Edit the static filesystem table file /etc/fstab (e.g. with nano) and make it look like this:
+
Create /etc/fstab:
  
 +
cat >/etc/fstab <<EOF
 
  # /etc/fstab: static file system information.
 
  # /etc/fstab: static file system information.
 
  #
 
  #
  # file system   mount point   type   options                 dump pass
+
  # file system mount point type options dump pass
  /dev/sda2        /             xfs     defaults,noatime         0    1
+
  /dev/md2 / xfs defaults,noatime 0    1
  /dev/sda1        /boot         ext3   ro,nosuid,nodev         0    2
+
  /dev/md0 /boot ext3 rw,nosuid,nodev 0    2
  /dev/sda5        none         swap   sw                       0    0
+
  /dev/md10 none swap sw 0    0
/dev/sda6        /home        xfs    defaults,noatime        0    3
+
  proc /proc proc defaults 0    0
  proc             /proc         proc   defaults                 0    0
+
  EOF
  devpts          /dev/pts      devpts  gid=4,mode=620 0    0
+
   
  tmpfs            /tmp          tmpfs  defaults                0    0
+
 
sysfs            /sys          sysfs  defaults                0    0
+
Partition '''/dev/md2''' contains the shared directory which will be used as a temporary root before the final installation. Make sure that a backup of this partition is made if it contains important data.
  
#/dev/ram1 on /mnt/ram type tmpfs (rw)
+
If the LS has only a single drive attached, change '''/dev/md2''' to either '''/dev/sda6''' or '''/dev/sdb6''' depending on which slot the drive is inserted.
  
 
===Network===
 
===Network===
Line 145: Line 188:
 
  #    gateway 192.168.0.1
 
  #    gateway 192.168.0.1
  
Choose a hostname and write it /etc/hostname (must be created).
+
Create /etc/hosts
 
+
Edit /etc/hosts as follows:
+
  
 +
cat >/etc/hosts <<EOF
 
  127.0.0.1  localhost.localdomain localhost
 
  127.0.0.1  localhost.localdomain localhost
 +
EOF
 +
 +
Create /etc/hostname:
 +
 +
cat >/etc/hostname <<EOF
 +
<your hostname>
 +
EOF
 +
 +
Replace '''<your hostname>''' with a sensible name.
  
 
===Install SSHD===
 
===Install SSHD===
Line 166: Line 217:
 
  aptitude clean
 
  aptitude clean
 
  exit
 
  exit
  cd debian-armel-rootfs
+
  tar zcvf lenny-armel-rootfs.tgz -C debian-armel-rootfs .
tar zcvf ../lenny-armel-rootfs.tgz *
+
  
 
Now you have a complete rootfs for Debian Lenny armel.
 
Now you have a complete rootfs for Debian Lenny armel.
Line 173: Line 223:
 
=Installation=
 
=Installation=
  
==Removing the HDD==
+
We will reuse the existing root partition to store the debian rootfs. The data partition will be used as a temporary root so that this installation will be performed right on the LS itself. It is necessary to have a backup of the data partition if it contains important stuff.
  
Turn the LS off and open the LS case. Will require patience and carefulness in order not to break the plastic notches. Take [http://www.yamasita.jp/linkstation/2008/11/081112__disassemble.html this page] as a reference on how to open the case.
+
If you want to change the RAID type for the data partition, it is better to use the web interface before switching to the full Debian setup.
  
Remove the HDD from the Linkstation. Connect it to a Linux Desktop PC e.g with a SATA-to-USB adapter.
+
==Create an initrd==
 +
An initrd is necessary to boot debian using a raid partition.
 +
 
 +
We need busybox to create a minimal initrd. Note that we need to go back to the chrooted environment.
 +
 
 +
chroot debian-armel-rootfs/ /bin/bash
 +
apt-get install busybox
 +
 
 +
Install uboot files:
 +
 
 +
apt-get install uboot-mkimage
 +
 
 +
Create and mount an ext2 image file:
 +
 
 +
cd /tmp
 +
dd if=/dev/zero of=initrd bs=1k count=0 seek=3K
 +
mke2fs -F -m 0 -b 1024 initrd
 +
tune2fs -c0 -i0 initrd
 +
mkdir INITRD
 +
mount -o loop initrd INITRD
 +
 
 +
''Might you want to create a bigger initrd, the max size of the uncompressed initrd is 8388544 bytes.''
 +
 
 +
Create directory structure and the device nodes:
 +
 
 +
mkdir -p INITRD/{bin,lib,dev,etc/mdadm,proc,sbin}
 +
cp -a /dev/{null,console,tty,sd{a,b,c,d}?,md*} INITRD/dev/
 +
 
 +
Copy busybox, mdadm and their dependencies:
 +
 
 +
cp /bin/busybox INITRD/bin/
 +
cp /sbin/mdadm INITRD/sbin
 +
cp /lib/{libm.so.6,libc.so.6,libgcc_s.so.1,ld-linux.so.3} INITRD/lib
 +
 
 +
The dependencies can be determined using the commands:
 +
 
 +
ldd /bin/busybox
 +
ldd /sbin/mdadm
 +
 
 +
Create a linuxrc:
 +
 
 +
cat > INITRD/linuxrc <<EOF
 +
#!/bin/busybox sh
 +
 +
# Mount the /proc and /sys filesystems.
 +
mount -t proc none /proc
 +
mount -t sysfs none /sys
 +
 +
echo 'DEVICE /dev/sd??*' > /etc/mdadm/mdadm.conf
 +
mdadm -Eb /dev/sd??* >> /etc/mdadm/mdadm.conf
 +
mdadm -As --force
 +
 +
# use /dev/md1 as root
 +
# echo "0x901" > /proc/sys/kernel/real-root-dev
 +
# use /dev/md2 as root
 +
echo "0x902" > /proc/sys/kernel/real-root-dev
 +
# use /dev/sda6 as root
 +
# echo "0x806" > /proc/sys/kernel/real-root-dev
 +
# use /dev/sdb6 as root
 +
# echo "0x822" > /proc/sys/kernel/real-root-dev
 +
 +
# Clean up.
 +
umount /proc
 +
umount /sys
 +
EOF
 +
chmod +x INITRD/linuxrc
 +
 
 +
Uncomment the relevant line if you use a different temporary root partition.
 +
 
 +
Generate an initrd for temporary root partition:
 +
 
 +
umount INITRD
 +
gzip initrd
 +
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo
 +
 
 +
Next we need to create another initrd for the final installation:
 +
 
 +
gunzip initrd.gz
 +
mount -o loop initrd INITRD
 +
 
 +
Edit linuxrc to use /dev/MD1 as root:
 +
 
 +
# use /dev/md1 as root
 +
echo "0x901" > /proc/sys/kernel/real-root-dev
 +
 
 +
Or change it to whatever partition you may want later.
 +
 
 +
umount INITRD
 +
gzip initrd
 +
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo.final
 +
rmdir INITRD
 +
 
 +
Copy initrd:
 +
 
 +
exit
 +
mv /boot/initrd.buffalo /boot/initrd.buffalo.old
 +
cp debian-armel-rootfs/tmp/initrd.buffalo* /boot/
  
 
==Installing the Debian rootfs==
 
==Installing the Debian rootfs==
  
Let's say that the LS' HDD device will be /dev/sdg and the partitions will be /dev/sdg1, /dev/sdg2 etc. Change sdg to match your environment.  
+
This will be a two step process. We first boot debian using a temporary rootfs and then transfer it to it final partition.
  
The following instructions will copy the lenny-rootfs.tgz file created on the LS on the local system, will FORMAT the second HDD partition and will create the Lenny rootfs there:
+
If you are using two hard disks, /dev/md2 will be the temporary partition and /dev/md1 will be the final destination. If you are using a single drive, then /dev/sda6 or /dev/sdb6 will be the temporary partition.
  
sudo -i
+
===Install rootfs in temporary partition===
mkdir /mnt/sdg1
+
mkdir /mnt/sdg2
+
mount /dev/sdg1 /mnt/sdg1
+
mount /dev/sdg2 /mnt/sdg2
+
cp /mnt/sdg2/root/lenny-rootfs.tgz .
+
umount /mnt/sdg2
+
mkfs.xfs -f /dev/sdg2
+
mount /dev/sdg2 /mnt/sdg2
+
cp lenny-rootfs.tgz /mnt/sdg2/
+
cd /mnt/sdg2/
+
tar zxvf lenny-rootfs.tgz
+
rm lenny-rootfs.tgz
+
  
==Installing an empty initrd==
+
Untar the rootfs and copy the backup:
  
Must make an empty initrd in LS' boot partition. Otherwise the stock initrd will start and runs scripts to check for a stock setup. Indeed an initrd is not needed in this Lenny installation as everything can be found on the root filesystem.
+
tar xvzf lenny-armel-rootfs.tgz -C /mnt/array1/
 +
cp lenny-armel-rootfs.tgz /mnt/array1/
  
"empty initrd" means an initrd with no filesystem. It is not an empty file.
+
Use '''/mnt/disk1''' or '''/mnt/disk2''' instead of '''/mnt/array1''' if you are using a single drive.
  
For this you need the ''mkimage'' command. (in Debian/Ubuntu just install the package ''uboot-mkimage'').
+
Reboot and pray that it works. :)
  
  mkdir x ; cd x
+
  reboot
find . | cpio --quiet -o -H newc > ../x2
+
cd ..
+
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -d x2 initrd.buffalo
+
rmdir x ; rm -f x2
+
mv /mnt/sdg1/initrd.buffalo /mnt/sdg1/initrd.original
+
cp initrd.buffalo /mnt/sdg1/
+
  
Unmount all partitions:
+
After rebooting, login to the new system.
  
cd /
+
===Install rootfs in /dev/md1===
umount /mnt/sdg*
+
  
Turn the HDD off and put it back into the LS.
+
Format /dev/md1, use whatever filesystem that you prefer:
 +
 
 +
mkfs.ext3 /dev/md1
 +
tune2fs -c0 -i0 /dev/md1
 +
 
 +
Mount it under /mnt and extract the rootfs:
 +
 
 +
mount /dev/md1 /mnt
 +
tar xvzf /lenny-armel-rootfs.tgz -C /mnt
 +
cp /lenny-armel-rootfs.tgz /mnt/root          # make a copy
 +
 
 +
Edit /mnt/etc/fstab to reflect the changes:
 +
 
 +
# /etc/fstab: static file system information.
 +
#
 +
# file system mount point type options dump pass
 +
/dev/md1 / ext3 defaults,noatime 0    1
 +
/dev/md0 /boot ext3 ro,nosuid,nodev 0    2
 +
/dev/md10 none swap sw 0    0
 +
proc /proc proc defaults 0    0
 +
 
 +
Use the correct initrd:
 +
 
 +
cd /boot
 +
mv initrd.buffalo initrd.buffalo.initial
 +
cp initrd.buffalo.final initrd.buffalo
 +
 
 +
Note: make sure the /boot is mounted! You may have to manually mount it to complete the above step.
 +
 
 +
Reboot and pray that it works. :)
 +
 
 +
reboot
  
 
==Post-installation setup==
 
==Post-installation setup==
 +
 +
===Setup data partition===
 +
 +
The existing data partition can be mounted on the home directory as-is without formatting but the rootfs files must be manually deleted.
 +
 +
The other approach is to start clean and format it. Note that the EXT3 was chosen as the filesystem for the data partition.
 +
 +
Replace '''/dev/md2''' with either '''/dev/sda6''' or '''/dev/sdb6''' if you are using a single drive.
 +
 +
Format:
 +
 +
mkfs.ext3 -m0 /dev/md2
 +
tune2fs -c0 -i0 /dev/md2
 +
 +
Update /etc/fstab:
 +
 +
# /etc/fstab: static file system information.
 +
#
 +
# file system mount point type options dump pass
 +
/dev/md1 / ext3 defaults,noatime 0    1
 +
/dev/md2 /home ext3 defaults,noatime 0    2
 +
/dev/md0 /boot ext3 ro,nosuid,nodev 0    2
 +
/dev/md10 none swap sw 0    0
 +
proc /proc proc defaults 0    0
 +
 +
Mount /home
 +
 +
mount /home
 +
 +
===Add user===
 +
 +
Issue the following command
 +
 +
  adduser <username>
  
 
===Configuring timezone===
 
===Configuring timezone===
Line 240: Line 433:
 
  apt-get install ntp
 
  apt-get install ntp
  
 +
===blstools===
 +
 +
As told above, blstools are a set of utilities which enable LS-CHL/XHL/WXL hardware-specific features otherwise unavailable from a plain Debian Lenny installation.
  
=blstools=
+
In order to install the latest blstools, smartmontools is required:
  
As told above, blstools are a set of utilities which enable LS-CHL/XHL hardware-specific features otherwise unavailable from a plain Debian Lenny installation.
+
apt-get install smartmontools
  
In order to install blstools you have to download the package from [http://sourceforge.net/projects/blstools/ the blstools project page], put it on the LS and run, from the command line:
+
Download the package from [http://sourceforge.net/projects/blstools/ the blstools project page]
  
 
  wget http://downloads.sourceforge.net/project/blstools/releases/blstools-0.2.0.tar.gz
 
  wget http://downloads.sourceforge.net/project/blstools/releases/blstools-0.2.0.tar.gz
 
  tar zxf blstools-0.2.0.tar.gz
 
  tar zxf blstools-0.2.0.tar.gz
 
  cd blstools-0.2.0
 
  cd blstools-0.2.0
  sudo ./install.sh
+
  ./install.sh
  sudo reboot
+
  /etc/init.d/lsmonitor start
  
 
The following features are installed:  
 
The following features are installed:  
  
==lsmonitor (/etc/init.d/lsmonitor)==
+
====lsmonitor (/etc/init.d/lsmonitor)====
  
 
This is a daemon that is automatically started when the system boots. You don't need
 
This is a daemon that is automatically started when the system boots. You don't need
Line 264: Line 460:
 
shutdown (which is nice isn't it?)
 
shutdown (which is nice isn't it?)
  
==usb (/etc/init.d/usb)==
+
====usb (/etc/init.d/usb)====
  
 
Powers on and off the USB interface.
 
Powers on and off the USB interface.
Line 280: Line 476:
 
to disable the USB device.
 
to disable the USB device.
 
   
 
   
 +
===NFS kernel===
 +
 +
<font color=red size=large> Note: Some export problems were encountered using this kernel. Compiling a Debian kernel is the preferred approach.  </font>
 +
 +
The kernel provided on this [[Ready-to-use_NFS_kernel | page]] can also be used for LS-WXL.
 +
 +
Download and extract kernel and modules:
 +
 +
wget http://downloads.buffalo.nas-central.org/Users/kenatonline/NFSKernel/nfs-kernel-feroceon-kw.tgz
 +
tar xzf nfs-kernel-feroceon-kw.tgz boot lib
 +
 +
Install and reboot:
 +
 +
mount -o remount,rw /boot
 +
mv /boot/uImage.buffalo /boot/uImage.buffalo.old
 +
cp boot/uImage.buffalo /boot/
 +
cp -a lib/modules/2.6.22.18kenatonline /lib/modules/
 +
reboot
 +
 +
Install nfs
 +
 +
apt-get install nfs-kernel-server nfs-common portmap
 +
 +
Check if server is running:
 +
 +
/etc/init.d/nfs-kernel-server status
 +
 +
===Webmin===
 +
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
 +
apt-get install libnet-ssleay-perl openssl libauthen-pam-perl libio-pty-perl apt-show-versions libapt-pkg-perl
 +
dpkg -i webmin_1.510-2_all.deb
 +
 +
For more information, please refers to [[Webmin to remotely administer your LinkStation]]
 +
 +
=Building the Debian kernel=
 +
 +
<font color=red size=large> Caution: Make sure that you have physical access to the drives and a linux box just in case you messed up with the the kernel configuration. At the moment, there is no known way of gaining root access when the device is in EM mode. </font>
 +
 +
The kernel can be natively compiled or cross compiled using an external Debian PC.
 +
 +
==Requisites==
 +
 +
Install the following packages under root:
 +
 +
apt-get install build-essential fakeroot uboot-mkimage debhelper python libncurses5-dev
 +
 +
Update /etc/apt/sources.list to be able to download the Squeeze kernel sources:
 +
 +
echo deb-src http://ftp.us.debian.org/debian squeeze main >> /etc/apt/sources.list
 +
apt-get update
 +
 +
Install the kernel sources (this command can be run as a normal user)
 +
 +
apt-get -t squeeze source linux-2.6
 +
 +
Download the patch and sample config file (for linux-2.6-2.6.32-30):
 +
 +
wget http://pastebin.com/download.php?i=vFRr3zAX -O patch.lswxl
 +
wget http://pastebin.com/download.php?i=2R6sJ0ZX -O config.lswxl
 +
 +
==Native compilation==
 +
 +
cd linux-2.6-2.6.32
 +
make -f debian/rules source
 +
cd debian/build/source_armel_none/
 +
 +
apply the necesary patches, but review them before you apply them, as the kernel patches changes every week
 +
 +
patch -Np1 -i ~/patch.lswxl
 +
 +
cp ~/config.lswxl .config
 +
make uImage modules
 +
cp arch/arm/boot/uImage uImage.buffalo.debian
 +
make modules_install INSTALL_MOD_PATH=./modules
 +
 +
On my LS, the compilation took around 1.5 hrs.
 +
 +
==Cross compilation==
 +
 +
cd linux-2.6-2.6.32
 +
make -f debian/rules.gen source_armel_none
 +
 +
apply the necesary patches, but review them before you apply them, as the kernel patches changes every week
 +
 +
patch -Np1 -i ~/patch.lswxl
 +
 +
cd debian/build/source_armel_none/
 +
patch -Np1 -i ../../../../patch.lswxl
 +
cp ../../../../config.lswxl .config
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage modules
 +
mv arch/arm/boot/uImage uImage.buffalo.debian
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install INSTALL_MOD_PATH=./modules
 +
 +
==Installation==
 +
 +
Get yourself root access, and get write access to the boot fs
 +
 +
su
 +
mount -o remount,rw /boot
 +
 +
If [http://sourceforge.net/projects/blstools/ blstools] is installed, this program must first be disabled or removed. Otherwise, the system will just automatically reboot.
 +
 +
chmod a-x /etc/init.d/lsmonitor
 +
 +
Copy the kernel to the boot directory, create a backup of the old version:
 +
 +
mv /boot/uImage.buffalo /boot/uImage.buffalo.old
 +
cp uImage.buffalo.debian /boot/uImage.buffalo
 +
 +
Copy the modules:
 +
 +
cp -a modules/lib/modules/2.6.32 /lib/modules
 +
 +
make the correct realtime clock device, with this kernel settings it is:
 +
 +
mknod /dev/rtc c 254 0
 +
 +
 +
Reboot and enjoy your new kernel.
 +
 +
==blstools Replacement==
 +
 +
This is the replacement [http://pastebin.com/9yWQBnhW lsmonitor] script. This uses the sysfs GPIO interface instead of the buffalo specific proc interface. Also this script monitors the temperature of both drives.
  
 
=References=
 
=References=
Line 288: Line 607:
 
* http://buffalo.nas-central.org/wiki/FreeLink_for_the_Kurobox_Pro_-_Automatic_Install
 
* http://buffalo.nas-central.org/wiki/FreeLink_for_the_Kurobox_Pro_-_Automatic_Install
 
* http://forum.buffalo.nas-central.org/viewtopic.php?f=39&t=13551
 
* http://forum.buffalo.nas-central.org/viewtopic.php?f=39&t=13551
 +
* http://en.gentoo-wiki.com/wiki/Initramfs
  
  
[[Category:LS-WXL]][[Category:Debian]]
+
[[Category:LS-WXL]][[Category:Debian]][[Category:Lenny]]

Latest revision as of 15:55, 18 January 2013

This guide will explain how to install Debian GNU/Linux "Lenny" on the LinkStation™ Duo LS-WXL using the Debian "debootstrap" procedure. The original kernel will be preserved, as well as the original bootloader (U-Boot).

Note that there's also a page on setting up Debian Squeeze that may be derived from this one: Debian Squeeze on LS-WXL

For Debian Squeeze on the LS-CHLv2 see Debian Squeeze on LS-CHLv2, which is largely based on this document and Debian_Squeeze_on_'V'_and_'X'_Series_(LS-WXL_and_others)

Basic idea:

  • create a Debian system with debootstrap
  • use the data partition as a temporary root
  • replace the old filesystem with the new one

This guide will ask you to reformat partitions, delete existing data, etc. All of these actions may void your warranty, destroy your data, etc. In general you can receive help from the community or from the Buffalo forums but bear in mind that every problem you may encounter is ultimately up to you to solve. You do it at your own risk.

This guide is based on the procedure for installing Debian on LS-CHLv2 and was developed using the LS-WXL/E version. This guide should also work for the LS-WXL/R1 variants.

This guide suggests to install blstools, a small set of utilities developed for this hardware to enable some operations which would not be possible from a plain Debian install:

  • turn the unit off from the on-off-auto switch
  • turn unit blinking LEDs to still blue when boot is complete
  • resume blinking when the unit is shutting down
  • use the USB port

Please note that the Armel Debian "micro_evtd" package will NOT work on LS-WXL because of different hardware.


Contents

Preliminary steps

Obtain root access to the linkstation

You are supposed to start from an "open" Stock Firmware, that is stock software that you can telnet to,

Follow this guide to get telnet root console access to the LS.

Follow this guide to SSH as root to the LS.

Backup the LS

If you have any important data on the LS you definitely need to make a backup.

Even if you don't, you'd better take a snapshot of the vital disk partitions (first and second partition). So you will be able to easily revert to the original stock distribution. [forum post] explains how to do it.

Prepare a Debian Lenny root filesystem

Debootstrap

This is derived from original debootstrap docs.

From the linkstation console download the Debian debootstrap utility and install it with dpkg:

wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.10lenny1_all.deb
dpkg -i debootstrap_1.0.10lenny1_all.deb

dpkg will complain of missing dependencies. Ignore it.

Note that for firmware 1.22 (and possibly others) Busybox isn't linked to ar so the debootstrap step below will fail.

which ar >/dev/null || ln -s /bin/busybox /usr/bin/ar  # fix ar link

mkdir debian-armel-rootfs
debootstrap --verbose --arch armel lenny debian-armel-rootfs http://ftp.us.debian.org/debian

This step WILL take time. At the end you should get the following message:

I: Base system installed successfully.

Completing the debootstrap and preparing the rootfs

Most commands will be run in the chrooted environment of the newly created Debian Lenny install. In order to enter the chroot type

LANG=C chroot debian-armel-rootfs/ /bin/bash

to leave type exit.

Copy kernel modules from stock kernel

Kernel modules reside in /lib/modules/<kernel version>. Here we are using the stock kernel so we must copy them from the stock initrd to the new rootfs. This must be done from within a chrooted environment in the new system - won't work with stock software.

cp /boot/initrd.buffalo debian-armel-rootfs/tmp/
LANG=C chroot debian-armel-rootfs/ /bin/bash
cd /tmp
dd if=initrd.buffalo of=initrd.gz ibs=64 skip=1
gunzip initrd.gz
mkdir INITRD
mount -t ext2 -o loop initrd INITRD 
cp -R INITRD/lib/modules/* /lib/modules/
umount INITRD
rmdir INITRD
rm initrd*

Adding missing devices

Still in the chrooted environment.

Mount the proc filesystem - it can be mounted a number of times - and run the command to create device nodes in /dev (TODO: investigate dynamic devices with udev?):

mount -t proc proc /proc
cd /dev
MAKEDEV generic
umount /proc

This will also take some time while all device nodes are created.

Apt setup

Apt will complain about packages without verification if this step is not performed.

Edit /etc/apt/sources.list, use the appropriate debian mirror

# Debian packages for lenny
deb http://ftp.us.debian.org/debian lenny main
# Uncomment the deb-src line if you want 'apt-get source'
# to work with most packages.
# deb-src http://ftp.us.debian.org/debian lenny main

deb http://security.debian.org/ lenny/updates main contrib
# deb-src http://security.debian.org/ lenny/updates main contrib

deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib
# deb-src http://volatile.debian.org/debian-volatile lenny/volatile main contrib

Perform an update

apt-get update

The final upgrade step can be performed later once the installation is finished.

Install mdadm

ln -s /sbin/MAKEDEV /dev     # mdadm install expects to see this
apt-get --no-install-recommends install mdadm

Ignore the "(failed to load MD subsystem)" error.

Update mdadm.conf:

exit                                                # exit from chroot
cp /etc/mdadm.conf debian-armel-rootfs/etc/mdadm/
LANG=C chroot debian-armel-rootfs/ /bin/bash        # back again

Configuring locale

Install and configure the locales. Suggestion is to install at least the en_US.UTF-8 and your native language locale (e.g. it_IT.UTF-8, de_DE.UTF-8, etc).

apt-get install locales
dpkg-reconfigure locales

Editing /etc/fstab

Create /etc/fstab:

cat >/etc/fstab <<EOF
# /etc/fstab: static file system information.
#
# file system	mount point	type	options			dump pass
/dev/md2	/		xfs	defaults,noatime	0    1
/dev/md0	/boot		ext3	rw,nosuid,nodev		0    2
/dev/md10	none		swap	sw			0    0
proc		/proc		proc	defaults		0    0
EOF

Partition /dev/md2 contains the shared directory which will be used as a temporary root before the final installation. Make sure that a backup of this partition is made if it contains important data.

If the LS has only a single drive attached, change /dev/md2 to either /dev/sda6 or /dev/sdb6 depending on which slot the drive is inserted.

Network

Edit /etc/network/interfaces to match your LAN configuration. My LS gets all information from DHCP:

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

# We always want the loopback interface.
auto lo
iface lo inet loopback
# DHCP for Ethernet connection 
auto eth1
iface eth1 inet dhcp
# Example static IP setup: (broadcast and gateway are optional)
# auto eth1
# iface eth1 inet static
#     address 192.168.0.42
#     network 192.168.0.0
#     netmask 255.255.255.0
#     broadcast 192.168.0.255
#     gateway 192.168.0.1

Create /etc/hosts

cat >/etc/hosts <<EOF
127.0.0.1  localhost.localdomain localhost
EOF

Create /etc/hostname:

cat >/etc/hostname <<EOF
<your hostname>
EOF

Replace <your hostname> with a sensible name.

Install SSHD

apt-get install openssh-server
passwd root

Edit /etc/ssh/sshd_config and make sure that the following line is present and uncommented:

PermitRootLogin yes

Prepare the rootfs archive

Clean up the installation, leave the chrooted environment and tar it up:

aptitude clean
exit
tar zcvf lenny-armel-rootfs.tgz -C debian-armel-rootfs .

Now you have a complete rootfs for Debian Lenny armel.

Installation

We will reuse the existing root partition to store the debian rootfs. The data partition will be used as a temporary root so that this installation will be performed right on the LS itself. It is necessary to have a backup of the data partition if it contains important stuff.

If you want to change the RAID type for the data partition, it is better to use the web interface before switching to the full Debian setup.

Create an initrd

An initrd is necessary to boot debian using a raid partition.

We need busybox to create a minimal initrd. Note that we need to go back to the chrooted environment.

chroot debian-armel-rootfs/ /bin/bash
apt-get install busybox

Install uboot files:

apt-get install uboot-mkimage

Create and mount an ext2 image file:

cd /tmp
dd if=/dev/zero of=initrd bs=1k count=0 seek=3K
mke2fs -F -m 0 -b 1024 initrd
tune2fs -c0 -i0 initrd
mkdir INITRD
mount -o loop initrd INITRD

Might you want to create a bigger initrd, the max size of the uncompressed initrd is 8388544 bytes.

Create directory structure and the device nodes:

mkdir -p INITRD/{bin,lib,dev,etc/mdadm,proc,sbin}
cp -a /dev/{null,console,tty,sd{a,b,c,d}?,md*} INITRD/dev/

Copy busybox, mdadm and their dependencies:

cp /bin/busybox INITRD/bin/
cp /sbin/mdadm INITRD/sbin
cp /lib/{libm.so.6,libc.so.6,libgcc_s.so.1,ld-linux.so.3} INITRD/lib

The dependencies can be determined using the commands:

ldd /bin/busybox
ldd /sbin/mdadm

Create a linuxrc:

cat > INITRD/linuxrc <<EOF
#!/bin/busybox sh

# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys

echo 'DEVICE /dev/sd??*' > /etc/mdadm/mdadm.conf
mdadm -Eb /dev/sd??* >> /etc/mdadm/mdadm.conf
mdadm -As --force

# use /dev/md1 as root
# echo "0x901" > /proc/sys/kernel/real-root-dev
# use /dev/md2 as root
echo "0x902" > /proc/sys/kernel/real-root-dev
# use /dev/sda6 as root
# echo "0x806" > /proc/sys/kernel/real-root-dev
# use /dev/sdb6 as root
# echo "0x822" > /proc/sys/kernel/real-root-dev

# Clean up.
umount /proc
umount /sys
EOF
chmod +x INITRD/linuxrc

Uncomment the relevant line if you use a different temporary root partition.

Generate an initrd for temporary root partition:

umount INITRD
gzip initrd
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo

Next we need to create another initrd for the final installation:

gunzip initrd.gz
mount -o loop initrd INITRD

Edit linuxrc to use /dev/MD1 as root:

# use /dev/md1 as root
echo "0x901" > /proc/sys/kernel/real-root-dev

Or change it to whatever partition you may want later.

umount INITRD
gzip initrd
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo.final
rmdir INITRD

Copy initrd:

exit
mv /boot/initrd.buffalo /boot/initrd.buffalo.old
cp debian-armel-rootfs/tmp/initrd.buffalo* /boot/

Installing the Debian rootfs

This will be a two step process. We first boot debian using a temporary rootfs and then transfer it to it final partition.

If you are using two hard disks, /dev/md2 will be the temporary partition and /dev/md1 will be the final destination. If you are using a single drive, then /dev/sda6 or /dev/sdb6 will be the temporary partition.

Install rootfs in temporary partition

Untar the rootfs and copy the backup:

tar xvzf lenny-armel-rootfs.tgz -C /mnt/array1/
cp lenny-armel-rootfs.tgz /mnt/array1/

Use /mnt/disk1 or /mnt/disk2 instead of /mnt/array1 if you are using a single drive.

Reboot and pray that it works. :)

reboot

After rebooting, login to the new system.

Install rootfs in /dev/md1

Format /dev/md1, use whatever filesystem that you prefer:

mkfs.ext3 /dev/md1
tune2fs -c0 -i0 /dev/md1

Mount it under /mnt and extract the rootfs:

mount /dev/md1 /mnt
tar xvzf /lenny-armel-rootfs.tgz -C /mnt
cp /lenny-armel-rootfs.tgz /mnt/root           # make a copy

Edit /mnt/etc/fstab to reflect the changes:

# /etc/fstab: static file system information.
#
# file system	mount point	type	options			dump pass
/dev/md1	/		ext3	defaults,noatime	0    1
/dev/md0	/boot		ext3	ro,nosuid,nodev		0    2
/dev/md10	none		swap	sw			0    0
proc		/proc		proc	defaults		0    0

Use the correct initrd:

cd /boot
mv initrd.buffalo initrd.buffalo.initial
cp initrd.buffalo.final initrd.buffalo

Note: make sure the /boot is mounted! You may have to manually mount it to complete the above step.

Reboot and pray that it works. :)

reboot

Post-installation setup

Setup data partition

The existing data partition can be mounted on the home directory as-is without formatting but the rootfs files must be manually deleted.

The other approach is to start clean and format it. Note that the EXT3 was chosen as the filesystem for the data partition.

Replace /dev/md2 with either /dev/sda6 or /dev/sdb6 if you are using a single drive.

Format:

mkfs.ext3 -m0 /dev/md2
tune2fs -c0 -i0 /dev/md2

Update /etc/fstab:

# /etc/fstab: static file system information.
#
# file system	mount point	type	options			dump pass
/dev/md1	/		ext3	defaults,noatime	0    1
/dev/md2	/home		ext3	defaults,noatime	0    2
/dev/md0	/boot		ext3	ro,nosuid,nodev		0    2
/dev/md10	none		swap	sw			0    0
proc		/proc		proc	defaults		0    0

Mount /home

mount /home

Add user

Issue the following command

 adduser <username>

Configuring timezone

dpkg-reconfigure tzdata

Useful packages

Anyone would need these:

apt-get install sudo less usbutils bzip2 mc linuxlogo psmisc

NTP

Ntpd ensures that your Linkstation clock stays in sync with global time servers.

apt-get install ntp

blstools

As told above, blstools are a set of utilities which enable LS-CHL/XHL/WXL hardware-specific features otherwise unavailable from a plain Debian Lenny installation.

In order to install the latest blstools, smartmontools is required:

apt-get install smartmontools

Download the package from the blstools project page

wget http://downloads.sourceforge.net/project/blstools/releases/blstools-0.2.0.tar.gz
tar zxf blstools-0.2.0.tar.gz
cd blstools-0.2.0
./install.sh
/etc/init.d/lsmonitor start

The following features are installed:

lsmonitor (/etc/init.d/lsmonitor)

This is a daemon that is automatically started when the system boots. You don't need to call it directly.

lsmonitor stops the blue led from flashing and provides a reassuring, still blue light. Also, when you move the switch in "off" position lsmonitor initiates system shutdown (which is nice isn't it?)

usb (/etc/init.d/usb)

Powers on and off the USB interface.

When you want to connect a USB disk to the Linkstation you should first call:

sudo /etc/init.d/usb start

and then you will be able to mount the USB drive to the desired location (generally, the device will be /dev/sdb1). Once done, in order to save power you can unmount the mounted volume and issue:

sudo /etc/init.d/usb stop

to disable the USB device.

NFS kernel

Note: Some export problems were encountered using this kernel. Compiling a Debian kernel is the preferred approach.

The kernel provided on this page can also be used for LS-WXL.

Download and extract kernel and modules:

wget http://downloads.buffalo.nas-central.org/Users/kenatonline/NFSKernel/nfs-kernel-feroceon-kw.tgz
tar xzf nfs-kernel-feroceon-kw.tgz boot lib

Install and reboot:

mount -o remount,rw /boot
mv /boot/uImage.buffalo /boot/uImage.buffalo.old
cp boot/uImage.buffalo /boot/
cp -a lib/modules/2.6.22.18kenatonline /lib/modules/
reboot

Install nfs

apt-get install nfs-kernel-server nfs-common portmap

Check if server is running:

/etc/init.d/nfs-kernel-server status

Webmin

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
apt-get install libnet-ssleay-perl openssl libauthen-pam-perl libio-pty-perl apt-show-versions libapt-pkg-perl
dpkg -i webmin_1.510-2_all.deb

For more information, please refers to Webmin to remotely administer your LinkStation

Building the Debian kernel

Caution: Make sure that you have physical access to the drives and a linux box just in case you messed up with the the kernel configuration. At the moment, there is no known way of gaining root access when the device is in EM mode.

The kernel can be natively compiled or cross compiled using an external Debian PC.

Requisites

Install the following packages under root:

apt-get install build-essential fakeroot uboot-mkimage debhelper python libncurses5-dev

Update /etc/apt/sources.list to be able to download the Squeeze kernel sources:

echo deb-src http://ftp.us.debian.org/debian squeeze main >> /etc/apt/sources.list
apt-get update

Install the kernel sources (this command can be run as a normal user)

apt-get -t squeeze source linux-2.6

Download the patch and sample config file (for linux-2.6-2.6.32-30):

wget http://pastebin.com/download.php?i=vFRr3zAX -O patch.lswxl
wget http://pastebin.com/download.php?i=2R6sJ0ZX -O config.lswxl

Native compilation

cd linux-2.6-2.6.32
make -f debian/rules source
cd debian/build/source_armel_none/

apply the necesary patches, but review them before you apply them, as the kernel patches changes every week

patch -Np1 -i ~/patch.lswxl
cp ~/config.lswxl .config
make uImage modules
cp arch/arm/boot/uImage uImage.buffalo.debian
make modules_install INSTALL_MOD_PATH=./modules

On my LS, the compilation took around 1.5 hrs.

Cross compilation

cd linux-2.6-2.6.32
make -f debian/rules.gen source_armel_none

apply the necesary patches, but review them before you apply them, as the kernel patches changes every week

patch -Np1 -i ~/patch.lswxl
cd debian/build/source_armel_none/
patch -Np1 -i ../../../../patch.lswxl
cp ../../../../config.lswxl .config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage modules
mv arch/arm/boot/uImage uImage.buffalo.debian
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install INSTALL_MOD_PATH=./modules

Installation

Get yourself root access, and get write access to the boot fs

su
mount -o remount,rw /boot

If blstools is installed, this program must first be disabled or removed. Otherwise, the system will just automatically reboot.

chmod a-x /etc/init.d/lsmonitor

Copy the kernel to the boot directory, create a backup of the old version:

mv /boot/uImage.buffalo /boot/uImage.buffalo.old
cp uImage.buffalo.debian /boot/uImage.buffalo

Copy the modules:

cp -a modules/lib/modules/2.6.32 /lib/modules

make the correct realtime clock device, with this kernel settings it is:

mknod /dev/rtc c 254 0


Reboot and enjoy your new kernel.

blstools Replacement

This is the replacement lsmonitor script. This uses the sysfs GPIO interface instead of the buffalo specific proc interface. Also this script monitors the temperature of both drives.

References