Skip to main content

Recovering From a Kernel Panic in Linux

Carl HamiltonBy Carl HamiltonFounder, Hamilton Group
1 Aug 2026
Media Recovering From a Kernel Panic in Linux

Worked for 20s

There are meaningful improvements, so I’d rewrite this one automatically. The live article is technically strong but around 860 lines, and it mixes together three very different situations: a panic during boot, a panic after the machine has been running, and a recurring production-server panic that needs proper crash capture.

The stronger version should make the recovery path much clearer:

record the panic → determine when it occurs → boot a known-good kernel if necessary → inspect the previous boot → isolate drivers/storage/RAM → rebuild boot components only when the error points there → configure kdump for recurring or business-critical failures.

 

A Linux kernel panic is one of the more serious failures a Linux system can experience.

Instead of an application crashing or one service stopping, the kernel itself reaches a state from which it cannot safely continue.

You may see:

Kernel panic - not syncing: Fatal exception

or messages such as:

Unable to mount root fs

VFS: Cannot open root device

The machine may:

freeze completely

reboot automatically

display a stack trace

stop responding over SSH

panic repeatedly during startup


A kernel panic looks dramatic, but it does not automatically mean the computer is permanently damaged.

Common causes include:

a bad kernel update

faulty kernel module or driver

damaged initramfs

storage failure

filesystem problems

faulty RAM

unstable hardware

bad boot configuration

third-party kernel modules


The most useful first question is:

When does the panic happen?

Because:

panic during boot and panic after hours of normal operation are very different problems.

First: Record the Error

Before restarting the machine, capture as much information as possible.

If there is text on the screen, photograph it.

Look for:

the first Kernel panic message

named kernel modules

kernel version

root filesystem/device

I/O error

BUG

Oops

Call Trace

Machine Check

NVMe

filesystem errors


Your existing article correctly emphasises that the first clear error is often more useful than several screens of stack-trace information.

Do not rely on remembering:

“There was loads of Linux text.”

The exact wording can dramatically shorten the investigation.

Was the Panic During Boot?

If the machine panics every time Linux starts, think first about:

current kernel

initramfs

storage/root filesystem

boot configuration

modules needed early in startup


If the panic began immediately after installing a new kernel, the quickest recovery is often to boot the previous one.

Boot the Previous Kernel

Most mainstream Linux distributions deliberately retain older kernels for this reason.

At startup, display the GRUB menu.

Depending on the machine, this may involve pressing or holding:

Shift

or:

Esc

Choose:

Advanced options for Linux

Then select an older kernel.

For example:

Linux 6.x.x-current
Linux 6.x.x-previous

If the previous kernel boots successfully, you have learned something important:

the underlying Linux installation is probably still broadly functional.

Now investigate:

new kernel

new kernel module

DKMS module

graphics driver

storage driver


rather than immediately reinstalling the operating system.

Keep the Working Kernel

Once Linux starts:

uname -r

Check which kernel is currently running.

On Debian/Ubuntu:

dpkg --list | grep linux-image

On Fedora/RHEL-family systems:

rpm -q kernel

Do not immediately remove the last known-good kernel.

It is your recovery route.

Aggressive automatic kernel cleanup can turn:

“the latest kernel is broken”

into:

“the machine has nothing usable to boot.”

Did a Third-Party Driver Change?

Kernel modules deserve particular attention.

Examples include:

NVIDIA graphics drivers

storage drivers

virtualisation modules

security products

filesystem modules

hardware-management software


Check loaded modules:

lsmod

Look for warnings or failures in the previous boot:

sudo journalctl -k -b -1

If the panic repeatedly identifies the same third-party module, investigate that module before blaming Linux generally.

This is especially relevant with DKMS modules, which are rebuilt against installed kernels. A kernel upgrade followed immediately by a panic can indicate that an out-of-tree module did not build or behave correctly with the new kernel.

Check the Previous Boot Logs

If the machine successfully restarts after the panic, use the journal before doing anything drastic.

To inspect the complete previous boot:

sudo journalctl -b -1

For kernel messages only:

sudo journalctl -k -b -1

journalctl -k -b -1 is specifically documented by systemd as showing kernel logs from the previous boot.

Search for likely indicators:

sudo journalctl -k -b -1 | grep -iE \
"panic|oops|fatal|error|fail|nvme|i/o|machine check"

Look for events immediately before the panic.

The last line is not always the cause.

