Crate boot2dump[][src]

Expand description

A library for OS developers to save a kernel crash log happened in your own kernel into a file on disk reboot the computer.


You kernel needs to satisfy the following prerequisites to use this crate:

  • The CPU is x86_64 and is in the 64-bit mode.
  • The file system is ext4 and its on a virtio-blk device.
  • A sufficiently large file for the crash log (e.g. in the following example, kerla.dump) already exists in the root directory.
  • Virtual addresses starting 0xffff_8000_0000_0000 are straight mapped into from the physical addresses 0 (i.e. 0xffff_8000_0001_0000 points to 0x1_0000). It should cover the memory pages where boot2dump image exist.

How to Use

The usage is pretty simple: at the end of your panic handler, call save_to_file_and_reboot. It will save the given buffer into a file and then reboot the computer.


use boot2dump::save_to_file_and_reboot;

fn panic(info: &core::panic::PanicInfo) -> ! {
    // Save the panic message into a file. Let's hope `format!` won't panic...
    let message = format!("{}", info).as_bytes();
    save_to_file_and_reboot("kerla.dump",  message.as_bytes());


Saves data into filename on the disk and then reboots the computer.