The Intel Atom CPU with earlier Synology units does not have VT-x extensions 1, and using KVM will fall back to full (slow) emulation. These units do provide a way to run workloads via Docker, however, and we can instead paravirtualize with User Mode Linux inside a container. You can read more about UML in Jeff Dike's book 2. I won't detail configuring UML here, I will only present what I am using.
Firstly, create a container to bootstrap the image. I used rdebath-devuan:beowulf
, and then added a folder into the container from the Synology. Go to Docker > Container > [NAME] > Edit > Volume and then "Add Folder", mount it at /mnt. You will use this same volume to provide the disk for your VM to boot from. Once you start the container, change to the Terminal pane. Run the following:
# debootstrap beowulf /mnt/a
# chroot /mnt/a tasksel openssh-server
# cat > /mnt/a/etc/network/interfaces <<_EOF_
auto eth0
iface eth0 inet static
address 10.0.2.15/32
up ip route add default dev eth0
_EOF_
# cat > /mnt/a/root/.ssh/authorized_keys <<_EOF_
...
_EOF_
# mkfs.ext4 /mnt/a.img -d /mnt/a 10G
Once this finishes, you'll have a filesystem ready to boot. Create a new Docker container, example Dockerfile:
FROM rdebath/devuan:beowulf
RUN apt -y update && apt -y install user-mode-linux slirp
COPY run-slirp.sh /run-slirp.sh
VOLUME ["/disks"]
VOLUME ["/dev/shm"]
ENTRYPOINT ["linux"]
CMD ["mem=512M","ubda=/disks/a.img","con=pts","con0=fd:0,fd:1","con1=none","umid=devuan","eth0=slirp,,/run-slirp.sh","net.ifnames=0"]
EXPOSE 22
Where /run-slirp.sh
is:
#!/bin/sh
exec /usr/bin/slirp-fullbolt "redir 22 22"
Create a volume to be mounted at /dev/shm
, the ssh into your Synology and mount it as tmpfs. This is a bit hacky, but you'll need to have scratch space available for UML. Also mount the volume you created earlier, mine's at /disks
. Once you bring the container up you will see the kernel boot messages in the terminal in Synology's web interface. You can then ssh into the port you exposed, with the key you supplied. And, looking at the "cpu":
$ cat /proc/cpuinfo
processor : 0
vendor_id : User Mode Linux
model name : UML
mode : skas
host : Linux devuan 3.10.105 #25426 SMP Wed Jul 8 03:16:31 CST 2020 x86_64
bogomips : 2092.23
Enjoy!
No comments:
Post a Comment