This is a small guide to create a USB pen drive with three livecds installed and ready to boot from it. These are miniPE, BackTrack and Knoppix. For good measure, I've thrown in Memtest86+ too. It is expected that the reader is seasoned in Linux usage; I certainly won't try to explain certain things.
Because I find them extremely useful as rescue cds (miniPE and Knoppix) and of course BackTrack is the leading pentest livecd. Also, they boot much faster from USB than CD and I can carry them in my pocket at all times. But more than that, I enjoyed the technical challenge, since there are guides out there to convert specific livecds to USB but none (that I know of) to bundle several livecds, especially these three livecds that are representative of the livecd technologies most used today. MiniPE is based on bartPE, a windows livecd; BackTrack is based on Slax, a linux slackware-based livecd; and Knoppix, well, powers a lot of other livecds, such as the late Auditor. So, by learning how to deal with these three popular livecds simultaneously, you can pretty much install any other livecd.
Before we begin, you should have these ready:
We must begin with miniPE because the best way I know of installing it is by using PeToUSB. Although it is free as in beer, the problem with PeToUSB is that it clears the USB pen during the miniPE installation process. Otherwise it's quite nice and easy to use. Just do the following:
Afterwards you should try to boot miniPE off the pen to make sure it's working.
Moving on to Linux now. The first USB drive is usually named /dev/sda, but if you have SCSI/SATA drives, it'll probably be sdb or sdc. So when I say /dev/sda, it's just an example. For partitioning I prefer gparted but you can use whatever you like. Here's what you'll need to do:
This is the partition table I ended up with:
Device Boot Start End Blocks Id System /dev/sda1 1 65 522081 16 FAT16 /dev/sda2 * 66 66 8032+ 83 Linux /dev/sda3 67 157 730957+ 83 Linux /dev/sda4 158 249 738990 83 Linux
Now we'll mount BackTrack's ISO and copy all contents into its target partition:
mount -o loop backtrack.iso /mnt/iso mount /dev/sda3 /mnt/usb cp -a /mnt/iso/* /mnt/usb/ umount /mnt/usb umount /mnt/iso
Exactly like BackTrack:
mount -o loop knoppix.iso /mnt/iso mount /dev/sda4 /mnt/usb cp -a /mnt/iso/* /mnt/usb/ umount /mnt/usb umount /mnt/iso
This is the fun part. Grub installs here just like in any other drive (I'm assuming the USB pen drive is the second drive, hence grub's hd1):
mount /dev/sda2 /mnt/usb grub-install --root-directory=/mnt/usb --recheck '(hd1)'
We might as well install memtest86+ since it's small and handy in the worst case scenario. I used the copy I had already installed in my desktop:
cp -a /boot/memtest86plus /mnt/usb/boot
A little boot splash doesn't hurt, either. I downloaded this one and copied it to grub's directory:
cp robin.xpm.gz /mnt/usb/boot/grub/
What is a little harder is figuring out what to put in our menu.lst. For miniPE, we boot it just like any other windows partition. For the Linux livecds, one should inspect what kernel, initrd and boot parameters they use. BackTrack has all of these in /boot/DOS/config (strange place but what the heck). Knoppix uses a more standard /boot/isolinux/isolinux.cfg. Now we only have to translate this information to grub parlance. Create /mnt/usb/boot/grub/menu.lst with the following (beware of line wraps):
default 0 timeout 5 splashimage=(,1)/boot/grub/robin.xpm.gz title=miniPE rootnoverify (,0) chainloader +1 title BackTrack root (,2) kernel /boot/vmlinuz root=/dev/ram0 rw initrd=/boot/initrd.gz init=linuxrc lang=pt load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=100000 max_loop=255 pci=nommconf initrd /boot/initrd.gz title Knoppix root (,3) kernel /boot/isolinux/linux ramdisk_size=100000 init=/etc/init lang=pt apm=power-off vga=791 initrd=minirt.gz nomce quiet pci=nommconf BOOT_IMAGE=knoppix initrd /boot/isolinux/minirt.gz title=Memtest86+ root (,1) kernel /boot/memtest86plus/memtest.bin
Just a few notes:
Hopefully now you have an USB pen drive with your favorite livecds booting in harmony. When new versions of the livecds come out, all you have to do is to replace the files in the respective partition with the new ISO's files, and possibly to change the boot parameters in grub if it stops booting. Enjoy!