It may simply be the last thing that had time to log.

Kernel Panic vs Kernel Oops

These are related but different.

A kernel panic stops the kernel because continuing is unsafe.

A kernel oops indicates a serious kernel error but may allow the machine to continue temporarily.

That does not mean an oops should be ignored.

Repeated kernel oopses can leave the system unstable and can ultimately lead to a panic.

Search:

sudo journalctl -k | grep -i oops

Linux can also be deliberately configured to panic when an oops occurs using panic_on_oops. Kernel documentation confirms that when enabled, an oops causes an immediate panic.

So if a machine panics after an apparently recoverable driver error, check whether this policy is configured.

“Unable to Mount Root FS”

This message points the investigation in a much more specific direction.

Possible causes include:

broken initramfs

missing storage module

incorrect root UUID

damaged filesystem

storage hardware failure

boot configuration referring to the wrong device


Before rebuilding everything, confirm the storage device is actually visible.

Useful commands from a rescue environment include:

lsblk -f

and:

blkid

Compare the UUIDs against:

cat /etc/fstab

and the boot configuration.

A renamed /dev/sdX device is one reason Linux installations commonly use filesystem UUIDs rather than depending on physical device numbering.

Rebuild the initramfs When the Evidence Points There

The initramfs contains the early userspace and drivers Linux needs before it can mount the real root filesystem.

If it is damaged—or missing a storage driver—the kernel can fail before normal userspace ever starts.

On Debian/Ubuntu, you can rebuild existing initramfs images using:

sudo update-initramfs -u -k all

If repairing from a rescue or chroot environment, make sure:

the real root filesystem is mounted

/boot is mounted where appropriate

EFI System Partition is mounted where required


Do not blindly rebuild initramfs because:

“kernel panic article said so.”

Use it when the panic indicates early-boot/root-filesystem trouble.

Filesystem Corruption: Be Careful With fsck

If the panic indicates filesystem corruption, filesystem checking may be required.

But do not run destructive repair against a filesystem that is mounted read/write and actively in use.

Boot from:

recovery environment

rescue media

another Linux installation


and inspect the affected filesystem offline where appropriate.

The exact repair command depends on the filesystem.

For example, ext-family filesystems use fsck/e2fsck, whereas XFS uses different repair tooling.

Do not assume:

fsck -y

is the universal Linux disk-repair command.

If important business data is involved and storage failure is suspected, prioritise the data before aggressive repair.

Panic After Linux Has Been Running Normally?

If the machine boots successfully and panics:

under heavy load

after several hours

during backups

during GPU use

during high storage activity


the investigation changes.

Now I would look closely at:

RAM

CPU stability

temperature

storage

kernel modules

hardware events


rather than GRUB and initramfs.

Check Memory

Faulty RAM can create unpredictable kernel failures.

Useful symptoms include:

panics with different stack traces each time

random processes crashing

filesystem corruption appearing without explanation

decompression/checksum failures


Run an appropriate memory diagnostic such as Memtest86+ where available through your distribution or boot environment.

One clean pass is useful.

For intermittent faults, longer testing is better.

On business-critical servers with ECC RAM, also inspect hardware/BMC logs for corrected and uncorrected memory errors.

Check Storage Health

Storage faults can present as kernel problems.

Look in the journal:

sudo journalctl -k | grep -iE \
"nvme|ata|i/o error|timeout|reset|medium error"

For supported drives, inspect SMART/NVMe health using appropriate tooling such as smartctl or nvme-cli.

Repeated:

NVMe resets

I/O timeouts

unreadable sectors


should not be treated as a software-only problem.

If the drive contains important data, preserve that data before stressing a device that may be failing.

Check Hardware Stability

Kernel panics can also result from:

unstable overclock

undervolting

overheating

failing power supply

motherboard faults


Return systems to manufacturer/default operating parameters when diagnosing unexplained panics.

Do not spend days debugging the Linux kernel on a PC running:

aggressive RAM timings + CPU overclock + undervolt

without first removing those variables.

If It Only Happens With One Device Attached

Disconnect non-essential hardware.

Examples:

USB storage

unusual network adapters

capture hardware

external GPUs

specialist PCIe cards


If the panic disappears, reconnect devices individually.

That gives you much stronger evidence about the relevant hardware or driver.

Automatic Reboot Can Hide the Evidence

Linux can be configured to reboot after a panic.

