John Patton <[EMAIL PROTECTED]> writes: > Does anyone know how one would go about creating a debian > rescue cd?
Here is what I did to make my rescue CDs. First, assemble the things you need: 1. A kernel image with your devices compiled in, plus ramdisk and initrd support. Modules are ok (other than for initrd support). My scripts just use the kernel-image.deb created with make-kpkg. The system that you are using to build the rescue cd also needs loopback device support. 2. The busybox package. This is a nice little binary that implements lots of different unix commands, with a small footprint. 3. Other software that you think is useful for a rescue disk. I include ae, xfsprogs, reiserfsprogs, e2fsprogs, lilo, parted, ... 5. A windows boot diskette that knows how to install cdrom drivers. I got mine by taking my win98 boot cd, booting onto the cd, from there, go to "drive A:" (this is not the floppy drive; it's an image on the CD). Format a real floppy (on drive B) with the /s flag, and and copy the autoexec.bat, config.sys, etc., plus the other useful files from "drive A:". Then, on linux, do "dd if=/dev/fd0 of=boot.image bs=1440k". Voila, instant boot image. You can then mount boot.image on your linux system (using the loopback device) and add other DOS commands or drivers or whatever you need. 5. Finally, you need loadlin.exe to boot your kernel This is how I made the disk: 1. Create an 8MB file for the ramdisk. You can make it bigger if you have lots of ram, or smaller if you are short of ram. All of the files I put on my boot disks use about 80% of the ramdisk. dd if=/dev/zero of=ramdisk.img bs=1024k count=8 2. Make a filesystem on that image: mke2fs -m0 -F ramdisk.img 3. Mount that filesystem using a loopback device mount -o loop ramdisk.img /mnt 4. Create your linux tree on that filesystem. As a minimum, you need /bin, /etc, /tmp, /dev, /proc, /lib. mkdir /mnt/bin mkdir /mnt/etc ... etc. ... 5. Copy busybox to /mnt/bin, and make symlinks to busybox for all of the commands that busybox implements cp /bin/busybox /mnt/bin ln -s busybox /mnt/bin/ar ln -s busybox /mnt/bin/cat ... etc. ... 6. Copy the other useful binaries to /mnt/bin (i.e., ae, reiserfsck, parted, reboot, cfdisk, MAKEDEV, etc.) 7. Copy all required libs to /lib. As a minimum, you want ld-linux.so.2, libc.so.6. Use ldd on the binaries you copied in steps 5 and 6 to make sure you get them all. 8. Make a /mnt/etc/init.d/ directory, and put a script in there called rcS. That script does the basic bootup stuff. You probably want to mount the /proc filesystem: mount -t proc none /proc Anything else you need to do before the prompt should be there as well. I use devfs on my rescue disk, but rather than run devfsd, I use rcS to set up the essential symlinks: ln -s vc/1 /dev/tty1 ln -s vc/2 /dev/tty2 ... etc. ... 9. If you don't use devfs, then you probably want to make a bunch of device nodes in /mnt/dev. These really eat up the inodes on your ext2 filesystem, so you may want to tune the mke2fs command above to allocate more inodes. 10. Copy the /lib/modules/vsn tree to /mnt/lib/modules/vsn. I just use dpkg-deb to extract the tree from the kernel-image.deb. 11. Unmount /mnt, and now you have an initrd that's ready to boot. 12. Next, create your cd tree: a. mkdir /tmp/cdtree b. cp /boot/vmlinuz-vsn /tmp/cdtree/linux (or extract it with dpkg-deb) c. cp loadlin.exe /tmp/cdtree d. cp ramdisk.img /tmp/cdtree e. mkdir /tmp/cdtree/boot f. cp boot.image /tmp/cdtree/boot/ This is just the minimum that you need. You could also choose to copy lots of other stuff from /bin and /usr/bin onto the CD, because you've got over 600MB to play with. 13. Create the cd image and burn it: cd /tmp/cdtree mkisofs -r -j -b boot/boot.image -c boot/boot.catalog -o /tmp/cdimage.iso cdrecord -v -eject -pad -speed=8 dev=1,4,0 /tmp/cdimage.iso To use the disk, just boot from the CDROM; change to the drive that the cd is mounted on, and run loadlin linux root=/dev/ram ramdisk_size=8192 initrd=ramdisk.img This is mostly just cribbed from my scripts, which are too oriented to our site to be of much use to anyone else, so there may be some things I missed, but you get the basic idea. Also, VMWare is awesome for testing boot disks. You still have to burn a physical CD, but it's still better than trying to test on a physical box. -- Dave Carrigan ([EMAIL PROTECTED]) | Yow! Hydraulic pizza oven!! UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | Guided missile! Herring Seattle, WA, USA | sandwich! Styrofoam! Jayne http://www.rudedog.org/ | Mansfield! Aluminum siding! | Borax! Pedal pushers! Jukebox!