7 ms·
The final code takes 399 bytes, so there is still free space for the disk label (bytes 440-443), read-only flag (bytes 444-445) and partition table (446-509).
by pzmarzly 6y ago
The final code takes 399 bytes, so there is still free space for the disk label (bytes 440-443), read-only flag (bytes 444-445) and partition table (446-509).
truncate -s 100M disk.img
dd if=bootmine.img of=disk.img bs=512 count=1 conv=notrunc
fdisk disk.img
# n -> enter -> enter -> enter (new primary partition, use all space)
# t -> c (set type to FAT32)
# w (save)
sudo losetup -f disk.img --show -P
# it will print the device path, e.g. /dev/loop21
# -P is to auto-detect partitions
sudo mkfs.vfat /dev/loop21p1
# Now you can use e.g. GNOME Disks to see that
# the partition is "normal" (you can mount it,
# put files there, etc).
# Does it boot?
sudo qemu-system-x86_64 -drive file=/dev/loop21
# Looks good to me, though I don't have time to play rn.