I'm trying to play around with OS development, and I started with a boot loader, where phase 0 loads phase 1 from a file (specified by inode) on an ext4 partition (specified by first LBA). Of course, I need something to boot from, so I grabbed QEMU. Now what?
What has worked fine so far is this:
truncate -s64M /tmp/SomeVolume
/sbin/mke2fs -t ext4 -F /tmp/SomeVolume
yasm phase0.asm
dd if=phase0 of=/tmp/SomeVolume conv=notrunc
I make a volume of about 64 MB, format it as ext4, and overwrite the first 1024 octets with phase0 (which is always 1024 bytes in size). This works fine.
But now I want to make a properly partitioned file, to test it for more realistic scenarios. I know I could /sbin/cfdisk
my volume file, but mke2fs
doesn't have a parameter that lets me choose a span within the file.
Now I'm aware of solutions using loop, but unfortunately, it doesn't seem to work for me (it seems I'm not able to change max_part
in Debian jessie). There seems to be another module called nbd
, but I don't have the server and client for that module installed. And it's getting a little ridiculous that I need root privileges for something that could clearly be done in userland.
How can I do this as a user? Or should I just build the MBR/GPT-partitioned volume around the ext4-formatted file I created?