[vox-tech] How to make an OEM style "system recovery disk"

Ted Deppner vox-tech@lists.lugod.org
Mon, 28 Oct 2002 22:16:33 -0800


On Mon, Oct 28, 2002 at 09:10:10PM -0800, Ryan Castellucci wrote:
> I'm looking to build a bootable CD to give to a friend along with a computer 
> that when booted will offer to overwrite the hard drive from a compressed 
> disk image. I looked on freshmeat, but didn't see anything well suited to 
> this. The box in question will have windows on it (They want windows, I don't 
> feel like arguing). Anyone know of a project that can do this?

Project no, but tools available yes.

> What about linux boot CDs that can easily be customized to run a shell script 
> at boot time?

Easy.

> All the stuff i saw on freshmeat looked like it just restored files from a 
> backup.

Sounds close.

The trick with those bootable CDs is called the "El Torito" extension.
It's basically a 1.44 or 2.88 mb floppy image stored on the CD and booted
by chipsets that support it (any mobo in the last 3-4 years).  The system
thinks it's booted a floppy.

So, get what you want working using a floppy disk, and a CD-RW.  If you
were doing dos, the floppy would need to have the cdrom drivers, and so
forth to get the cdrom usable.  If linux, same thing applies, kernel with
cdrom drivers and/or initrd image.

Under linux, you can either replace /sbin/init on your filesystem with a
shell script, or you can use lilo and set "init=/bin/myscript.sh".

Once you have the floppy and the cdrom filesystem, you just use mkisofs to
merge the two and write the result to disk.  Trivial.

Under debian, look at the 'mkinitrd-cd' package.

#build an initrd image suitable for an eltorito bootdisk
mkinitrd-cd /lib/modules/2.4.18-386/ custom.initrd full
# extract the custom.initrd and monkey with the linux.sh script as
# desired.  stick a "zcat /cdrom/compdisk.gz | dd of=/dev/hda" in there,
# and you've got your "restore from compressed disk image".  Dangerous,
# but doable.

#build the eltorito bootdisk
mkbootimg 2880 /boot/vmlinuz-2.4.18-386 custom.initrd custom.eltorito

#build the iso
mkisofs -rRJ \
        -m '*/live/lib/modules/*' \
        -m '*/live/etc/X*' \
        -b custom.eltorito \
        -o custom.iso \
        diskdir
        # -r    all to uid 0
        # -R    Rockridge long filenames for unix
        # -J    MS Joliet lfn
        # -m    exclude files matching pattern
        # -b    eltorito boot image

I've a program that copies core libs and system data (/etc/*) and creates
a "live" directory heirarchy from the currently running machine.  This
allows me to boot the machine with the exact kernel and configuration that
it runs with, but to a live fs on the cdrom.  Useful for fixing things,
and playing around.

Note, you don't need a live fs on the cdrom to do what you want... the
kernel and an initrd image would be sufficient.

<plug>vmware makes tweaking and playing easy!</plug>

Caveats:

The only tricky part is the "mkinitrd-cd" command doesn't do everything it
needs to (too complex to tell you the stuff from memory), and working with
initrd images can be fun.  Getting a good kernel that will boot gz and/or
cramfs initrd images can also be fun.

Hint:  Use CD-RW media until you get it right.  There's enough of your
garbage in my landfill already.  :)

-- 
Ted Deppner
http://www.psyber.com/~ted/