Pregunta

I've been looking at LILO bootsect.s and GRUB stage1.s.

LILO loads things(or something) from a specific hard-coded sector; it doesn't use some reserved bytes that can be patched up on installation. I wonder how does this work for if when you're on a partition and not alone on a drive? How does LILO tell its bootsec.s where it is on the disk and so adjust appropriately where the files it needs to load are?

LILO doesn't have space for a BPB, so it is for the most part an ext bootloader. ext only has another 512 reserved right after the bootsector. Can LILO's stage 2 really fit in just that little space? Or does it place it on a reserved block?

On the other hand, GRUB does have a reserved dword for where the stage2 resides, which I reckon can be patched up on installation. But it doesn't say anything about the size of it. Looking at it, it seems that it just reads a single sector(mov ax, 0x0201) and then jumps to it. Looking at the stage2 directory, I don't think it can fit on just a single sector.

Both the LILO and GRUB config files have nothing about the filesystem on which they are on. How do they continue with the bootprocess? I mean it contains paths for the files, but I don't think that helps much. Do they try to find out? How so? If there is an already existing OS, won't there be any conflicts with how the current OS likes its filesystem setup and the bootloader files? Given that their stage1 is pretty much filesystem-stupid.

When LILO and GRUB sets up a partition bootsector(a pre-partitioned disk), does it read the partition table on the MBR and so infers where the rest of it is on the disk and so the 'fixed addressing' can work since it will patch stuff, or does it actually load its stuff on fixed hard disk sectors? I go back to my conflict question.

I'm trying to write a bootloader and I feel that something that just reads off a static disk address isn't good enough as it can conflict with filesystem structures and I am lost on how to 'know' where I am on the disk because I don't know if I could trust that the DS:SI points to a real partition table(what if I'm on LBA 0?) and reading the MBR partition table and patching some dword in my stage1 doesn't sit very well to me. So I'm looking for some inspiration from LILO and GRUB. Not being written in NASM doesn't really help. :(

¿Fue útil?

Solución

There is apparently what is called the 'DOS compatibility region'. Insight here

Basically, CHS 0:0:2 - 0:0:63 is 'free'; partitions start at 1:0:1.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top