Skip to content

Instantly share code, notes, and snippets.

@klange
Created December 24, 2016 07:53
Show Gist options
  • Save klange/278268664d70742e81a236e832b19250 to your computer and use it in GitHub Desktop.
Save klange/278268664d70742e81a236e832b19250 to your computer and use it in GitHub Desktop.

tl;dr: Run:

qemu-system-i386 -vga std -m 512 -cdrom http://toaruos.org/netboot.iso -M accel=kvm:tcg \
  -soundhw ac97 -net user -net nic,model=rtl8139 -serial stdio

Netboot ToaruOS from a 3MB ISO

ToaruOS has a reasonably stable network stack under VirtualBox's and QEMU's user network modes, and we already run ramdisk-based systems on CDs, so why not write an application that gets that ramdisk from the network and have that be the only thing we ship?

Kernel Changes

Some much-needed changes to the kernel were made to support this situation. First off, we assumed we had a working root filesystem mounted in order to try to start init. Second, we always run /bin/init as our init binary. Some new kernel arguments were added to change the init binary, and the requirement for a mounted root filesystem was changed. Also, you can now change the filesystem type for the root filesystem, but that change is aimed at a different project.

The Netboot Binary

Our netboot init is based on a combination of our original init, fetch, and ungz. It enable serial output, downloads the payload file, decompresses it, mounts it, and then runs /bin/init live-welcome.

The Payload

The payload is a normal ext2-formatted ramdisk image just like normal CDs use.

The CD

To make sure the CD is extra small, everything on it is compressed with xz. Unfortunately, GRUB still takes up about 2MB of space - our own files are under 500KB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment