systemd mount units
I needed to add a lot of storage to /var/lib/docker on a coreOS qemu VM using a version of their coreos_production_qemu.sh script.
# add to ignition yaml:
systemd:
units:
- name: var-lib-docker.mount
enable: true
contents: |
[Unit]
Before=local-fs.target
[Mount]
What=/dev/disk/by-label/docker_data
Where=/var/lib/docker
Type=ext4
Options=rw,relatime,seclabel,data=ordered
[Install]
WantedBy=local-fs.target
# regenerate ignition json:
ct -in-file tansu-config.yml -out-file tansu-config.ignition
# create disk image
qemu-img create -f raw /data/coreos/tansu_docker.img 500G
# add line to wrapper script around coreos_production_qemu.sh:
-drive if=virtio,format=raw,file=/data/coreos/tansu_docker.img,discard=unmap \
# restart coreOS, format ext4, mount new disk,
rsync -xavSH /var/lib/docker/ /mnt/
# create /etc/systemd/system/var-lib-docker.mount
systemctl enable var-lib-docker.mount
# stop docker containers
systemctl stop docker
rsync -xavSH /var/lib/docker/ /mnt/
# reboot
Important bit about systemd mounts: unit file must be named according to Where path. docker.mount would fail with a delightfully useless error message, var-lib-docker.mount is what the unit must be called.