Debian chroot on Synology NAS

Last week I decided to by myself an early X-mas present: a Synology DS211 NAS to replace my power hungry desktop PC to share my data on the network.

The main reason I bought this NAS is the fact that it runs Linux, it is highly ‘customizable’ (you can install extra software packages) and it has a large community behind it.

Because after bootstrapping the device I found that too many applications were not available with the ipkg tool, I decided to create a chroot environment in which I could easily install apps without the need of compiling (or even cross compiling) them.

0. Prerequisites

  • a bootstrapped Synology Nas (howto)
  • a computer running Debian/Ubuntu (native or in a virtual machine) - only needed when creating the chroot from scratch
1. Create the chroot environment - or download mine here
In order to create the chroot environment from scratch, you need to complete 2 phases. The first phase needs to be performed on a computer/VM running Debian/Ubuntu, the second phase has to be done on the target device itself.

The following instructions are copied from a tutorial for getting a chroot on the DS101g+ (thanks Miro Dietiker !).

<copy>
Lines beginning with ds# need to be executed on target DS211+ console, while lines with leading pc$ are to be executed on your local PC.

Now we create folders for the Debian project and roots under project home.

pc$ mkdir -p ~/ds211/debian/chroottarget
ds# mkdir -p /volume1/debian/chroottarget

From now on, all commands need to be executed in this directory!

pc$ cd ~/ds211/debian
ds# cd /volume1/debian

Get debootstrap. Even if you intend to install sarge and stable, it is recommended that you use the newest version of the debootstrap script due to updates. For debian users:

pc$ wget http://ftp.de.debian.org/debian/pool/main/d/debootstrap/debootstrap_0.3.3.1_all.deb
pc$ dpkg --install debootstrap_0.3.3.1_all.deb

Execute debootstraps first stage to fetch all packages for the target platform:

pc$ debootstrap --foreign --arch atmel lenny chroottarget "http://ftp.de.debian.org/debian"

Now we move this folder root to the target…

pc$ tar -czf chroottarget.tar.gz chroottarget

Copy the tar file using your preferred method (SMB, NFS, SFTP etc…) to the target in /volume1/debian and untar.

ds# tar -xzf chroottarget.tar.gz

tar should not display any errors or warning like “convert sym links to …”. The best
to transfert archive is to do it from the local PC under linux, not from windows.

Finish debootstrap second stage on target platform.

ds# chroot chroottarget /debootstrap/debootstrap --second-stage

</copy>

2. Configure the chroot environment

Copy the file /etc/resolv.conf of your NAS to your chroot environment in order to make name resolving work.

ds# cp /etc/resolv.conf chroottarget/etc/

Set the ‘hostname’ of your chroot environment (otherwise some apps will complain).

ds# echo <YourHostname> > chroottarget/etc/hostname

Bind /proc to the proc directory of your chroot environment.

ds# mount -o bind /proc /chroottarget/proc

Now it is time to chroot to your new Debian install and setup apt.

ds# chroot chroottarget /bin/bash
ds-chroot# echo "deb ftp://ftp.be.debian.org/debian stable main contrib non-free" > /etc/apt/sources.list
ds-chroot# apt-get update

That’s it !

2 Comments

[...] Last week I decided to by myself an early X-mas present: a Synology DS211 NAS to replace my power hungry desktop PC to share my data on the network. The main reason I bought this NAS is the fact that it runs Linux, it is highly ‘customizable’ (you can install extra software packages) and it has a large community behind it. More here [...]

TwirrimDecember 12th, 2010 at 8:29 pm

I bought a DS109j for similar reasons. Love it. Actually ended up getting one of it’s bigger brothers for use in a data center as an NFS backend. It’s not going to break any performance records but its ideal for our purposes.

Leave a comment

Your comment