The kernel's panic setting determines the behaviour:

0 → wait indefinitely

positive number → reboot after that many seconds

negative → reboot immediately.


Check:

sysctl kernel.panic

On unattended servers, automatic recovery may be desirable.

During diagnosis, however, a very short reboot delay can make it difficult to capture the panic screen.

Do not alter production recovery policies casually just to make troubleshooting easier.

For Important Servers, Configure Kdump

This is the biggest improvement I would make to the advanced section of the original article.

If the panic is:

intermittent

difficult to reproduce

happening on an important server


ordinary journald logs may not contain enough information.

Use kdump.

Linux kernel documentation describes kdump as a crash-dump mechanism that uses kexec to boot a dedicated dump-capture kernel after a panic while preserving the crashed kernel's memory. That memory can then be written to a vmcore for analysis.

Red Hat goes further and recommends operational kdump for mission-critical systems because a crash dump can sometimes be the only useful evidence available after a kernel failure.

Conceptually:

normal kernel panics

↓

kdump launches crash kernel

↓

crashed kernel memory preserved

↓

vmcore saved

↓

engineer analyses actual crash state

That is much more valuable than:

“It rebooted at 03:12 but we don't know why.”

Do Not Test Kdump on Production Casually

Kernel documentation includes mechanisms that deliberately trigger a panic for testing purposes.

Do not run panic-trigger commands casually on a production server.

Testing crash capture intentionally crashes the machine.

If kdump needs validation, schedule it as controlled maintenance with:

backups confirmed

business impact understood

console/recovery access available


Don't “Fix” a Panic by Suppressing It

Avoid the mentality:

“Can I configure Linux not to panic?”

A kernel panic is often the kernel protecting data or system integrity because it cannot continue safely.

Changing panic behaviour may alter what happens after the fault.

It does not remove:

bad memory

broken driver

failing SSD

corrupt initramfs


Fix the underlying cause.

The Fastest Recovery Path

For a Linux kernel panic, I would use this order:

1. Photograph or record the panic.


2. Determine whether it happens during boot or after normal operation.


3. If it started after a kernel update, boot the previous kernel.


4. Keep the known-good kernel installed.


5. Review:

 

sudo journalctl -k -b -1

6. Identify repeatedly named modules or hardware errors.


7. For root-filesystem panics, inspect storage, UUIDs and initramfs.


8. Check RAM and storage health where hardware is plausible.


9. Remove recent third-party kernel modules or hardware from the test.


10. Rebuild initramfs/boot configuration only when the evidence points there.


11. For recurring production failures, configure and verify kdump.


12. Fix the root cause before returning the machine to normal service.

 

The key principle is:

Recovering the boot is only half the job. A kernel panic needs an explanation, particularly if the machine contains important business data.

A Useful Example

A server updates from:

Kernel 6.x.A

to:

Kernel 6.x.B

It immediately begins panicking during startup.

From GRUB you select:

Kernel 6.x.A

and the server boots normally.

Logs identify a third-party kernel module that was rebuilt during the update.

That strongly points towards:

new kernel/module compatibility

rather than:

failed server hardware.

You can keep the system operational on the known-good kernel while correcting the module/update problem.

Another Example

A server runs normally for several hours and then panics unpredictably.

Each crash produces a different stack trace.

The journal also shows occasional machine-check/memory errors.

That makes:

RAM or hardware instability

far more interesting than rebuilding GRUB repeatedly.

Different symptom.

Different investigation.

How Hamilton Group Can Help

Hamilton Group can help businesses investigate Linux failures involving:

kernel panics

kernel updates

GRUB

initramfs

Linux drivers and kernel modules

storage failures

Linux server hardware

crash logs

kdump

backup and disaster recovery


For important servers, the objective is not simply:

“Make it boot again.”

It is to establish why the kernel failed, preserve useful crash evidence and reduce the chance of the same failure taking the system down again.

Visit.. *&? #or call 01423 438 953 to discuss Linux server and business IT support.

Carl Hamilton
About the author
Carl Hamilton
Founder, Hamilton Group
Carl Hamilton is the founder of Hamilton Group, a UK managed IT services provider helping small and medium businesses stay secure, productive and well supported with proactive IT, cyber security and Microsoft 365 expertise.

0 comments

  1. Be the first to comment.

Join the conversation

Comments are checked before they appear.

Your email stays private; we never publish it. By commenting you agree to our acceptable-use terms.