A free cloud VM, and the reboot hang that wasn't the kernel
This site is served from a small Oracle Cloud (OCI) VM on the Always Free tier: Ubuntu 24.04 on an E2.1.Micro, which is 1 GB of RAM and a fraction of one CPU. It is set up with Ansible. I moved there because it’s free for good, and, unlike on Google Cloud, the public IP address doesn’t cost anything.
Then I tried rebooting it.
About half the reboots hung
A reboot either came back in about 70 seconds or never came back. No ping, no ssh, and OCI still said RUNNING. Only a hard reset from the OCI console brought it back, and sometimes that needed a second one.
The serial console was the same on every hang. It stopped on Finished cloud-init-local.service at about 21 seconds, with no panic, no OOM and no error.
What it wasn’t
I spent a day crossing things off:
- The kernel. I pinned it with
apt-mark hold, then moved the box from 6.17 to 6.14, the version the other VM was running. It still hung. - MTU. The VM comes up with MTU 9000. I forced 1500, and it hung 3 times in 4 runs.
- Slow boot on a tiny CPU.
snapdwas eating 6 minutes of a 6m43s boot. Throttling it brought boot to 2m04s. It still hung.
Turning cloud-init off gave 16 clean reboots in a row. That pointed at the cause, but it also meant giving up cloud-init, so it wasn’t the fix.
The cause: a systemd ordering race
I had been reading the silence as “the VM froze”. It hadn’t. systemd never reached sysinit.target, so nothing after it (networking, ssh) ever started. The VM was alive the whole time.
The box keeps a persistent journal, and across 39 boots every hung boot contained this line and every good one didn’t:
Requested transaction contains an unfixable cyclic ordering dependency
The units form a loop: cloud-init.service has to finish before sysinit.target, but it waits for networking. Networking waits for firewalld, which waits for basic.target. That waits for the sockets, and the sockets wait for sysinit.target. The loop exists on every boot. Whether systemd trips over it depends on timing, which is why only about half the boots failed.
The fix
I removed Before=sysinit.target from cloud-init.service with a full override copy in /etc/systemd/system. A drop-in doesn’t work here: systemd 255 doesn’t clear a dependency list when you write an empty Before=. systemd-analyze verify prints the cycle before the change and nothing after.
An apt hook now compares the override with upstream after every package upgrade, so I get a warning if an update makes it stale.
How it turned out
With the override, 29 of 30 reboots were clean. The one hang left no journal at all, so I can’t say what it was. The other VM got the same fix, and 12 reboots in a row were clean. That second result only shows the fix does no harm, because that VM had never hung.
Things that helped
- Backups and a serial console first. Free tier lets you keep 5 boot-volume backups, and you can open a serial console on the instance.
- The console quirk. OCI’s serial console only offers
ssh-rsa, which Fedora’s crypto policy refuses. I ran ssh from a throwaway Debian container. - The persistent journal. It’s what exposed the cycle. Console output only showed that something was stuck.
Loading comments…