[GUIDE] Install gentoo on WD My Book Live

I have serveral WD my-book-lives. These little boxes are small, power efficient, and have an old debian preinstalled. I found it a better NAS solution than SBC + USB disk.

The origin firmware, although based on debian, is pretty outdated, however, with the community’s great work, linux kernel 4.x and debian 8 could be installed. (More at github/KL-Yang/mbl-linux-4.0 and github/ewaldc/My-Book-Live/, thanks you! KL-Yang and Ewald).

Unfortunately, Debian and many other linux distros are quickly phasing out support for 32bit ppc processors, leaving debian 8 the last release that could be install on mybook live, moreover, all powerpc debs are already moved to archive.debian.org.

There are only a few (linux) distros will support 32bit ppc for next several years, what i’ve found are openwrt and gentoo. (Could any BSD be installed on mybooklive? )OpenWrt has official support for mybooklive, but I think gentoo is more generic and has more packages. So I tried to install gentoo on mybooklive.

WARNING! Open the case and install 3rd party os may void your warranty, you are on your own, YOU HAVE BEEN WARNED.

Mybooklive (single disk version) technical specs:

  • CPU: Applied Micro APM82181 runs at 800MHz, powerpc 464fp architecture
  • RAM: 256MB DDR2
  • Gigabit-lan, sata port, No USB ports
  • Howto open case: ifixit/Teardown/Western+Digital+My+Book+Live+Teardown/26942

The plan:

The uboot of mybooklive only boot kernel from ext2/3 partition, so first install debian on ext2/3 to bootstrap gentoo on ext4, after gentoo is ready, debian partition will act as a boot partition and a backup system.

The process:

  1. prepare disk

Make sure the data on the disk is backed up or can be discarded, attach the disk to a linux box, use fdisk or parted to create a gpt table, then format the partitions like this:

/dev/sde1 2G ext3 debian boot
/dev/sde2 20G format later in debian as gentoo partition
/dev/sde3 512M format later in gentoo as swap
/dev/sde4 format later in gentoo as data partition

  1. install debian
  • decompress the tarball, github/ewaldc/My-Book-Live/tree/master/debian/debian%208%20(Jessie)
root# mkdir /mnt/debian
root# mount /dev/sde1 /mnt/debian
root# cd /mnt/debian
root# tar xzf /path/to/DebianJessie8.11.tgz
  • delete unneed fstab entries otherwise will block boot
root# cat /mnt/debian/etc/fstab

tmpfs /tmp tmpfs rw,size=100M 0 defaults,noexec,nosuid,nodev,mode=0755,size=100M 0 0
/dev/sda1 / ext3 defaults,noatime 0 0
  • umount and unplug the disk
root# cd /
root# umount /mnt/debian
  1. bootstrap gentoo
  • install the disk to the circuit board and boot, ssh into it(default root password is welc0me)
ssh root@<device ip found in router>

*** Attention! now in the debian ***

ETNas# mkfs.ext4 -b 16384 /dev/sda2
ETNas# mkdir /mnt/gentoo
ETNas# mount /dev/sda2 /mnt/gentoo
ETNas# cd /mnt/gentoo
ETNas# wget /url/to/stage3
ETNas# tar xpvf stage3.tar.name --xattrs-include='*.*' --numeric-owner

for make.conf, I use -mcpu=464fp -mtune=464fp according to gcc doc

for USE flag, i add “minimal” to reduce dependencies, (compile on a 800m single core processor would be very slooow), configure the mirror for gentoo and portage and ready to chroot:

ETNas# cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
ETNas# mount --types proc /proc /mnt/gentoo/proc
ETNas# mount --rbind /sys /mnt/gentoo/sys
ETNas# mount --make-rslave /mnt/gentoo/sys
ETNas# mount --rbind /dev /mnt/gentoo/dev
ETNas# mount --make-rslave /mnt/gentoo/dev
ETNas# chroot /mnt/gentoo /bin/bash

*** Attention now in gentoo chroot ***

ETNas# source /etc/profile
ETNas# export PS1="(chroot) ${PS1}"
  • bootstrap portage
(chroot) ETNas# emerge-webrsync
(chroot) ETNas# eselect profile list
  • install dropbear to enable ssh service (dropbear is more slim compare to sshd)
(chroot) ETNas# emerge --ask net-misc/dropbear
(chroot) ETNas# rc-update add dropbear
  • config network
(chroot) ETNas# ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
(chroot) ETNas# cat /etc/conf.d/net

(chroot) ETNas# rc-update add net.eth0
  • swap and fstab
(chroot) ETNas# mkswap /dev/sda3
(chroot) ETNas# swapon /dev/sda3
(chroot) ETNas# cat /etc/fstab

/dev/sda2 / ext4 defaults,noatime 0 1
/dev/sda3 none swap defaults 0 0
  • finally don’t forget to set password (which I forgot for the first time :-P) and back to debian
(chroot) ETNas# passwd
(chroot) ETNas# exit
  1. install kernel lib and boot file
  • copy kernel lib from debian partition to gentoo partition
ETNas# cp -r /lib/modules/ /mnt/gentoo/lib/
  • build boot file: github/ewaldc/My-Book-Live/tree/master/uboot
ETNas# cd
ETNas# cat boot.txt
setenv md0_args 'setenv bootargs root=/dev/sda2 rw rootfstype=ext4'
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
ETNas# mkimage -A powerpc -O linux -T script -C none -a 0 -e 0 -n 'Execute uImage' -d boot.txt boot.scr
ETNas# cd /boot
ETNas# mv boot.scr boot.scr.bak
ETNas# cp ~/boot.scr ./
ETNas# reboot

reboot and try to ssh to gentoo

if everything goes well, now a (very) basic gentoo environment is ready. you can follow gentoo handbook for detail configurations and emerge various packages or even compile kernel. Enjoy :slight_smile:

1 Like

The biggest problem with that is the Kernel. You will need to replace the rather dated Linux Kernel early on before you can truly bootstrap the system with Gentoo. Also, it’s best if you can move the partition elsewhere on the disk (delete the large partition, partition it towards the end, and dd the partition to the new one) or flat out TFTP/NFS boot (which is what I’ve been doing lately).

I would suggest having at least a 32MB boot (sda1 ext2), a 1GB swap (sda2), and an 8GB root (sda3 ext4). You can partition the rest of it how you’d like it.

I’ve been running Gentoo on the MBL for… almost a decade now. They’re currently running Kernel 4.19.99 and it runs rather smooth. I now have 4, a 1TB, 2TB, 3TB, and a Duo 4TB.

Word of advice, if you’re going to take it apart (there are ways to do the above without taking it apart), add the Serial Port mod. It will make your life a ton easier since you can do practically everything through the serial port.

Cool walkthrough. One question though, why use the 64k block size for the ext4 partition? Just followed your guide but with default blocksize and everything works just fine. Plus, the gentoo partition becomes visible in an external linux box such as a x86 machine.