Sys
From Foomagic
This is a quick howto to get SystemRescueCD onto your usb key from within linux. For some reason, whatever documentation I found for doing this wouldn't work, so here's the steps I had to go through to get it all working. I dont have a floppy drive for my laptop, and the cdrom drive decided to die a while ago, so booting from the usb key is about my only option should I need to perform any rescue tasks. Syslinux also refused to boot any distro's I have tried on the key, so I have ended up putting an ext2 partition on the end of the key and installing grub to its mbr. Grub's a bit more than is needed, but at least it works. Also the good thing about having the ext2 partition, is that windows cant see it, so whenever I am moving files around on windows computers, I dont have to worry about deleting any of the Rescue CD files, as windows cant see that partition.
First of all, I needed to make an ext2 partition on the key, This was done with cfdisk. I put it on the end of the disk as the windows computer I have here wont see the fat partition (if the ext2 is first partition) on the drive and always asks to format the thing. So with the fat partition at the front, and the ext2 one at the back, I have my rescue cd and then a bit of room to save any files I need to disk. Heres a screenshot of my key with cfdisk.
Now that we have our key partitioned we need to make some file systems on it.
#mkfs.ext2 /dev/sda2 #mkdosfs /dev/sda1
Now, of course we need the iso of the cd, which you can get (of course:) from the SystemRescueCD website. Download it and save to your hard drive. What you do with the iso is up to you, but seeing as I couldnt burn the iso (the whole reason for needing it on usb) I simply mounted the iso on loopback and copied files over from there. If your are unfamiliar with mounting an iso image 'man mount' will give you some insight of what you need to do. I will include all the commands neccessary to perform the tasks I talk about here though. At this stage we also need our usb key in and mounted. Then we need to install grub, edit the menu list, copy the files over from the iso and finally make some alterations.
#mkdir /mnt/usb
#mount /dev/sda2 /mnt/usb
#cp -r /boot/grub /mnt/usb
#grub
GNU GRUB version 0.95 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> root (hd1,1)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+16 p (hd1,1)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.
grub>quit
#mkdir /mnt/iso
#mount -t iso9660 -o loop /path/to/systemrescuecd.iso
#cp -r /mnt/iso/isolinux /mnt/usb
#cp -r /mnt/iso/bootdisk /mnt/usb
#cp -r /mntiso/manual /mnt/usb
#cp /mnt/iso/sysrc.dat /mnt/usb
Ok, now we have all the neccessary stuff there, we need to make a few alterations. Firstly the grub menu has to be changed to suit the installation. Heres the relevant bits of mine.
title rescue root (hd0,1) kernel /isolinux/vmlinuz1 acpi=off root=/dev/ram0 init=/linuxrc dokeymap noscsi usbstick cdcache vga=791 initrd /isolinux/initrd1 savedefault boot
Ok, now we have that done, the only thing left to do is modify the initrd. Luckily someone posted about this little trick on the sysrescuecd forums, so I can't claim any credit for this one.
#cp /mnt/usb/isolinux/initrd1 /tmp/initrd1.gz
#gunzip /tmp/initrd1.gz
#mkdir /mnt/temp
#mount -o loop /tmp/initrd1 /mnt/temp
#vim /mnt/temp/linuxrc ##edit the code to look like this
findusbmount()
{
if mount -t ext2 -r /newroot/dev/scsi/host0/bus0/target0/lun0/part2 /newroot/mnt/cdrom; then
if [ ! -e /newroot/mnt/cdrom/sysrcd.dat ]; then
echo -e "${HILITE}---- /newroot/../part2 is not a Live-USB Stick; skipping...${NORMAL}"
umount /newroot/mnt/cdrom
else
mounted=/newroot/dev/scsi/host0/bus0/target0/lun0/part2
echo -e "${HILITE}---- USB medium found on /newroot/dev/../part2${NORMAL}"
fi
fi
}
*what we are editing is the file type from vfat to ext2, and part1 to part2, now we need to unmount and recompress.
#umount /mnt/temp
#gzip -9 /tmp/initrd1
#cp /tmp/initrd1.gz /mnt/usb/isolinux/initrd1
#umount /mnt/usb
#reboot
Thats about it. If all went well, after setting bios to boot from usb, you should be greeted with grub, and then hopefully boot into the SystemRescueCD. If it takes to long to write to memory during the boot process, you can remove the 'cdcache' option from the kernel options in grub.

