Difference between revisions of "Debian Squeeze on LS-WVL"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
(Created page with "{| align="center" width="80%" style="border: 2px dashed #FF0000; background-color: Lemonchiffon; padding: 10px" |- |align="left" width="99%"|<center><big>'''NOTE:'''</big></cente…")
(Blanked the page)
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{| align="center" width="80%" style="border: 2px dashed #FF0000; background-color: Lemonchiffon; padding: 10px"
|align="left" width="99%"|<center><big>'''NOTE:'''</big></center>
<p><center>This is a WIP! This will be finished 17-03 or 18-03. VolleMelk</center></p>
This guide(a Work In Progress) will explain how to install Debian GNU/Linux "Squeeze" 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 Procedure is based on the Lenny procedure of the same name and is offered here as all the procedures for installing Squeeze on the LS-WXL led to an eventual endless reboot cycle. As the "lenny" procedure installs a squeeze kernel in any case and the lenny procedure produces a sane machine I just altered it by the change of the bootstrap fetched and the apt archives accessed in the install procedures.
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_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 suggests to install [http://sourceforge.net/projects/blstools/ 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.
=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 [[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==
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. [[http://forum.buffalo.nas-central.org/viewtopic.php?f=39&t=13551|This forum post]] explains how to do it.
=Prepare a Debian squeeze root filesystem=
This is derived from original debootstrap docs.
From the linkstation console download the [http://packages.debian.org/lenny/all/debootstrap/download Debian debootstrap] utility and install it with dpkg:
wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.35_all.deb
dpkg -i debootstrap_1.0.35_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 squeeze 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 squeeze 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?):
apt-get install makedev
ln -s /sbin/makedev /dev/MAKEDEV
mount -t proc proc /proc
cd /dev
mv .udev .oldudev
MAKEDEV generic
mv .oldudev  .udev
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 [http://www.debian.org/mirror/list mirror]
# Debian packages for squeeze
deb http://ftp.us.debian.org/debian squeeze 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 squeeze main
deb http://security.debian.org/ squeeze/updates main contrib
# deb-src http://security.debian.org/ squeeze/updates main contrib
deb http://volatile.debian.org/debian-volatile squeeze/volatile main contrib
# deb-src http://volatile.debian.org/debian-volatile squeeze/volatile main contrib
Perform an update
apt-get update
The final upgrade step can be performed later once the installation is finished.
===Install mdadm===
apt-get --no-install-recommends install mdadm
If apt-get complains that pts isn't accessible: ignore it or mount devpts (mount -t devpts devpts /dev/pts).
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
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.
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
#    network
#    netmask
#    broadcast
#    gateway
Create /etc/hosts
cat >/etc/hosts <<EOF  localhost.localdomain localhost
Create /etc/hostname:
cat >/etc/hostname <<EOF
<your hostname>
Replace '''<your hostname>''' with a sensible name.
===Install SSHD===
apt-get install openssh-server
passwd root
mkdir ~/.ssh
cp /root/.ssh/au* debian-armel-rootfs/root/.ssh/
LANG=C chroot debian-armel-rootfs/ /bin/bash  #back again
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
tar zcvf squeeze-armel-rootfs.tgz -C debian-armel-rootfs .
Now you have a complete rootfs for Debian squeeze armel.
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
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:
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 squeeze-armel-rootfs.tgz -C /mnt/array1/
cp squeeze-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. :)
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 /squeeze-armel-rootfs.tgz -C /mnt
cp /squeeze-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. :)
==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.
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
Ntpd ensures that your Linkstation clock stays in sync with global time servers.
apt-get install ntp
As told above, blstools are a set of utilities which enable LS-CHL/XHL/WXL hardware-specific features otherwise unavailable from a plain Debian squeeze installation.
In order to install the latest blstools, smartmontools is required:
apt-get install smartmontools
Download the package from [http://sourceforge.net/projects/blstools/ the blstools project page]
apt-get install subversion
svn co https://blstools.svn.sourceforge.net/svnroot/blstools/trunk blstools
cd blstools
/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.
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.560_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.560_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.
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.(unverified for squeeze userland)
==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
Get yourself root access, and get write access to the boot fs
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.
* http://www.kolios.dk/2009/09/07/howto-install-a-debian-from-scratch-on-a-buffalo-terastation-duo-2/
* http://www.cyrius.com/debian/orion/buffalo/kuroboxpro/recovery.html
* http://buffalo.nas-central.org/index.php/Open_Stock_Firmware
* 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://en.gentoo-wiki.com/wiki/Initramfs

Latest revision as of 20:11, 17 March 2013