Install a Debian chroot on your Synology disk station

If you’re googling this and are eager to have a chroot running on your x86 Synology box, please scroll down.
These instructions worked for me on my DS416play. 
Should work for you too.

So here’s what happened

I’ve been a happy user of a Synology disk station for quite a while now, it mostly just works. I’ve observed some issues with the Plex server that I have running on it, but that’s hardly Synologie’s fault.

Today however I did experience something new, the disk station was very slow to respond and it took ages even to do the simplest of operations.

Luckily, underneath all the fancy UI, it’s just a Linux box, surely I could debug it, I thought.

I have had the SSH account enabled on it since the beginning, but I have not ever actually used it for anything.

Now that I experienced the slowness, I finally had a good use case for logging in and troubleshooting, but I was surprised to discover that it lacks any observability tools beyond ps and top

What I needed was vmstat (or dstat), iostat et al.

Installing debug tools

Quick googling revealed that there is a set of debug tools that you can install  using the command: sudo synogear install

Once you have them you can do synogear list to see what’s available to you.

So far so good, and this should give enough tools to start with.
If you need fancier tools, you can use ipkg or Entware
Of course this does come with added downside of running random binaries off the internet. So think a bit about the implications.

Initially I seem to have overlooked another option.

It turns out there is Synocommunity, and you can quite easily add their packages by changing one setting in Package manager settings by setting it to use packages by “Synology Inc. and trusted publishers”.

But what if there was a better way

It is a Linux box after all. I noticed that the chroot command is available. So why not to try to debootstrap a nice Debian chroot…

There’s always a way. This might not be the most elegant one, but that’s how I did it.

First things first, we’ll need chroot package. You can take it from any Debian mirror. Luckily it is mostly just bunch of scripts. One dependency it has is Perl. You can install Perl via the Synology package manager.
Once you have both the chroot package and Perl, it’s just a standard Debian debootsrapping procedure.

Deploy a Debian chroot on your Synology box

Make sure you have Perl installed (see above).
Get latest debootstrap package and unpack it.

wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.109.tar.gz
tar xvzf debootstrap_1.0.109.tar.gz
# debootstrap assumes some file locations, you could fix that or just move it to where it expects to be
mv debootstrap-1.0.109 /usr/share/debootstrap

You should now be able to invoke debootstrap command using the full path /usr/share/debootstrap/debootstrap

Now, pick a nice place to keep your chroots and run the debootstrap command to create a fresh new Debian chroot for you.

CHROOT=/volume1/chroots/debian
mkdir -p $CHROOT
/usr/share/debootstrap/debootstrap stable $CHROOT http://deb.debian.org/debian/

If everything went well, then congrats, you should be all set, feel free to chroot into your new Debian as usual

echo "proc $CHROOT/proc proc defaults 0 0" >> /etc/fstab
mount proc $CHROOT/proc -t proc
echo "sysfs $CHROOT/sys sysfs defaults 0 0" >> /etc/fstab
mount sysfs $CHROOT/sys -t sysfs
cp /etc/hosts $CHROOT/etc/hosts
cp /proc/mounts $CHROOT/etc/mtab
chroot $CHROOT /bin/bash

If anyone asks, you’re sort of running a container on your Synology now, an you can now install whatever tools you need.

See this for more complete instructions on building a chroot.

And all that, without messing up your Synology with any 3rd party packages.