3.3. Building an USB/HDD image

The following sequence of helper commands will create a basic USB/HDD image containing just the Debian standard system without X.org. It is suitable for booting from USB sticks, USB hard drives, and various other portable storage devices.

Note if you created an iso image with the previous example, you will need to clean up your working directory with the lh clean helper command (see Section 4.1.3, “The lh clean helper”):

$ lh clean --binary

Run the lh config helper command with the parameters to configure the "config/" hierarchy to create a USB/HDD image type:

$ lh config -b usb-hdd

Now build the image with the lh build helper command:

# lh build

3.3.1. Copying USB/HDD image to a USB stick

The generated binary image contains a VFAT partition and the syslinux bootloader, ready to be directly written on an USB stick. Plug in an USB stick with a size larger than that of binary.img and type:

$ dd if=binary.img of=${USBSTICK}

where ${USBSTICK} is the device file of your key, like /dev/sdb (not a partition like /dev/sdb1!); you can find the right device name by looking in dmesg's output after plugging in the stick, for example.

Important

This will definitely overwrite any previous contents on your stick!

3.3.2. Testing a USB/HDD image with Qemu

# apt-get install qemu
$ qemu -hda binary.img

3.3.3. Using the space left on a USB stick

If you want to use the remaining free space after you have installed the binary.img, you can use a partitioning tool such as gparted or parted to create a new partition on the stick. The first partition will be used by the Debian Live system.

# gparted ${USBSTICK}

After the creation of the partition you have to create a filsystem on it. One possible choice would be ext2 (ext3 isn't recommended because the journaling causes too many writes to the stick).

# mkfs.ext2 ${USBSTICK}

If you want to use this data partition with Windows, use FAT32.

# mkfs.vfat -F 32

Important

Remember: Every time you install a new binary.img on the stick, all your data will be lost because the image includes a complete partition table.

FIXME: Describe installing Debian Live to a partition (e.g. /dev/sdc1) AND using a bootloader to boot this.