DebWrt Boot Sequence

DebWrt support two ways of boot procedure:

  1. Using DebWrt bootscript (default since 2.0)
    1. Auto detect root device ( LABEL=DEBWRT_ROOT )
    2. Kexec to boot alternate kernels
  2. Directly boot from /dev/sda1
  3. Failsafe

The boot procedure is selected in make menuconfig in the "DebWrt boot options/Boot method" menu.

See boot.log attachment of this wiki for an example.

DebWrt bootscript

Instead of mounting the root device directly, this method initially mounts /dev/mtdblock2 as root device. This is where OpenWrt by default stores its root file system. DebWrt uses this OpenWrt rootfs to provide advanced boot options for DebWrt. A init script /etc/preinit is started which auto detects the root device, optionally boots into an alternate kernel from disk and continues to boot from the discovered root device:

Auto detect root device

DebWrt searches and waits 30 seconds for a block device with LABEL=DEBWRT_ROOT to appear. It falls back to /dev/sda1 if it can't find any. The hotplug2 system of OpenWrt is used to detect connected devices.

tip: Set the label DEBWRT_ROOT when creating the root filesystem to prevent waiting 30 seconds before DebWrt falls back to /dev/sda1.

Optionally boot alternate kernel from disc (kexec)

The discovered root device is mounted and /boot is searched for an alternate kernel (/boot/vmlinux.elf). When found, kexec is used to boot into this kernel. The kernel is booted with an additional parameter kexec=1 to prevent a loop of kexecing kernels. The DebWrt boot process(/etc/preinit) is re-executed after the alternate kernel has been executed.

In future this kexec feature will allow DebWrt to ship kernels in normal Debian packages. No more need for re-flashing the device. Kexecing the alternate kernel is very fast. The entire POST of the device is skipped. The overhead of kexec is therefore minimal.

Continue to boot

Once the root file system is mounted ( and optionally the alternate kernel is loaded ) the the discovered root filesystem is set(pivot_root) as root filesystem and Debian is normally booted (/sbin/init).

Note: The initial OpenWrt root filesystem(/dev/mtdblock2( is unmounted before Debian is booted.

Directly boot from /dev/sda1

This method provides the quickest way of booting DebWrt, in case above functionality is not required. The kernel directly mounts /dev/sda1 and runs /sbin/init to boot Debian. The rootdevice (/dev/sda1 by default) can be selected in menuconfig in "DebWrt boot options/Config Command line" if in "DebWrt boot options/Boot method" menu the option "Directly boot from device" has been selected.


When no root device has been discovered and /dev/sda1 does not exist, a shell(/bin/sh) is started.

Last modified 5 years ago Last modified on Feb 15, 2012, 11:39:06 PM

Attachments (1)

Download all attachments as: .zip