[lug] "boot floppy" CD creation recommendations

D. Stimits stimits at comcast.net
Mon Oct 9 21:59:48 MDT 2006


Bear Giles wrote:

> D. Stimits wrote:
>
>> I never tried this, but it would be a cheap and easy test...put a 
>> floppy in the drive, , and do a grub-install to the floppy which 
>> points at the grub partition. Then create a file from the floppy via:
>> dd if=/dev/fd0 of=/tmp/testboot.iso bs=512
>
> No floppy drive.
>
No floppy, no problem. We'll use /dev/random to make our boot iso of 512 
bytes look like a floppy. This time I did try it out, call it my Monday 
night wild hair. At one point in my career I had to write a virtual 
diskless cluster installer, part of that required I rewrite grub for my 
own purposes to deal with very bare hardware. So...here's how you do it.

> The 'dd' would definitely not work.  The 'el torino' extension to 
> ISO9660 allows you to specify a 1200, 1440 or 2880 kb floppy image 
> that compliant BIOSes can treat as a boot floppy.  So if I had a 
> floppy I could try dd'ing the disk into a file that I then pass into 
> mkisofs, but I don't have a floppy drive on that system.
>
Somehow I'm reminded of a cheap Sci Fi movie on tv recently, Deep Core. 
"My Kung Fu is strong!" :P dd works, and I'll show you how.

First, anyone who wants to be convinced (or to deny this), can copy 
their existing boot sector to a floppy with dd, then set it as the boot 
device (the floppy, and disable hard drive boot devices). You can then 
boot from the floppy. I'll assume your first hard drive is /dev/hdc, and 
floppy is /dev/fd0:
dd if=/dev/hdc of=/tmp/boot.iso bs=512 count=1
dd if=/tmp/boot.iso of=/dev/fd0 bs=512 count=1

If you remove all other boot devices (and assuming hdc was already 
bootable), then boot by floppy, it'll act just like you booted from that 
bootable hard drive. So, you should be convinced by now that the first 
512 bytes are the magic.

So...to make el torito work, you only need a floppy of the exact size of 
a floppy drive. This is to fool the BIOS. Only the first 512 bytes 
matter. So to make that boot.iso (which is only 512 bytes) look like a 
1.44 MB floppy, it has to have exactly 2880 blocks of 512 bytes per 
block. We don't really care what happens after the first 512 bytes, 
they're pointless padding we'll never use. We need another 2879 blocks, 
and /dev/urandom will work just fine:
dd if=/dev/urandom of=pad.iso bs=512 count=2879
cat pad.iso >> boot.iso

Next, we need an ISO image which won't freak out systems when they 
truncate before filling one block of the cd (much larger than the block 
of a floppy), so we use mkisofs:
mkisofs -b boot.iso -o plain_boot.iso -pad .

We now have a burnable backup boot device if we get it to cd. So:
cdrecord -v -data dev=/dev/cdrom plain_boot.iso

I added this README file to mine before I created the ISO, just for 
anyone wanting to see how it was made:
----------------------------------------------------------------------------------------
dd if=/dev/<your_MBA_device> of=/tmp/boot.iso bs=512 count=1
cd /some/path/to/mkisofs/source
cp /tmp/boot.iso .
dd if=/dev/urandom of=pad.iso bs=512 count=2879
cat pad.iso >> boot.iso
mkisofs -b boot.iso -o plain_boot.iso -pad .
cdrecord -v -data dev=/dev/cdrom plain_boot.iso
----------------------------------------------------------------------------------------

Boots great...bet you never thought /dev/urandom could repair your ISO 
filesystem? You can add rock ridge extensions and documentation, backup 
files, useful utilities, so on. But all you need on that cd is the 1.44 
MB ISO. Which, btw, can be copied and backed up as well. Should your MBR 
die, dd can put it back.

D. Stimits, stimits AT comcast DOT net

PS: If have *ANY* bootable sector, you have all you need. If so much as 
the device you will point at is designated the same, it'll work on any 
system. E.G., if I am chain loading to /dev/hdc3 where hdc3 is my /boot, 
it'll work on all systems where hdc3 has a /boot capable of chain 
loading. No pixie dust required.



More information about the LUG mailing list