In the past I have created liveusb image files using the script below.
Did something change, on Fedora 13 I am getting.
Error finding block device of /dev/loop0. Aborting!
Or is there a better way I can create img files?
#!/bin/bash
# Create a bootable usb image
# So we will create a 7800 image
# For 8GB we use
# Headers - 247
# Sectors - 62
# Bytes/Sector - 512
# BS = 247*62*512=7840768
# Cylinders(count) = (7800MB*1000*1024)/7840768) = 1018 cylinders
# Skip = Sectors * Bytes i.e. 62*512 = 31744
# BLOCKS which we will use (found in fdisk)
# 1GB = 799728 (800MB)
# 2GB = (1900MB)
# 4GB = 3499094 (3500MB)
# 8GB = 7794795 (7800MB)
ISO=$1
IMAGE=`echo $ISO | sed "s|.iso|.img|"`
# Check for files
if [ ! -f /usr/share/syslinux/mbr.bin ]; then
echo cannot find /usr/share/syslinux/mbr.bin
exit 0
fi
if [ ! -x /usr/bin/livecd-iso-to-disk ]; then
echo cannot find /usr/bin/livecd-iso-to-disk
exit 0
fi
HEADERS=247
SECTORS=62
BYTES=512
CYLINDERS=1018
BS=7840768c
BLOCKS=7794795
SKIP=31744
LOOP=$(losetup -f)
# Check for iso
if [ ! -f "$1" ]; then
echo no file $1
exit 0
fi
# Create an image
echo "Creating img file"
dd if=/dev/zero of=${IMAGE} bs=${BS} count=${CYLINDERS}
# attach image as loopback device
echo "Attaching img"
losetup ${LOOP} ${IMAGE}
# fdisk the loop device and create mbr/partition
echo "Creating partition"
echo -e "o\nn\np\n1\n\n\na\n1\np\nw\n" | fdisk -u -C${CYLINDERS}
-S${SECTORS} -H${HEADERS} ${LOOP}
# detach loop device
echo "Dettach img"
losetup -d ${LOOP}
# Attach image as loop ignoring mbr
echo "Attaching img, skipping mbr"
losetup -o${SKIP} ${LOOP} ${IMAGE}
# Set UUID
echo "Setting UUID"
tune2fs -U 45bc7871-dc50-4729-aece-d007ef2a2de7 ${LOOP}
# Create a ext3 partiton here, the BLOCKS is the blocks from fdisk
echo "Creating ext3 partiton"
mke2fs -j -b1024 ${LOOP} ${BLOCKS}
# unpack livecd to loop
echo "Unpack livecd"
livecd-iso-to-disk --noverify --home-size-mb 2048 --overlay-size-mb 2048
${ISO} ${LOOP}
# detach loop device
echo "Dettach img"
losetup -d ${LOOP}
# attach image as loopback device
echo "Attaching img"
losetup ${LOOP} ${IMAGE}
# unpack MBR to start of image
echo "Setup mbr"
dd if=/usr/share/syslinux/mbr.bin of=${LOOP}
# detach loop device
echo "Dettach img"
losetup -d ${LOOP}