- Notifications
You must be signed in to change notification settings - Fork0
Mirror ofhttps://git.sr.ht/~pmh/mlb2
License
philhofer/mlb2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Minimal Linux Bootloader, adapted/adopted from Sebastian Plotzby Wiktor Kerr, and then later adapted for use in virtualizedbooting environments by Phil Hofer for use in thedistill project.
This is a single stage x86 bootloader that can boot a single Linux kernel.There is no support for initrd and only one kernel can be configured to boot atany time.
MLB was originally written by Sebastian Plotz. Wiktor Kerr changed the code veryslightly and wrote the original Makefile andmlbinstall
. Phil Hofer optimizedthe assembly a bit more and wrote a new Makefile andmlb2install
.
http://sebastian-plotz.blogspot.de/
- a C compiler
- ld(1)
- make(1)
- nasm(1)
Runmake
, optionally with CC, LD, CFLAGS, LDFLAGS, etc. set via thecommand line, i.e.make CC=gcc 'CFLAGS=-02'
Themlb2install
binary has the MBR boot code embedded in it, soit can simply be copied to its final destination, or you canrunmake install
. (The Makefile will respect the conventionalPREFIX
andDESTDIR
arguments for the install prefix and stagingprefix, respectively.)
To install MLB, simply invoke
mlb2install <target> <kernel-lba> <command line>
where:
<target>
is where you want your bootloader installed (e.g. a file, a blockdevice, whatever)<kernel-lba>
is the LBA (in 512-byte sectors) of the kernel within thetarget device<command line>
is the command line to pass to the kernel - don't forget topassroot=
asmlbinstall
will not calculate the root device. Currentlythe command line cannot be longer than 99 bytes (more just won't fit in theMBR).
Typically, the kernel will live in reserved (unformatted) space at thebeginning of the drive before the first real MBR partition, or it willbegin at the first partition. (You can simplydd
your kernel to theright place once you've arranged the partitions so that it won't be clobberedby other disk manipulation.)
mlb2install
is quite noisy if it detects any problems. Restore your MBR frombackup, fix the problems, and try again. If it succeeds, it won't say anything.
If MLB fails to boot your kernel, it will print a one-letter error code.Currently, there are two error codes:
Error What it means----- ---------------------------------------- R Failed reading data from disk M Failed moving data to its final location