KRaBs is an x86/x86_64 chain loader written in pure Rust.
KRaBs is working on booting vmlinux and other kernels formatted in ELF on 32-bit/64-bit PCs and is under the development. Krabs also aims to support only the minimal Linux x86/x86_64 boot protocol. This allows you to use the kernel command line and initrd/initramfs.
Other features:
- Supports GPT and FAT32 File System on EFI System Partition(ESP).
- You can configure KRaBs's boot option in CONFIG.TXT on FAT32 ESP.
- CONFIG.TXT is a simple matrix-oriented text file. See CONFIG.TXT formats.
- 2020/08: Currently, KRaBs can boot kernel-5.8.3! initrd and kernel command line also work fine!!. see details
cargo run -- -we disk.img
To get started with KRaBs, build it from source.
rust-src
andllvm-tools-preview
- GPTed disk image that has BIOS Boot Partition and EFI System Partition.
- CONFIG.TXT, kernel image and initrd on FAT32 FileSystem on EFI System Partition.
- (option) qemu-system-x86
$ cd /path/to/krabs
$ rustup component add rust-src
$ rustup component add llvm-tools-preview
$ gdisk -l disk.img
...
Found valid GPT with protective MBR; using GPT.
Disk disk2.img: 204800 sectors, 100.0 MiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 2A1F86BB-74EA-47C5-923A-7A3BAF83B5DF
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 204766
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 BIOS boot partition
2 4096 106495 50.0 MiB EF00 EFI system partition
3 106496 204766 48.0 MiB 8300 Linux filesystem
$ sudo kpartx -av disk.img
$ sudo mkfs.fat -F 32 /dev/mapper/loop0p2
$ sudo mkfs.ext4 /dev/mapper/loop0p3
$ sudo mount /dev/mapper/loop0p2 /mnt
$ ls /mnt
CONFIG.TXT initramfs.cpio.gz vmlinux-5.8.3
simple matrix-oriented text file
main.kernel vmlinux-5.8.3
main.initrd initramfs.cpio.gz
main.cmdlin clocksource=tsc net.ifnames=0
cargo build
cargo run -- -w disk.img
cargo run -- -e disk.img
Examples for x86-64 Linux is described in the docs of 'Creating Custom Linux Images and Booting'.
KRaBs welcomes all contributions. To contribute to KRaBs, check out the getting started guide and then the KRaBs contribution guidelines.
KRaBs's overall architecture is described in the design document and the specification document.
- Supports legacy BIOS.
- Supported media are HDD and SSD which have GPT.
- Supports 32bit protected mode and 64bit long mode.
- Supports OS kernel formatted in ELF32/ELF64.
- Supports minimal x86/x86_64 linux boot protocol.
- KRaBs interprets the FAT32 file system.
- KRaBs's boot optuon is configureset by CONFIG.TXT on the FAT32 file system.
- KRaBs can load modules such as initramsfs/initrd according to linux boot protocol.
- KRaBs can transmit kernel command line to the kernel according to linux boot protocol.
- support gziped kernel.
- support recovery mode.
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
You can get in touch with me in the following ways:
- Contact me on my twitter.
- Open a GitHub issue in this repository.
- Email me at [email protected].
Note: I'm on a Japan time zone.
When communicating within the Krabs community, please mind our code of conduct.