How to set up a Debian‐based chroot environment on a Synology DS218 NAS - fredlcore/BSB-LAN GitHub Wiki
I found this great set of instructions on the web, but decided to do it in an even less intrusive way by not editing the system-wide fstab file, so here's the set of commands in short, make sure to adjust the debootstrap URL based on their site:
wget https://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.141~bpo12+1.tar.gz
tar xvfz debootstrap_1.0.141~bpo12+1.tar.gz
sudo mv debootstrap /usr/share/
CHROOT=/volume1/chroots/debian
sudo mkdir -p $CHROOT
sudo /usr/share/debootstrap/debootstrap stable $CHROOT http://deb.debian.org/debian/
This will take a while.
sudo mount -t proc proc $CHROOT/proc
sudo mount -t sysfs sysfs $CHROOT/sys
sudo mount --bind /dev $CHROOT/dev
sudo cp /etc/hosts $CHROOT/etc/hosts
sudo cp /proc/mounts $CHROOT/etc/mtab
sudo chroot $CHROOT /bin/bash
...and you've entered the debootstrap chroot environment. Now you can install all necessary packages using apt-get, completely detached from your Synology DSM system. Leave the chroot environment via exit and return whenever you want using sudo chroot $CHROOT /bin/bash (replace $CHROOT with the actual path or set $CHROOT as above).
Take note that the mounts do not survive a reboot, so before you enter the chroot, make sure they are set accordingly.
Alternatively, you can set up a script debchroot.sh that contains the relevant commands from above and use that one to enter the chroot environment:
#!/bin/bash
CHROOT=/volume1/chroots/debian
sudo mount -t proc proc $CHROOT/proc
sudo mount -t sysfs sysfs $CHROOT/sys
sudo mount --bind /dev $CHROOT/dev
sudo cp /etc/hosts $CHROOT/etc/hosts
sudo cp /proc/mounts $CHROOT/etc/mtab
sudo chroot $CHROOT /bin/bash
If the mounts are already set, the script will notify you with warnings, but it enters the chroot environment nevertheless.
Once in the chroot environment, as a first step, you should install the proper locale:
apt update
apt install locales
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
And these are further necessary/useful packages required to compile BSB-LAN using arduino-cli:
apt install curl
apt install unzip
apt install python3
apt install minicom
Then you can continue with installing arduino-cli as described here.