Linux and servers · Advanced · 24 min
Recover an Ubuntu server that will not boot
By Padding · Updated 18 Nov 2026
Ubuntu 26.04.1 LTS · systemd 259 · GRUB 2
You will work out where an Ubuntu 26.04 server stopped booting from its console, get it running again with an older kernel, emergency mode or a rescue system with chroot, and read the failed boot's log afterwards.
On this page
A server that will not boot also will not answer SSH, so every habit you rely on is gone at once. What you have left is the console, the GRUB menu and a few kernel options. This tutorial turns those into a routine: read the last thing the console printed, work out which stage of the boot gave up, and pick the smallest repair that gets you back in.
Most failures fall into a short list. A new kernel or initramfs that cannot find the root disk. An /etc/fstab line for a volume that has gone. A root filesystem so full that services fail on the way up. A boot loader that has lost its files. Each has a different first move, and the console usually tells you which one you are looking at.
Do the steps in order until one works. Steps 3 to 6 are done on the broken server itself. Step 7 is for after it boots. Step 8 is the last resort, when the server cannot get far enough to give you any shell.
If you reach the console over a slow or prepaid mobile connection, prefer the provider's serial console where there is one. It is plain text, so it stays usable on a weak signal and uses a fraction of the data of a graphical web console.
Step 1 · Open the console and read the last screen
Open the console before you reboot anything. On a cloud server this is the provider's serial console or web console in the control panel; on a machine in an office it is a screen and keyboard. Some providers ask you to enable the serial console on the account first, so check that now if you can.
Read the last lines on screen and write them down, word for word, or take a photo. Then reboot from the control panel and watch the whole boot scroll past. The useful line is often a few lines above the final one, for example a filesystem error just before the emergency shell prompt.
Note three things:
- The last stage that printed anything (firmware, GRUB, kernel messages, or systemd's
[ OK ]and[FAILED]lines). - Any line with
FAILED,error,panicorTimed out. - Whether you get any prompt at all, and what it looks like.
Check it worked
You have the exact text of the last error line, and you know whether the console ended at a blank screen, a grub> prompt, a kernel panic, a shell prompt or a hanging A start job is running line.
Step 2 · Match the screen to the boot stage
Booting is a chain of hand-offs. Firmware finds a disk and starts GRUB. GRUB loads a kernel and its initramfs, a small temporary root filesystem. The kernel starts drivers and runs the initramfs, whose job is to find and mount the real root disk. Then it hands over to systemd, which mounts everything in /etc/fstab, starts services and shows the login prompt.
Match what you wrote down to a stage:
- Nothing after the firmware,
No bootable device, or agrub rescue>prompt: the boot loader or its files are damaged. Go to step 8. - A
grub>prompt orerror: file not foundafter choosing an entry: GRUB runs but cannot find the kernel. Try step 3, then step 8. Kernel panic - not syncing(often withUnable to mount root fs), or a wait for the root device that ends in adracutemergency shell: the kernel or initramfs cannot reach the root disk. Ubuntu 26.04 builds its initramfs with dracut. Go to step 3.- A line like
A start job is running for /dev/disk/by-uuid/...counting to 1 min 30 s, thenYou are in emergency mode: systemd could not mount something in/etc/fstab. Go to steps 4 and 5. - Many
[FAILED]services,No space left on device, then emergency mode or a login prompt that never comes: a full root filesystem. Go to steps 4 and 6.
If the login prompt appears but SSH still fails, the server did boot. That is a network, firewall or SSH problem, not a boot problem.
Check it worked
You can name one stage from the diagram as the last one that ran, and you have picked the step you will try first.
Step 3 · Boot the previous kernel from the GRUB menu
Ubuntu keeps the previous kernel installed after an update. If the failure started after a kernel or initramfs update, the older one usually still boots.
Ubuntu hides the GRUB menu unless you ask for it. Reboot from the console and, as soon as the firmware finishes, press Esc (UEFI machines, which covers most cloud servers) or hold Shift (older BIOS machines). If one Esc drops you at a grub> prompt instead of the menu, type normal and press Enter to get the menu back.
In the menu, choose Advanced options for Ubuntu. It lists every installed kernel, newest first, each with a matching (recovery mode) entry. Choose the second normal entry, the one with the older version number.
Some cloud images set the GRUB wait to zero, which leaves no time to press a key. If the menu never appears, go to step 8 and, once the server is back, give yourself a visible menu for next time. Ubuntu reads extra GRUB settings from files in /etc/default/grub.d/, in name order, so a file starting with 99 wins:
printf 'GRUB_TIMEOUT_STYLE=menu\nGRUB_TIMEOUT=5\n' | sudo tee /etc/default/grub.d/99-show-menu.cfg
sudo update-grubOnce you are in on the older kernel, confirm which one is running and list what is installed:
uname -r
ls /boot/vmlinuz-*Rebuild the initramfs for the newest kernel, which fixes most failures that started after an update. Replace 7.0.0-NN-generic with the newest version from the list:
sudo dracut --force --kver 7.0.0-NN-generic
sudo update-grubIf dracut is not installed, the server still uses initramfs-tools (some servers upgraded from older releases do), and the equivalent is sudo update-initramfs -u -k 7.0.0-NN-generic. If the new kernel still fails after that, keep booting the older one and reinstall the new kernel's packages with sudo apt install --reinstall linux-image-7.0.0-NN-generic linux-modules-7.0.0-NN-generic.
Check it worked
uname -r prints the older version you picked, and you can log in over SSH. After the rebuild and a normal reboot without touching the menu, uname -r prints the newest version.
Step 4 · Start emergency or rescue mode from the kernel command line
When systemd gives up, it drops to emergency mode by itself. You can also ask for it, or for rescue mode, from GRUB. Rescue mode mounts all filesystems and starts only basic services. Emergency mode mounts nothing beyond what is already there, often with root read-only, so it still works when an fstab line or a broken service blocks rescue mode.
Ubuntu locks the root account by default, so emergency and rescue mode usually stop at Cannot open access to console, the root account is locked and give you no shell. The kernel option systemd.setenv=SYSTEMD_SULOGIN_FORCE=1 tells systemd to open the shell without a root password in that case. Anyone at the console gets a root shell this way, so use it only for this boot; edits made in the GRUB menu are not saved.
Show the GRUB menu as in step 3, highlight the normal Ubuntu entry and press e. Find the line that starts with linux and move to its end (it may wrap over several screen lines). Add a space and then:
systemd.unit=emergency.target systemd.setenv=SYSTEMD_SULOGIN_FORCE=1For rescue mode, use systemd.unit=rescue.target instead. Press Ctrl-x or F10 to boot the edited entry.
If systemd never starts because the initramfs cannot find the root disk, ask for the emergency shell inside the initramfs instead. That shell also goes through sulogin, so the locked root account can block it in the same way. dracut's emergency script looks for a plain SYSTEMD_SULOGIN_FORCE=1 on the kernel command line, so add that as well as the systemd.setenv form:
rd.systemd.unit=emergency.target SYSTEMD_SULOGIN_FORCE=1 systemd.setenv=SYSTEMD_SULOGIN_FORCE=1From there ls /dev/disk/by-uuid/ shows which disks the kernel can see, which tells you whether the root disk is missing or just named differently.
Check it worked
The console shows a # prompt after a line that starts You are in emergency mode (or rescue mode). systemctl --failed lists the units that failed during this boot, and findmnt / shows the root filesystem with ro or rw in its options.
Step 5 · Fix a bad fstab line from emergency mode
The most common cause of emergency mode is an /etc/fstab line for a volume that is detached, renamed or reformatted. systemd waits 90 seconds for the device, fails local-fs.target, and that target is set to fall back to emergency mode.
Read the explanation, then ask findmnt to check every line:
journalctl -xb -p err
findmnt --verifyfindmnt --verify names each line it cannot resolve, such as a UUID that matches no disk. Compare it with what is attached:
lsblk -fEmergency mode may leave root read-only. Remount it read-write so you can edit the file, and keep a copy first:
mount -o remount,rw /
cp /etc/fstab /etc/fstab.before-fix
nano /etc/fstabOn the failing line, either correct the UUID to the one lsblk -f shows, or put # at the start to switch it off for now. For a data volume the server can run without, add nofail to the options so a missing volume never stops boot again. Do not comment out the line for / or /boot/efi. If one of those is wrong, correct its UUID instead.
Check the file again, tell systemd it changed, and carry on with the normal boot:
findmnt --verify
systemctl daemon-reload
systemctl defaultThe full fstab rules, including x-systemd.device-timeout for a shorter wait, are in /tutorials/mount-a-disk-at-boot-with-fstab-and-uuids.
Check it worked
findmnt --verify reports no errors (warnings are fine), the boot continues to the login prompt, and systemctl --failed after logging in no longer lists a .mount unit.
Step 6 · Free space on a full root filesystem
When / is full, services that write a PID file, socket or log fail one after another, and the boot can end in emergency mode or at a prompt that never answers. Boot into emergency mode as in step 4, then confirm the problem:
mount -o remount,rw /
df -h /Use% at or near 100% confirms it. Find what grew, staying on the root filesystem with -x:
du -xh --max-depth=2 / 2>/dev/null | sort -h | tail -n 20The usual culprits on a server are an old journal, the apt cache and an application's own logs. Free space you can safely get back first:
journalctl --vacuum-size=200M
apt-get cleanFor application logs under /var/log, empty the file rather than deleting it while a service may still hold it open, for example truncate -s 0 /var/log/myapp/big.log (replace this with the file du found). Do not delete anything under /usr, /boot or /var/lib/dpkg to make room. Once there is space, systemctl default continues the boot.
Check it worked
df -h / shows Use% well below 100%, and the boot reaches the login prompt. After you log in, systemctl --failed shows no services that failed for lack of space.
Step 7 · Read the failed boot with journalctl -b -1
Once the server is up, find out why it failed so the fix lasts. If the journal is persistent (it is when /var/log/journal exists), it keeps the log of every boot, including the broken one:
journalctl --list-bootsEach line is one boot, numbered 0 for the current one, -1 for the one before, and so on. Read the errors from the failed attempt. If you rebooted more than once, use the number of the boot that failed:
journalctl -b -1 -p err
journalctl -b -1 -e-p err shows only errors and worse; -e jumps to the end of that boot, where the last messages before the emergency shell or power-off are. If --list-boots shows only boot 0, the journal lives in memory and was lost at reboot. Make it persistent with /tutorials/keep-the-systemd-journal-small-and-persistent so the next failure leaves a record.
Check it worked
journalctl -b -1 -p err shows the same error you wrote down from the console in step 1, such as a mount timing out or a disk full message. You can name the cause, not only the repair.
Step 8 · Repair from a rescue system with chroot
When there is no menu, no shell and no older kernel that works, repair the disk from another running Linux system. There are two ways in:
- Boot the server into the provider's rescue image from the control panel. The server's own disk then appears as a second disk.
- Stop the server, detach its root volume, and attach it to another Ubuntu server in the same region.
Snapshot the volume in the control panel first if your provider allows it, so a mistake here can be undone.
On the rescue system, find the broken disk. It is the one that is not mounted:
lsblk -fTwo catches before mounting. If the rescue server was built from the same image, both root filesystems can share a UUID and label, so always mount by device path and never by UUID here; for XFS add -o nouuid. If both disks use LVM with the default volume group name, use the provider's rescue image, which normally has no LVM of its own, rather than another server built from the same installer.
Mount the broken root filesystem. Replace /dev/sdb1 with the partition lsblk -f showed:
sudo mkdir -p /mnt/broken
sudo mount /dev/sdb1 /mnt/broken
ls /mnt/broken/etc/fstabA default Ubuntu Server install puts root on LVM. Then lsblk -f shows the large partition as LVM2_member rather than ext4, and mounting that partition fails. Activate the volume group and mount the logical volume instead, installing lvm2 first if the rescue system has no vgchange:
command -v vgchange || sudo apt install lvm2
sudo vgchange -ay
sudo mount /dev/mapper/ubuntu--vg-ubuntu--lv /mnt/brokenVolume groups and logical volumes are explained in /tutorials/add-disks-and-grow-filesystems-with-lvm.
Bind the system folders into it so tools inside see the disks and the kernel. --make-rslave stops the later unmount from reaching back into the rescue system's own mounts:
for d in dev proc sys run; do
sudo mount --rbind "/$d" "/mnt/broken/$d"
sudo mount --make-rslave "/mnt/broken/$d"
done
sudo chroot /mnt/broken /bin/bashYou now have a root shell in which / is the broken disk.
The repairs below may use apt, which needs DNS. On the broken disk, /etc/resolv.conf is a link to systemd-resolved's stub at 127.0.0.53, which answers only if the rescue system also runs systemd-resolved, and many rescue images do not. If apt cannot resolve hosts, exit the chroot, run sudo cp --remove-destination /etc/resolv.conf /mnt/broken/etc/resolv.conf on the rescue system, and chroot again. Before you leave the chroot for the last time, put the link back with ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf.
Mount its other filesystems from its own fstab, then make the repair the earlier steps pointed to:
mount /boot
mount /boot/efiThe first line errors if /boot is not a separate partition, and the second if the server boots with BIOS; both are fine to ignore. Then, as needed:
- A bad fstab line: edit
/etc/fstabas in step 5 and check it withfindmnt --verify. - A broken initramfs:
dracut --force --regenerate-all, orupdate-initramfs -u -k allon initramfs-tools. - An unbootable kernel:
linux-image-genericis only a metapackage, so reinstalling it rewrites nothing. List the kernels withls /boot/vmlinuz-*and reinstall the versioned packages, as in step 3:apt install --reinstall linux-image-7.0.0-NN-generic linux-modules-7.0.0-NN-generic. - Missing GRUB files: check which boot packages are installed with
dpkg -l 'grub*' 'shim*'and reinstall those. On a UEFI amd64 server, including cloud images with Secure Boot, that is usuallyapt install --reinstall shim-signed grub-efi-amd64-signed; arm64 servers usegrub-efi-arm64-signed, and BIOS serversgrub-pc. Then runupdate-grub, plusgrub-installwith the disk (for examplegrub-install /dev/sdb) on a BIOS server. - A full disk: free space as in step 6.
Leave the chroot and unmount everything before you boot the disk again:
exit
sudo umount -R /mnt/brokenThen end the rescue boot in the control panel, or detach the volume and attach it back to the original server as its boot volume, and start the server.
Check it worked
Inside the chroot, cat /etc/hostname prints the broken server's hostname, not the rescue system's. After umount -R, findmnt /mnt/broken prints nothing, and the original server boots to its login prompt on the console.
Next steps
- Make fstab entries that cannot stop a boot, with
nofailand short timeouts: /tutorials/mount-a-disk-at-boot-with-fstab-and-uuids - Keep logs from every boot so the next failure leaves a record: /tutorials/keep-the-systemd-journal-small-and-persistent
- Get faster at reading boot logs by unit, priority and time: /tutorials/search-the-systemd-journal-with-journalctl
- Understand the volume group behind Ubuntu's default root disk before you need to repair it: /tutorials/add-disks-and-grow-filesystems-with-lvm
Related tutorials
- Write safer Bash scripts with strict mode and trapsYou will build a small Bash release script that stops on the first error, says which line failed, survives file names with spaces and always removes its temporary files.
- Write least-privilege sudo rules with visudoYou will replace blanket sudo access with checked rule files in /etc/sudoers.d that let two operators restart one service and edit one file, give an automation account a password-free command list, and audit what every account can run.
- Upgrade a server from Ubuntu 24.04 LTS to 26.04 LTSYou will take a backed-up Ubuntu 24.04 server through do-release-upgrade to 26.04 LTS over SSH with a fallback login, then confirm services, repositories and language runtimes work on the new release.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials