Looking inside an lxd container launched from image “ubuntu:20.04”, systemctl says it is “degraded”:
root@vault1:~# systemctl status | head -4
● vault1
State: degraded
Jobs: 0 queued
Failed: 1 units
And the problem is this service:
root@vault1:~# systemctl | grep fail
● systemd-remount-fs.service loaded failed failed Remount Root and Kernel File Systems
root@vault1:~# systemctl status systemd-remount-fs
● systemd-remount-fs.service - Remount Root and Kernel File Systems
Loaded: loaded (/lib/systemd/system/systemd-remount-fs.service; enabled-runtime; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-02-03 07:01:46 UTC; 2 weeks 6 days ago
Docs: man:systemd-remount-fs.service(8)
https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Main PID: 65 (code=exited, status=1/FAILURE)
Feb 03 07:01:46 vault1 systemd-remount-fs[73]: mount: /: can't find LABEL=cloudimg-rootfs.
Warning: journal has been rotated since unit was started, output may be incomplete.
root@vault1:~# cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
root@vault1:~#
Clearly, a container shouldn’t be attempting to mount its own root filesystem in the first place, and ideally the container images would be set up so no user tweaking is required.
I can solve it by commenting out that line in /etc/fstab
by hand, and restarting the container.
However, does anybody know an “official” way to fix this at container creation time? I have tried the following in user.user-data
:
#cloud-config
mounts: []
and
#cloud-config
mounts: [['LABEL=cloudimg-rootfs']]
and
#cloud-config
mounts: [['LABEL=cloudimg-rootfs',null]]
but none of these work. In the second and third cases, /var/log/cloud-init.log
shows:
2022-02-23 09:00:43,217 - stages.py[DEBUG]: Running module mounts (<module 'cloudinit.config.cc_mounts' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_mounts.py'>) with frequency once-per-instance
2022-02-23 09:00:43,218 - handlers.py[DEBUG]: start: init-network/config-mounts: running config-mounts with frequency once-per-instance
2022-02-23 09:00:43,219 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/tst1/sem/config_mounts - wb: [644] 24 bytes
2022-02-23 09:00:43,220 - helpers.py[DEBUG]: Running config-mounts using lock (<FileLock using file '/var/lib/cloud/instances/tst1/sem/config_mounts'>)
2022-02-23 09:00:43,221 - cc_mounts.py[DEBUG]: mounts configuration is [['LABEL=cloudimg-rootfs']]
2022-02-23 09:00:43,221 - util.py[DEBUG]: Reading from /etc/fstab (quiet=False)
2022-02-23 09:00:43,222 - util.py[DEBUG]: Read 43 bytes from /etc/fstab
2022-02-23 09:00:43,222 - cc_mounts.py[DEBUG]: Attempting to determine the real name of LABEL=cloudimg-rootfs
2022-02-23 09:00:43,222 - cc_mounts.py[DEBUG]: changed LABEL=cloudimg-rootfs => None
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: Ignoring nonexistent named mount LABEL=cloudimg-rootfs
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: Attempting to determine the real name of ephemeral0
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: changed default device ephemeral0 => None
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: Ignoring nonexistent default named mount ephemeral0
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: Attempting to determine the real name of swap
2022-02-23 09:00:43,223 - cc_mounts.py[DEBUG]: changed default device swap => None
2022-02-23 09:00:43,224 - cc_mounts.py[DEBUG]: Ignoring nonexistent default named mount swap
2022-02-23 09:00:43,224 - cc_mounts.py[DEBUG]: Skipping nonexistent device named LABEL=cloudimg-rootfs
2022-02-23 09:00:43,224 - cc_mounts.py[DEBUG]: no need to setup swap
2022-02-23 09:00:43,224 - cc_mounts.py[DEBUG]: No modifications to fstab needed
2022-02-23 09:00:43,224 - handlers.py[DEBUG]: finish: init-network/config-mounts: SUCCESS: config-mounts ran successfully
“Read 43 bytes from /etc/fstab” suggests that the line is already there:
root@tst1:~# cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 1
root@tst1:~# wc -c /etc/fstab
43 /etc/fstab
But it’s not matching my rule. It looks like sanitize_devname
in cloudinit/config/cc_mounts.py
throws it away because it can’t find a device on the system with this name (and it’s not an otherwise recognized format like a network mount host:/path
)
Any ideas?
I’m not sure whether to class this issue as:
- A problem with the Ubuntu lxd image itself (containing an fstab entry that’s not needed in a container)
- An issue with cloud-init’s cc_mount not being able to manage LABEL=… entries
- Something else