iso/buildimage.sh

46 lines
800 B
Bash

#!/bin/sh
# creates an image suitable for writing to a USB stick with dd
# requires dosfstools, syslinux
# image size in megabytes with a bit of extra room just in case
IMG_SIZE=285
IMG=$1
ISO_ROOT_DIR=$2
dd if=/dev/zero of=$IMG bs=1M count=$IMG_SIZE
LO=`losetup -f`
losetup $LO $IMG
fdisk $LO <<EOF
o
n
p
1
t
b
a
1
w
EOF
losetup -d $LO
losetup -o 32256 $LO $IMG
mkdosfs -F 32 $LO
mkdir -p tmp/mnt
mount $LO tmp/mnt
rsync -aqz $ISO_ROOT_DIR/ tmp/mnt/
mkdir -p tmp/mnt/boot/syslinux
cp iso/isolinux/{isolinux.cfg,*.msg,memtest86plus} tmp/mnt/boot/syslinux/
mv tmp/mnt/boot/syslinux/{iso,sys}linux.cfg
sed -i -e 's/isolinux/syslinux/g' tmp/mnt/boot/syslinux/syslinux.cfg
umount tmp/mnt
syslinux $LO
losetup -d $LO
losetup $LO $IMG
dd if=/usr/share/syslinux/mbr.bin of=/dev/loop0
losetup -d $LO