-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66: Add guide on chainloading r=phil-opp a=64 Co-authored-by: Matt Taylor <mstaveleytaylor@gmail.com>
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Chainloading | ||
|
||
Chainloading is a technique that allows one bootloader to call another bootloader as if the system had just booted up. [GNU GRUB](https://www.gnu.org/software/grub/) is one such bootloader which is commonly used for chainloading, as it presents a menu which you can use to select the OS you'd like to boot from. We're using `grub2` here. | ||
|
||
Create a file under `iso/boot/grub/grub.cfg` in the root directory of your OS's source tree. In it, put: | ||
|
||
``` | ||
menuentry "myOS" { | ||
chainloader (hd1)+1 | ||
} | ||
``` | ||
|
||
This tells grub that our binary is installed on the first partition of the `hd1` disk. If you're trying to boot on real hardware you may need to edit this value as appropriate. Alternatively, you should be able to create a partition on the same ISO file that grub creates and copy the binary there. | ||
|
||
Next, create the ISO with: | ||
``` | ||
grub-mkrescue -o grub.iso iso | ||
``` | ||
|
||
Testing with QEMU (replacing `my_os` with the name of your OS's target): | ||
``` | ||
qemu-system-x86_64 -hda grub.iso -hdb target/x86_64-my_os/debug/bootimage-my_os.bin | ||
``` |