Generation of images for USB memory sticks

See DebianLive/FirstStepsUSB too.

Although some of the generic images are autobuilt and downloadable on the download server (look for the .img files on http://live.debian.net/), you may want to create your own. This is very easy, you just create them the same way as an ISO image (see DebianLive/Howto/ISO), except that you have to add an option to lh_config. Ensure you have the package live-helper installed and perform as described below:

lh_config -b usb-hdd <options>

lh_build

e.g.

lh_config -b usb-hdd -p gnome -m http://127.0.0.1:3142/ftp.debian.org/debian/

lh_build

Where, in this example, -p is the desktop choice of the image ( more choices in /usr/share/live-helper/lists/ ) and -m is the local apt-cacher mirror to speed up rebuilding images.

If you run into trouble with losetup during lh_build, i.e. an unexpected argument "-f", then give lh_config the additional option --losetup losetup.orig.

When you have the img file, in order to copy it to your USB drive, follow these steps for Linux or for Windows.

Linux

http://www.flickr.com/photos/hendry/963313057/

For computers with Linux installed in the hard disk:

$ ls -la /dev/disk/by-id/usb-*
lrwxrwxrwx 1 root root  9 2007-08-11 12:46 /dev/disk/by-id/usb-Kingston_DataTraveler_II+_5B720CB323C1 -> ../../sdc
lrwxrwxrwx 1 root root 10 2007-08-11 12:46 /dev/disk/by-id/usb-Kingston_DataTraveler_II+_5B720CB323C1-part1 -> ../../sdc1

Note: even if you don't have SCSI drives in your system, many devices (e.g. SATA drives and USB drives) use the SCSI emulation layer. So while on a system with only PATA drives, your USB drive may be /dev/sda because it is the first one, don't count on it.

I'll refer to the USB drive (from the example above that's /dev/sdc) below as $USBDRV.

dd if=debian-live-sid-i386-standard.img of=$USBDRV

Caveat: make sure that you overwrite the whole device, not just the first partition of it that you normally mount, i.e. /dev/sdx instead of the more familiar /dev/sdx1.

Windows

Please note that after this step your USB flash drive will be unreadable by Windows.

On Windows 32 systems instead of dd use WinRaWrite (the easiest) or dd for Windows to copy the image file onto the USB drive. NOTE THAT THIS WIPES ITS CONTENTS!

Boot the live system

Now, ensure that your USB drive is plugged in and reboot your computer to use DebianLive.

Questions

The USB flash drive does not boot. Is an additional step required to make it bootable?

If you find that the USB drive is not bootable, you probably need to change the boot order in your system's BIOS. USB drives most often appear as an additional hard drive device *after* the internal drives in your system. Reorder the devices so that the USB drive comes first.

The FAQ has further details about how to boot from USB if the BIOS does not support USB booting. (see DebianLive/FAQ)

Options

cfdisk $USBDRV
mkfs.ext3 ${USBDRV}2

Testing

$ mkdir test
$ sudo mount -o loop,offset=512 debian-live-40r0-rc1-i386-gnome-USB.img test
$ ls test/
boot.txt  f10.txt  f3.txt  f6.txt  f9.txt       md5sum.txt  syslinux.bin
casper    f1.txt   f4.txt  f7.txt  initrd.img   memtest     syslinux.cfg
doc       f2.txt   f5.txt  f8.txt  ldlinux.sys  splash.rle  vmlinuz
$ sudo umount test

The "offset=512" skips the master boot record.

Note: example given to find the offset to use:

$ sudo fdisk -ul binary.img

it returns you the start sector and the sector size:

[...]
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
[...]

the offset equals the start sector multiplied by the sector size:

e.g.: offset = 63 x 512 = 32256

Generally, the offset found can be:

Testing with Qemu

You can boot the image with Qemu, without copying it to the USB key.

qemu -hda *.img

on amd64 systems run

qemu-system-x86_64 -hda *.img

Will boot the Debian Live image file from where it is on the hard drive. The installation of the accelerating kqemu module seems like a splendid idea, but was found buggy on amd64 systems in 8/2008. It works (slowly) with the "-no-kqemu" option set.

Testing with Virtual Box

For virtual box first convert the image to their format and optinally shrink it:

vditool DD binary.vdi *.img
vditool SHRINK binary.vdi

or:

VBoxManage convertfromraw -format VDI binary.img binary.vdi

Then start the virtualbox application and follow the instructions of the GUI. This seems to work only for images with i686-targeted kernels.

More info


CategoryPermalink

DebianLive/Howto/USB (last edited 2009-03-16 03:33:32 by localhost)