這是一張有關標題為 Fixing Ubuntu 24.04 Boot Hang: System Stalls When Ethernet Port is Off 的圖片

Fixing Ubuntu 24.04 Boot Hang: System Stalls When Ethernet Port is Off

Resolve Ubuntu Server 24.04 boot hang when Ethernet LED is off: use GRUB recovery to configure Netplan, fix permissions, reboot to restore network connectivity.

Introduction

I recently had to provision a new Ubuntu Server (24.04.2 LTS). After plugging in the Ethernet cable, I noticed a critical problem: the network port light on the back of the machine refused to light up.

By design, Ubuntu Server defaults to using systemd-networkd, which means its corresponding “wait” service, systemd-networkd-wait-online.service, is also enabled. When there’s a network configuration issue or the NIC is disconnected, this service will halt the boot process until it times out (typically 120 seconds).

It’s crucial to get the network configuration right during the Ubuntu installation. Otherwise, you’re likely to face a system that hangs for a long time during boot, significantly delaying access to the login prompt.

Getting into the System for Repairs

If you can actually boot into the system, the fix is trivial. You can follow the steps in the Network Configuration section of our guide, "Ubuntu Server 24.04: Installation, Partitioning, and Network Configuration". Just define the interface name and your IP acquisition method (e.g., DHCP), reboot, and the network should come up automatically.

Using Recovery Mode

If the system is inaccessible in a timely manner, we need to use recovery mode to intervene. Reboot the machine and repeatedly press the Esc key to bring up the GNU GRUB interface. If you land in the grub> shell, just type exit and hit Enter to get to the main GNU boot menu.

grub shell grub boot menu

From the menu, select Advanced options for UbuntuUbuntu .... (recovery mode).

You’ll eventually be prompted to press Enter to access a maintenance shell. At this point, you have root access to the system’s filesystem, allowing you to proceed with network configuration.

Configuring the Network

Follow the network configuration instructions outlined in the "Ubuntu Server 24.04: Installation, Partitioning, and Network Configuration" guide.

Now, here’s a catch. While in recovery mode, after creating my network config, I tried to run sudo netplan apply and was hit with this error:

1
'50-cloud-init.yaml' are too open. Netplan configuration should NOT be accessible by others.

This is a security feature. You can fix the file permissions with the following command:

1
2
3
4
5
6
7
8
# Set permissions for 50-cloud-init.yaml to 600 (read/write for root only)
sudo chmod 600 /etc/netplan/50-cloud-init.yaml

# Apply the Netplan configuration again
sudo netplan apply

# If the previous steps were successful, you can reboot immediately to verify a smooth boot process:
sudo reboot

After rebooting, if the network configuration is correct, the system will no longer hang during the boot sequence.

Disabling the Network Wait Service (Optional)

My initial workaround was to disable the network-wait service first, which allowed me to boot into the system and then configure the network. However, if you correctly configure the network from recovery mode, the systemd-networkd-wait-online.service should pass instantly without causing any delay.

Therefore, disabling the service isn’t strictly necessary. But if you wish to do so for any reason, here are the commands:

1
2
3
4
sudo systemctl disable systemd-networkd-wait-online.service
sudo systemctl mask systemd-networkd-wait-online.service
sudo systemctl daemon-reload
sudo reboot

A final reboot will ensure the system no longer waits for the network, giving you direct access to the bash prompt.

Conclusion

Given its role as a server operating system, Ubuntu Server prioritizes a stable network connection for remote administration and service delivery. This makes correct network setup during the installation phase critically important.

The issue I encountered—“system won’t boot, Ethernet port light off”—is rooted in the systemd-networkd-wait-online.service that’s enabled by default in Ubuntu 24.04. This service is designed to wait for network readiness, but if the configuration is bad or there’s no physical link, it stalls the entire boot process until it times out.

Technically, even with the hang, the system should eventually drop you at a login prompt after the timeout. My chosen fix, however, was to intervene by entering Recovery Mode via the GRUB boot menu.

By obtaining a root shell in recovery mode, we can bypass the boot-time services and directly edit the Netplan configuration file (/etc/netplan/50-cloud-init.yaml). After correcting the settings, fixing the file permissions, and applying the configuration, a reboot confirmed the problem was solved: the system detected the network and proceeded smoothly to the login prompt.

However, the best strategy is to prevent the problem from happening in the first place. Always have your Ethernet cable plugged in during the OS installation and configure your network settings correctly at that stage. This will save you from a lot of unnecessary post-install troubleshooting.

Theme Stack designed by Jimmy