Install Debian wheezy to LS-XHL

This post is also available in: Chinese (Simplified) Russian Spanish Portuguese (Portugal) French Arabic German Japanese

< Warning >
I can guarantee nothing about your troubles that happen to your hardware or data by following my procedure on this page. Please perform the procedure at your own risk.

< What is “LS-XHL”? >
It is a kind of NAS ( Network Attached Storage – Wikipedia ) made by Buffalo(Japanese company).
You can find similar NAS on Amazon by searching “linkstation”.
We can install Debian on it.
( Maybe “LS-XHL” is too old to buy new one, you can buy only used one. )

< I installed Debian wheezy to “LS-XHL” >
I wrote down about the procedure to install Debian wheezy to “LS-XHL”.
Basically I follow
http://www.zorac.org/wp/?p=447” (Japanese page) and
Buffalo NAS-Central Forums • View topic – LS-CHLv2 – LS-XHL – Debian Wheezy Rootfs – Update 2013.05.15” (English page).
If you want to understand or read more, please read these pages or google any keywords about them.

< Things you need >
1. LS-XHL ( LS-VL is similar to LS-XHL, maybe only network setting is different. )
2. Debian Wheezy Rootfs ( http://neboola.de/fjen/lschlv2/debian/wheezy/ )
3. Debian or Ubuntu machine ( I recommend ARM CPU machine. But maybe non-ARM is possible. )
4. USB-HDD Case ( You need it to temporarily connect to Linux machine. If it’s possible, internal SATA or any kind of connections are OK. )

I wrote the procedures of ARM and non-ARM as same as possible, but some procedures are different. I checked only on ARM machine. Please be careful.

< Something like traps >
1. When I use “Gparted” for partitioning, LS-XHL didn’t boot. ( “parted” is OK. )
2. “chroot” for this rootfs is only available on ARM machine.

< STEP 1 – Disassemble LS-XHL >
I found the good video on Youtube. Please follow this.

( Maybe disassembling LS-VL is the same. )
Its plastic part is really easy to break, please be careful not to break when you open it.

Even if you break some part, maybe it can work. Don’t worry so much.
Because I break many plastic part of my LS-XHL haha…

< STEP 2 – Partitioning and formatting HDD >
Boot your Linux machine. ( I used Debian wheezy on Raspberry Pi. )
Login the Linux machine as root.
If your machine doesn’t have “parted”, please install “parted”.
If your Linux is Debian or Ubuntu, execute this command line.

apt-get install parted

Next, connect your new HDD(for LS-XHL) to this Linux machine by USB or any kind of connections.
And check information of HDD. If your HDD is on “/dev/sda”, execute this command line.

parted /dev/sda print

In my case, it showed like this.

Model: ATA Hitachi HDS72202 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B

Important word is “2000GB” in line “Disk /dev/sda: 2000GB”. Please remember the same part of your HDD.

Make partitions.

parted /dev/sda mklabel gpt
parted -a cylinder /dev/sda mkpart primary 0 511
parted -a cylinder /dev/sda mkpart primary 511 8191
parted -a cylinder /dev/sda mkpart primary 8191 9215
parted -a cylinder /dev/sda mkpart primary 9215 2000G
parted /dev/sda set 1 boot on

This is my sample.
I was thinking to use
“/dev/sda1″ for “/boot”,
“/dev/sda2″ for “/”,
“/dev/sda3″ for swap,
“/dev/sda4″ for “/home”.
You need to change “2000G” of the line “parted -a cylinder /dev/sda mkpart primary 9215 2000G”.
Also you can change the each partition size.

Format partitions.

mke2fs -I 128 -j /dev/sda1
mke2fs -j -t ext4 /dev/sda2
mkswap /dev/sda3
mke2fs -j -t ext4 /dev/sda4

Mount partitions to expand Rootfs.

mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

< STEP 3 – Expand Rootfs >
Goto temporary folder like “/tmp”.
And get “debian_wheezy_rootfs_lschlv2-lsxhl_20130515.tar.xz” from http://neboola.de/fjen/lschlv2/debian/wheezy/.

cd /tmp
wget http://neboola.de/fjen/lschlv2/debian/wheezy/debian_wheezy_rootfs_lschlv2-lsxhl_20130515.tar.xz

Expand it to “/mnt”.

tar Jxvf debian_wheezy_rootfs_lschlv2-lsxhl_20130515.tar.xz -C /mnt

Download “uImage.buffalo.3.9.2-fjen-1.lsxhl” to “/mnt/boot”.

cd /mnt/boot
wget http://neboola.de/fjen/lschlv2/debian/wheezy/lsxhl-kernel-for-20130515/uImage.buffalo.3.9.2-fjen-1.lsxhl

< STEP 4 – Update settings >
Please update these five files.
/mnt/etc/fstab
/mnt/etc/network/interfaces
/mnt/etc/resolv.conf
/mnt/etc/hostname
/mnt/etc/hosts

This is my “/mnt/etc/fstab”.

/dev/sda1       /boot         ext3     noauto,noatime         1 2
/dev/sda2       /             ext4     noatime                0 1
/dev/sda3       none          swap     sw                     0 0
/dev/sda4       /home         ext4     noatime                0 0
proc            /proc         proc     defaults               0 0
shm             /dev/shm      tmpfs    nodev,nosuid,noexec    0 0
devpts          /dev/pts      devpts   gid=4,mode=620         0 0
#tmpfs           /tmp          tmpfs    defaults               0 0
sysfs           /sys          sysfs    defaults               0 0

This is my “/mnt/etc/network/interfaces”.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
  address 192.168.1.101
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

If you use “LS-VL”, it doesn’t have “eth1″.
Maybe “/mnt/etc/network/interfaces” is like this.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
  address 192.168.1.101
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

( These are just samples. Please set correct values for your own network. )

This is my “/mnt/etc/resolv.conf”.

domain linkstation
search linkstation
nameserver 8.8.8.8
nameserver 8.8.4.4

Lines “domain linkstation” and “search linkstation” are not necessary.

My “/mnt/etc/hostname” is “linkstation”.
I didn’t update “/mnt/etc/hosts”.
But you can change them, if you want.

< STEP 5 – chroot >
Using chroot, but it’s only available on the same architecture. ( In this case, it’s ARM architecture. )

chroot /mnt

If you don’t have ARM machine or fail to “chroot”, goto STEP 6.
If your “chroot” is succeeded, follow this way.

cd /boot
mv uImage.buffalo uImage.buffalo.bk
ln -s uImage.buffalo.3.9.2-fjen-1.lsxhl uImage.buffalo

< STEP 6 – If you can’t “chroot” >
( I didn’t test this STEP of procedure, be careful. And I recommend to google some information about this. )

cd /mnt/boot
mv uImage.buffalo uImage.buffalo.bk
mv uImage.buffalo.3.9.2-fjen-1.lsxhl uImage.buffalo

< STEP 7 – Basic settings >
Insert HDD to LS-XHL and boot it. When you do this, I recommend not to drive a screw and not to shut the lid. Ready to re-install Debian, if you fail the install.

Connect “192.168.1.101″(It’s my example) by SSH.
Default root password is “toor”.

ssh root@192.168.1.101

( It’s Linux/UNIX example. )

Follow these commands after logged in.

passwd
dpkg-reconfigure locales
dpkg-reconfigure tzdata
rm /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server

These lines mean
1. Reset root password
2. Update your locale
3. Update your time zone
4. Update SSH key
You need logout SSH to update SSH key in SSH client.
If you use SSH on Linux/UNIX, follow this command to update client SSH key.

ssh-keygen -R 192.168.1.101

After that, re-login as root and execute “apt-get”.

apt-get update
apt-get upgrade

It’s now complete.
Please drive a screw and shut the lid.
Good luck!

< Thanks >
Thanks a lot to a person who compiled “Debian Wheezy Rootfs”, people on http://forum.buffalo.nas-central.org/viewtopic.php?f=71&t=26291 and a person who wrote http://www.zorac.org/wp/?p=447.
You have made my installation a lot easier! Thank you!