RSS feed logo RSS Feed | About Pantz.org
Installing SystemRescueCd on a USB stick
Posted on 02-27-2008 15:03:00 EST | Updated on 02-27-2008 15:03:00 EST
Section: /software/systemrescuecd/ | Permanent Link

The SystemRescueCd is a Linux system on a bootable CD-ROM for repairing your system and recovering your data after a crash. Problem is I deal with machines that don't have CD-ROM's. It's a pain to hook up a USB CD-ROM drive everytime I want to boot the CD so I decided to use the instructions on the SystemRescueCd homepage to make a USB stick. I used many of the instructions on that page but I had to come up with a few of my own to make it work for me. Here are my instructions on making a SystemRescueCd bootable USB stick.

I'm going to be using a USB stick that shows up on my Linux system as /dev/sdb. I am using SystemRescueCd version 4.2 for this install.

Download the latest iso from the SystemRescueCd site. I'm putting mine in /tmp for this example.

Install the syslinux package on your machine if you don't have it. Use yum for redhat or apt for debian based system.

sudo apt-get install syslinux

Plug in your USB stick. Now to destroy the old mbr on USB stick. Remember the examples for the rest of the time will use /dev/sdb as the device (USB stick). Make sure your doing this on the right device or you could destroy your current machines master boot record. Type "dmesg" to find out what device your system says your USB stick is.

dd if=/dev/zero of=/dev/sdb bs=512 count=1

Next we need to partition the USB stick. We will use parted to do it. The first command is run from the shell prompt. The rest of commands after that should be done at the parted prompt. We will make one partition a minimum of 256 Meg. I use fat16 as the filesystem. Make it bootable. You might be able to use fat32 it depends on the version of syslinux your using. Later ones can use fat32. Try it if you like. Print your changes to make sure they look right and then quit.

parted /dev/sdb
mkpartfs primary fat16 0 100%
set 1 boot on
print
quit

Force a re-read of the partition table if need be.

sudo /sbin/blockdev --rereadpt /dev/sdb

Put on boot loader (mbr.bin) that came with syslinux package. If you need to find it use the command "find / -name mbr.bin". On Debian it was in the path below.

sudo cat /usr/lib/syslinux/mbr.bin > /dev/sdb

Make the filesystem on the partition of the USB stick.

mkfs.vfat -F 16 /dev/sdb1

Make temp dir for mounting USB stick.

mkdir /tmp/usb

Mount the USB stick.

sudo mount -t vfat /dev/sdb1 /tmp/usb

Make dir for iso mount.

mkdir /tmp/iso

Mount the SystemRescueCD iso.

sudo mount -o loop /tmp/systemrescuecd-x86-0.4.2.iso /tmp/iso

Copy the needed files from the SystemRescueCD.

sudo cp /tmp/iso/syslinux/syslinux.cfg /tmp/usb
sudo cp /tmp/iso/sysrcd.dat /tmp/usb
sudo cp -r /tmp/iso/isolinux/* /tmp/usb
sudo cp -r /tmp/iso/bootdisk/ /tmp/usb

Umount USB stick.

sudo umount /tmp/usb

Install syslinux to the USB keys partition.

syslinux /dev/sdb1

Sync the disk.

sync

Put the USB stick in the machine you want to test on and boot the USB stick (make sure the bios is set to boot the USB stick first).

After boot run dhclient to get an IP address from the dhcp server.

dhclient eth0

Now, we need to edit 2 files. The first is the system boot settings and the second a boot script.

Let's make the usbkey writeable. This assumes that /dev/sda is where your USB stick got mounted. Do a df to see where /cdrom is mounted. That is the USB stick device.

mount /dev/sda1 -o remount,rw

Open the file /mnt/cdrom/syslinux.cfg and edit the first line of the script and change it from default rescuecd to default rescuecd setkmap=us so we don't get the annoying boot message about keyboard map. Lower the boot timeout to 300 msecs also.

Next, create the file /mnt/cdrom/autorun. Put the lines below in this file and save it. This file will be executed at start up. It can be changed at any time to add or remove things. If any part of the script exits uncleanly the execution stops. All the lines do is request an ip from the dhcp server and remount the /mnt/cdrom dir to make is writeable.

#!/bin/bash
rootdir=`df | awk '/cdrom/ {print $1}'`
dhclient eth0 &
mount $rootdir -o remount,rw

Del.icio.us! | Digg Me! | Reddit!

Related stories