Boot from usb drive

**Revised and clarified, 2008/05/12**

Here is the procedure for Ubuntu:

1- Make the USB flash drive bootable using SYSLINUX.

sudo apt-get install syslinux

syslinux /dev/sda1 (assuming the device is sda1 - Use the correct device name!)

 

2- Obtain the Ubuntu-Rescue-Remix disk (or just mount the iso as a loop filesystem) and copy the contents of the CD to your flash drive.

mkdir mnt

sudo mount -o loop ubuntu-remix-804.iso mnt

(Copy everything, including hidden files in the mnt folder to your usb drive.  Use any file manager you like (Nautilus, for example)

3- Move all the contents of the "isolinux" folder on the usb drive to the root directory of the usb drive.  Then remove the empty "isolinux" folder.

4- Rename the file called isolinux.cfg to syslinux.cfg

5- Unmount (eject) your USB flash device and reboot the computer from your USB flash drive.

That's it!(ref http://wiki.debian.org/BootUsb and
https://help.ubuntu.com/community/Installation/FromUSBStick)

This is a more detailed

This is a more detailed description of how to get the ubuntu-rescue-remix image onto a usb stick. It also describes how to make a gzipped image suitable for putting on other usb sticks:

This should work for other versions of Ubuntu like the Ubuntu desktop cd.

#Prepare your work area:
mkdir liveusb
cd liveusb
mkdir tmp
mkdir mnt
touch loop

#Create a loop device with a fat16 filesystem:
#This creates a sparse file (which means it is bigger than then amount of space it takes up on the disk. This is to avoid waste. Use a number larger than 200M if you need to host a bigger image).

dd if=/dev/zero of=loop bs=1 count=1 seek=200M

#This creates an msdos filesystem. But there is no reason to use fat16 - you can use ext2 as well, see below...

mkdosfs -F 16 -n ubuntu-rescue-remix loop

#Mount the cdrom iso image:
#This step is not needed if you just built the image from scratch. Just use the /work/image directory instead of tmp/.

sudo mount -o loop ../work/rescue-remix-804Alpha.iso tmp

#Mount your new filesystem:
sudo mount -o loop loop mnt

#Copy the files:
sudo cp -a ../work/image/* mnt/

#or if you are using the iso image mounted as a loop filesystem at tmp/,
#cp -a tmp/* mnt/

#and change the location of the bootloader and its configuration file:

cd mnt
sudo mv isolinux/* .
sudo rmdir isolinux/
sudo mv isolinux.bin syslinux.bin
sudo mv isolinux.cfg syslinux.cfg

#Unmount
sudo umount mnt
cd ..
sudo umount tmp
syslinux loop
gzip -c loop > remixusb.gz

To install onto a usb drive, insert the drive, determine the device (Example, /dev/sdc), ensure that the device has a partition table on it and run

sudo zcat remixusb.gz > /dev/sdc1
EDIT: This is no longer correct. Use this instead:
zcat ubuntu-remix-804.usb.gz | sudo tee /dev/sdxX >/dev/null

If the device does not boot, you may need to install an MBR onto the device.

sudo apt-get install mbr

sudo mbr-install /dev/sdc

and try again.

You can partition your USB stick to contain the live image as well as a storage partition. You can use the storage partition to keep a small amount of recovered files or you can use it as swap space.

If the storage space is located after then live image partition, it won't be seen by Windows ("Doesn't just work") This is not a problem, since you can create the storage partition first and put the live image at the end of the drive. Just make the live image partition the only partition flagged as bootable.

When the drive boots, the bootable partition will be used and you are good to go. The live image partition won't be seen by Windows.

Thank you for the thorough

Thank you for the thorough walkthough.
I've been trying to use the pre-compiled gzipped usb file. Everything decompressed right, but I'm been unable to boot off my 200mb fat16 partition on the usb drive. I installed ubuntu's mbr package, but am unable to see the `mbr-install` binary. Has the name of the binary changed? or is there something else that I'm missing?

Found it. The Binary is

Found it. The Binary is `install-mbr`.

To use an ext2 filesystem,

To use an ext2 filesystem, use:

dd if=/dev/zero of=filesparse bs=1 count=1 seek=200M

mkfs.ext2 -L rescue -m 0 filesparse

sudo mount -o loop filesparse mnt

Continue with the rest of the instructions above.

To make it bootable, run

cd mnt

mkdir boot

mv isolinux boot/extlinux

mv boot/extlinux/isolinux.cfg /boot/extlinux/extlinux.conf

sudo extlinux --install boot/extlinux/

Neither of my computers has

Neither of my computers has a BIOS that supports booting from USB. Is there some way to boot from CD to a USB drive and then remove the CD, so that the CD drive is available for offloading files?

Smart Boot Manager is

Smart Boot Manager is included in the /install folder. You can possibly use that to boot from USB.

https://help.ubuntu.com/community/SmartBootManager

To write to CD, you still need to create the image on disk (or ramdisk). You cannot write a data cd on-the-fly. DO you have enough ram for this?

Can't the image be created

Can't the image be created on the USB drive?

I've offloaded files onto CD using Puppy Linux, which runs entirely in RAM and permits replacing the CD after booting. Never gave a thought to how it worked, though. My test files were small and perhaps things would not have been so simple if I had tried to fill the CD.

If you have enough ram, the

If you have enough ram, the iso image will be built in ram.

You can append "toram" to the kernel boot line to make it run completely from ram, freeing up the cdrom. From the manpage:
toram
Adding this parameter, casper will try to copy the whole read-only media to the computer’s RAM before mounting the root filesystem. This could need a lot of ram, according to the space used by the read-only media.

I see that the toram

I see that the toram function is currently not working:

https://bugs.launchpad.net/ubuntu/+source/casper/+bug/25496

#!/bin/bash #This will

#!/bin/bash
#This will create a gzipped image of the Ubuntu live cd suitable for using on a portable USB drive

TARGET=$(basename $1 .iso).usb
LABEL=$(basename $1 .iso)

mkdir loopdir mnt

SIZE=$(du --si $1 |awk '{print $1}')

echo
echo "creating loop device"
dd if=/dev/zero of=loop bs=1 count=1 seek=$SIZE
echo "filesystem is $SIZE bytes"

echo
echo "creating filesystem on loop device"
#mkdosfs -F 16 -n Ubuntu-live loop
mkfs.ext2 -F -q -L $LABEL -m 0 loop

echo
echo "copying files"
mount -o loop $1 mnt
mount -o loop loop loopdir
cp -aT mnt loopdir
mkdir loopdir/boot/
mv -T loopdir/isolinux/ loopdir/boot/extlinux/
mv loopdir/boot/extlinux/isolinux.cfg loopdir/boot/extlinux/extlinux.conf
rm loopdir/boot/extlinux/isolinux.bin
extlinux --install loopdir/boot/extlinux/
echo
echo "cleaning up..."
sync;sync;sync;
sleep 15
umount -l mnt
umount loopdir
rmdir loopdir
rmdir mnt
#syslinux loop

echo
echo "compressing image"
mv loop $TARGET
gzip $TARGET
echo
echo "to write image to usb device, run:"
echo "zcat $TARGET.gz | sudo tee /dev/sdxX >/dev/null"
echo "Where xX is the correct usb device (Example, /dev/sdc1)"
echo
echo "If the device doesn't want to boot, put an MBR on it by running:"
echo "cat /usr/lib/syslinux/mbr.bin | sudo tee /dev/sdX>/dev/null Where 'X' is the device."

http://ubuntu-tutorials.com/2

http://ubuntu-tutorials.com/2008/05/09/a-root-shell-on-ubuntu-the-right-...

The way to put a usb image onto a device is by using tee, since sudo privs are no longer redirected.

zcat ubuntu-remix-804.usb.gz | sudo tee /dev/sdxX >/dev/null