Installation of a vanilla debian on a MyBook Live NAS.

  • Note: For an update to Debian Jessie / direct installation of Debian Jessie, see my update on this guide.
  • Note 2: To install on a blank harddisk, see the my second update
  • Note 3: To revert to the original installation, follow my third update

The MyBook Live is hardware wise a pretty nice NAS, featuring an embedded powerpc board and gigabit ethernet. The standard installation is a mix of debian squeeze and wheezy and comes with dlna / air play software, ftp, smb and afp access, all configurable through a web interface. It cannot be easily upgraded to wheezy though. If you don’t need the dlna software and are interested in installing software for a more ‘recent’ system, here we go. Furthermore, we obtain security patches directly from debian instead of relying on infrequent firmware upgrades.

Overview

The system partition is a raid 1 such that upgrades can be rolled back. We will use one of the two RAID 1 partitions for our new system in this guide. The installation is based on the writeup from loetzimmer.de with some adaptions and a custom kernel build. Kernel builds are along the guide from Alex Ryzhof.

Prerequisites

  • familiarity with Linux systems, shell, etc.
  • In case that something went wrong:
    • tools to disassemble a mybooklive
    • sata box, adatper or computer with free sata ports

Preparations

  • Enable SSH access via web ui
  • Log as root into the system via ssh

Partition and Format

First we will determine which partition is usable as our new system partition. Parted should produce some similar output:

Gondor:/boot# parted
GNU Parted 2.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: ATA WDC WD30EZRS-11J (scsi)
Disk /dev/sda: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name     Flags
 3      15.7MB  528MB   513MB   linux-swap(v1)  primary
 1      528MB   2576MB  2048MB  ext3            primary  raid
 2      2576MB  4624MB  2048MB  ext3            primary  raid
 4      4624MB  3001GB  2996GB  ext4            primary

 (parted)

We will use sda1 as our new root partition and thus remove it from the RAID 1. The RAID device can be found out via proc filesystem:

Gondor:/boot# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md1 : active raid1 sda2[1] sda1[0]
      1999808 blocks [2/2] [UU]

unused devices: <none>

In this case, it is md1 but other MyBook Live systems seem to have different device numbers. Lets first fail and remove sda1:

Gondor:/boot# mdadm --manage /dev/md1 --fail /dev/sda1
mdadm: set /dev/sda1 faulty in /dev/md1
Gondor:/boot# mdadm --manage /dev/md1 --remove /dev/sda1
mdadm: hot removed /dev/sda1 from /dev/md1

Now we can format the empty partition and mount it.

Gondor:/boot# mkfs.ext3 /dev/sda1
Gondor:/boot# mkdir /newsys
Gondor:/boot# mount /dev/sda1 /newsys

RECOVERY: In case that something went wrong and you need to restore the original system, add sda1 to the raid and resync. If the system is unbootable, you have to do this by disassembling the MyBookLive and attaching the HD to an external Computer running Linux.

Bootstrap Debian

First we install debootstrap

Gondor:/tmp# wget http://ftp.de.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.67_all.deb
Gondor:/tmp# dpkg -i debootstrap_1.0.67_all.deb

I had to import the new debian archive keys since the ones on my mybooklive were too old

Gondor:/tmp# gpg --no-default-keyring --keyring /usr/share/keyrings/debian-archive-keyring.gpg   --keyserver keyserver.ubuntu.com --recv-keys 6FB2A1C265FFB764

Bootstrap the base system

Gondor:/tmp# debootstrap --arch powerpc wheezy /newsys/ http://ftp.de.debian.org/debian

Prepare networking

Networking setup is achived by copying interfaces and resolv.conf and setting a hostname

Gondor:/tmp# cp /etc/network/interfaces /newsys/etc/network/
Gondor:/tmp# cp /etc/resolv.conf /newsys/etc/
Gondor:/tmp# echo 'gondor' > /newsys/etc/hostname

Configure sources.list

Edit /newsys/etc/apt/sources.list

Gondor:/tmp# vim /newsys/etc/apt/sources.list

Change content e.g. to:

deb http://ftp.de.debian.org/debian/ stable main contrib non-free
deb-src http://ftp.de.debian.org/debian/ stable main contrib non-free
deb http://security.debian.org/ stable/updates main contrib non-free
deb-src http://security.debian.org/ stable/updates main contrib non-free
deb http://ftp.de.debian.org/debian stable-updates main contrib non-free
deb-src http://ftp.de.debian.org/debian stable-updates main contrib non-free

Chrooting to install additional software

For kernel compilation, the 2G default space are not enough, thus we bind-mount an external directory before chrooting.

