You can use nbdkit, our infinitely flexible Network Block Device server to serve small disks and test images with the nbdkit data plugin. For example you can cut and paste this command into your shell to demonstrate a bootable disk image which prints “hello, world”:
nbdkit data data=' 0xb4 0 0xb0 3 0xcd 0x10 0xb4 0x13 0xb3 0x0a 0xb0 1 0xb9 0x0e 0 0xb6 0 0xb2 0 0xbd 0x19 0x7c 0xcd 0x10 0xf4 0x68 0x65 0x6c 0x6c 0x6f 0x2c 0x20 0x77 0x6f 0x72 0x6c 0x64 0x0d 0x0a @0x1fe 0x55 0xaa ' --run 'qemu-system-i386 -fda $nbd'
(As an aside, what is the smallest nbdkit data string that can boot to a “hello, world” message?)
data parameter is a mini-language, and I recently extended it in an interesting way. It wasn’t possible to make repeated patterns easily before. If you wanted a disk containing
0x55 0xAA repeated (the binary bit patterns
01010101 10101010) then the only way to get that was to literally write:
nbdkit data data='0x55 0xAA 0x55 0xAA [repeated many times ...]'
but now you can group things together and write:
nbdkit data data='( 0x55 0xAA )*256'
The nesting works by recursively creating a new parser, which means you can use any data expression. For example to get 4 sectors containing half blank and half test data you can now do:
nbdkit data data='( @256 ( 0x55 0xAA )*128 )*4'
This gives you lots of way to make disks containing test patterns which you could then use to test Linux programs using /dev/nbd0 loop devices.