Writing OS experiment from scratch and curious about Grub2 and my FS
I haven't tried very much with this just yet, at least not in practice. I've been reading about GRUB2 and how to set it up but am getting slightly lost. I apologize, I don't have any source code at the moment to offer you. I just wanted to know how to set up GRUB2 to use a File System that I have written from scratch myself.
Write a GRUB driver module for your FS, like how it has modules for XFS, ext2/3/4, and so on. https://wiki.osdev.org/Writing_GRUB_Modules
https://www.gnu.org/software/grub/manual/grub/grub.html#Images explains the different components of GRUB2. The filesystem driver is loaded as part of core.img
, which is built from other images.
Keep in mind that many new filesystems don't get GRUB support right away, and having a separate /boot
partition that GRUB can read is not rare. e.g. on a single disk instead of a complicated RAID (although GRUB does have some md support), not encrypted, and with a long-established filesystem that GRUB does have a driver for. And that doesn't need a complicated log replay on dirty shutdowns before even reading.
Also, the earliest stage of GRUB booting needs to load core.img
from a block list that's hard-coded into the small first thing the firmware loads, so filesystems where the blocks of a file's data can move around when the file wasn't modified aren't usually a good fit for /boot
at all. You'd never know when you had to re-install GRUB after any change to anything on /boot
.
But if you still want to make your FS bootable in GRUB, check the GRUB source code, there's probably some documentation.