synology-docker: Updated binaries are incompatible with btrfs
Thanks for an excellent script!
Unfortunately, the updated binaries appear to be incompatible with BTRFS; given docker stack deploy stack -c stack.yaml all containers fail to launch with error: Failed to create btrfs snapshot: inappropriate ioctl for device.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 2
- Comments: 29 (13 by maintainers)
Hi there, Thanks for the great script! I ran into this same issue on a DS1819+ with a brtfs filesystem, where after updating Docker through the script, running
docker pullwould produce theFailed to create btrfs snapshot: inappropriate ioctl for device.error.I found that editing
/var/packages/Docker/etc/dockerd.jsonto use thevfsstorage device instead ofbrtfsworked. The Docker documentation suggests that the vfs storage driver, while not performant nor recommended for production use, is robust/stable, so I feel OK using it. In a brief test theoverlay2storage driver didn’t work for me, hence why I usedvfsIn my case I also deleted all my existing images before re-pulling everything, since the storage driver has something to do with how the images are stored:
Final
dockerd.jsonwas as follows:After all that, the updated non-DSM Docker seems to be working well for me after re-pulling and re-configuring my images. That being said, the GUI for Docker in DSM has a few bugs: the days since reboot for each container is some very large value, and the logs are not viewable (presumably from
json-filevsdb).That’s unfortunate. My NAS still uses EXT4, so I’m not able to reproduce your error. However, after some research, possibly changing the storage driver might help? I used Docker’s guide as a reference. Following step 6 of the guide, add
"storage-driver": "btrfs"to/var/packages/Docker/etc/dockerd.json. Make a backup of the file first to revert back to the previous version in case of any errors. The full configuration could look something like this:You will have to restart the Docker service to pick up the changes. Revert back to the old version of
dockerd.jsonif starting of the service fails.I’ve found the code responsible for this. In the Synology kernel,
linux-4.4.x.tar.gz, the following BTRFS code is patched, and throwsENOTTY(= “Inappropriate ioctl for this device”).I’m not familiar with BTRFS or kernel internals, but combined with patches in
./include/uapi/linux/btrfs.h,./usr/include/linux/btrfs.h, the rest of./fs/btrfs/, and/usr/local/include/synobtrfssnapusage/in the toolkit image, my impression is that Synology patches btrfs in several ways, but particularly to restrict or modify btrfs snapshots, which are very heavily used by both Synology and Docker../fs/btrfs/ioctl.c./fs/btrfs/super.cI have compiled btrfs-progs v4.4 through v4.16 on e2fs v1.43.9, and v4.16.1 through v5.15 on current e2fs. All have the same error.
I am still working on compiling btrfs-progs v4.0 through v4.3.1. They require kernel headers to compile, which is a bit of a pain. (
No rule to make target 'kernel-shared/volumes.h', needed by 'btrfs.o'.) TBD.I suspect that, because v4.0-v4.3.1 of btrfs-progs rely on kernel headers, they thereby import Synology’s btrfs related patches in the kernel, and that is what actually allows them to work. I haven’t yet tried copying a non-Synology-sourced btrfs-progs v4.0 (e.g. compiled against the standard linux 4.4.180 headers) to see if it works on Synology.
If a normal btrfs-progs v4.0 works, then the issue is some sort of change in btrfs-progs between v4.0 and v4.4. If it doesn’t, then the issue is the Synology patches to btrfs. I believe I could get the v4.0 btrfs-progs library compiled against the Synology kernel, but if the issue is Synology patches, I have no idea what versions of btrfs would be compatible even if v4.4+ could be coerced to use them for compilation.
For that matter, btrfs itself requires e2fs-progs, and Synology has patches to that, too. It’s possible that that has some sort of lingering effect, even on non-ext2/3/4 filesystem. No idea.
Testing against standard v4.0 btrfs-progs, and non-Synology-e2fs Synology-kerenel-btrfs compiled v4.0 progs, should give an answer to most of it. If it is actually because btrfs-progs v4.0-v4.3.1 accidentally includes the Synology btrfs kernel patches, rather than because of some intentional change by btrfs-progs, that’ll be a lot harder to test safely.
Impressive article @technorabilia! I was always a bit hesitant to bypass Docker’s package completely and to install Docker from scratch instead. But it’s great to know it can be done. If your suspicion is right, then Synology’s flawed kernel support for
btrfsis the core issue here.I’ll include a link to your article in the Known Issues, as it might help others too. Thanks for sharing your experience!