Gondor:~# mkdir /DataVolume/shares/kernel
Gondor:~# mkdir /newsys/root/kernel
Gondor:~# mount -o bind /DataVolume/shares/kernel/ /newsys/root/kernel/

Mounting dev and proc:

Gondor:/tmp# mount -o bind /proc /newsys/proc/
Gondor:/tmp# mount -o bind /dev /newsys/dev/

Chroot …

Gondor:/tmp# chroot /newsys/

In the chroot, we install openssh-server and set a password for the root user

root@Gondor:/# apt-get update
root@Gondor:/# apt-get install openssh-server vim
root@Gondor:/# passwd

Newer versions of openssh in debian disallow password based login for the root user. Therefore we have to change the following line in /etc/ssh/sshd_config:

PermitRootLogin: prohibit-password

to

PermitRootLogin: yes 

Alternatively, you can place the public part of your ssh key in /root/.ssh/authorized_keys.

Prepare mountpoints and fstab

My choice is to mount the big data partition to /mnt/data, feel free to adjust.

root@Gondor:/# mkdir /mnt/data

Edit fstab:

proc      /proc        proc   defaults                         0 0
sysfs     /sys         sysfs  defaults                         0 0
tmpfs     /tmp         tmpfs  rw,size=100M                     0 0
/dev/sda1 /            ext3   defaults,noatime,nodiratime      0 0
/dev/sda3 swap         swap   defaults                         0 0
/dev/sda4 /mnt/data    ext4   defaults,auto,noatime,nodiratime 0 0

These are mostly common options, the tmpfs size is limited since the MybookLive only has 256MB RAM.

Kernel & UBoot

Preparation and Patching

In our chroot, we now install all the tools we require for kernel building and creation of th eu-boot bootloader entrypoint.

root@Gondor:~/kernel# apt-get install ca-certificates build-essential uboot-mkimage ncurses-dev unzip

Download and patch the kernel

root@Gondor:~/kernel# wget https://mbl-common.googlecode.com/svn/kernel_2.6.32-61/010-kernel_2.6-add-modules.builtin.patch
root@Gondor:~/kernel# wget https://mbl-common.googlecode.com/svn/kernel_2.6.32-61/001-kernel_2.6.32-61-APM82181-with-accept4.patch
root@Gondor:~/kernel# wget https://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.32/linux-2.6.32.65.tar.xz
root@Gondor:~/kernel# xz -dc linux-2.6.32.65.tar.xz | tar -x
root@Gondor:~/kernel# cd linux-2.6.32.65
root@Gondor:~/kernel/linux-2.6.32.65# patch -p1 -i ../001-kernel_2.6.32-61-APM82181-with-accept4.patch
root@Gondor:~/kernel/linux-2.6.32.65# patch -p1 -i ../010-kernel_2.6-add-modules.builtin.patch

Building and installing kernel

Kernel building steps…

root@Gondor:~/kernel/linux-2.6.32.65# make distclean
root@Gondor:~/kernel/linux-2.6.32.65# make mrproper
root@Gondor:~/kernel/linux-2.6.32.65# make 44x/apollo_3G_nas_defconfig
root@Gondor:~/kernel/linux-2.6.32.65# make uImage

Copy the kernel image to its new location

root@Gondor:~/kernel/linux-2.6.32.65# cp arch/powerpc/boot/uImage /boot/

Build and install kernel modules

root@Gondor:~/kernel/linux-2.6.32.65# make modules
root@Gondor:~/kernel/linux-2.6.32.65# make modules_install

UBoot Configuration

Create boot.cmd with following content

echo Boot from U-boot configuration
setenv md0_args 'setenv bootargs root=/dev/sda1 rw rootfstype=ext3 rootflags=data=ordered'
setenv load_sata 'sata init; ext2load sata 1:1 ${kernel_addr_r} /boot/uImage; ext2load sata 1:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv boot_sata 'run load_sata; run md0_args addtty; bootm ${kernel_addr_r} - ${fdt_addr_r}'
echo ==== Loading Linux kernel, Device tree, Root filesystem ====
run boot_sata

Convert to binary bootloader config

mkimage -A powerpc -O linux -T script -C none -a 0 -e 0 -n 'Execute uImage' -d boot.cmd boot.scr
cp boot.scr /boot/

Exit the chroot via exit and copy the device tree blob in the new system.

Gondor:/boot# cp /boot/apollo3g.dtb /newsys/boot/

Cross Fingers

..and reboot :-)

Acknowledgements

Many thanks to Darren Strauss and Paul Trenholme for pointing out some issues in the original post.