[syslinux] syslinux 3.72 fails where 3.71 didn't
Ramón Casares
qasar.es at gmail.com
Sat Dec 6 04:52:15 PST 2008
I have written a bash script (see below) to generate bootable SD-USB
images using syslinux as booter. The script works OK with versions
3.63 and 3.71, but I get a null pointer error executing
/tmp/$SYSLINUX/linux/syslinux -sf -o 16384 SD.img
in 3.72.
If you execute
$ sudo sh SDformat.sh sys
then you can test the image easily with qemu
$ qemu -hda SD.img
++++++ SDformat.sh ++++++++++++++++++++
#!/bin/bash
# SDformat.sh fs
# makes a bootable disk file image
# formated with one big fs partition
# fs = iso | sys | ext | zip
# iso is iso9660 (CD)
# sys is vfat (Windows)
# ext is ext2 (Linux)
# zip is vfat as zip
# The file will be called SD.iso, or SD.img
if test $(whoami) != 'root'
then
echo 'Only the root can run this script!'
exit 1
fi
#SLV="3.72" ## Doesn't work
#SLV="3.63" ## Works
SLV="3.71"
SYSLINUX="syslinux-$SLV"
MTV="2.10"
MEMTEST="memtest86+-$MTV"
RDIR=$(cd $(dirname $0) && pwd)
cd ${RDIR}
if test ! -d downloads ; then mkdir downloads ; fi
echo "$SYSLINUX"
cd ${RDIR}/downloads
if test ! -f $SYSLINUX.tar.bz2
then
echo " Getting Syslinux"
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/$SYSLINUX.tar.bz2
fi
cd /tmp
if test ! -d $SYSLINUX
then
echo " Extracting Syslinux"
tar xjf ${RDIR}/downloads/$SYSLINUX.tar.bz2
chown -R root:root $SYSLINUX # 1026:1026
fi
echo "$MEMTEST"
cd ${RDIR}/downloads
if test ! -f "$MEMTEST.bin.gz"
then
echo " Getting Memtest"
wget http://www.memtest.org/download/$MTV/$MEMTEST.bin.gz
fi
if test ! -f /tmp/memtest
then
echo " Extracting Memtest"
gzip -cd "$MEMTEST.bin.gz" > /tmp/memtest
fi
echo "Writing configuration file"
##BEGIN CONFIG##
#BEGIN HEADER#
#Don't move this part. You can change the timeout and menu title, however.
cat > /tmp/syslinux.cfg << "EOF"
DEFAULT menu.c32
TIMEOUT 0
PROMPT 0
menu title Welcome to GNU/Linux!
EOF
#END HEADER#
#BEGIN HD BOOT OPTION#
#If this bugs you, get rid of it.
cat >> /tmp/syslinux.cfg << "EOF"
label local
menu label Boot from ^hard drive
localboot 0x80
EOF
#END HD BOOT OPTION#
# HERE YOU CAN ADD YOUR OWN ENTRIES
#BEGIN MEMTEST ENTRY#
cat >> /tmp/syslinux.cfg << "EOF"
label memtest
menu label ^Memtest86+ v2.10
kernel /boot/memtest
EOF
#END MEMTEST ENTRY#
#BEGIN REBOOT ENTRY#
cat >> /tmp/syslinux.cfg << "EOF"
menu separator
label reboot
menu label ^reboot
com32 reboot.c32
EOF
#END REBOOT ENTRY#
##END CONFIG##
if test $1 == "iso"
then
echo "Creating ISO image"
cd /tmp
if test -d CDroot ; then rm -r CDroot/* ; else mkdir CDroot ; fi
mkdir -p CDroot/boot/isolinux
cp $SYSLINUX/core/isolinux.bin CDroot/boot/isolinux/ ## 3.72
#cp $SYSLINUX/isolinux.bin CDroot/boot/isolinux/ ## 3.63
cp $SYSLINUX/com32/modules/reboot.c32 CDroot/boot/isolinux/
cp $SYSLINUX/com32/menu/menu.c32 CDroot/boot/isolinux/
cp memtest CDroot/boot/
cp syslinux.cfg CDroot/boot/isolinux/isolinux.cfg
genisoimage -r -J -l -V "ISOboot" -input-charset iso8859-1 \
-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-o ${RDIR}/SD.iso CDroot
echo "ISO image generated: ${RDIR}/SD.iso"
exit
fi
FSCode="c" ; if test $1 == "ext" ; then FSCode="83" ; fi
PART="1" ; if test $1 == "zip" ; then PART="4" ; fi
echo "Creating HD image"
cat > /tmp/fdisk.cmd << EOF
o
n
p
$PART
t
$FSCode
a
$PART
p
w
EOF
cd ${RDIR}
if test -f SD.img ; then rm SD.img ; fi
dd if=/dev/zero of=SD.img bs=512 count=251904
losetup /dev/loop/0 SD.img
fdisk -b 512 -H 8 -S 32 -C 984 /dev/loop/0 < /tmp/fdisk.cmd
dd if=/tmp/$SYSLINUX/mbr/mbr.bin of=/dev/loop/0
kpartx -av /dev/loop/0
if test $1 == "ext" ; then
mkfs.ext2 -L Linuxboot /dev/mapper/0p1
mount /dev/mapper/0p1 /mnt/loop/
mkdir -p /mnt/loop/boot/extlinux/
cd /mnt/loop
cp /tmp/$SYSLINUX/com32/menu/menu.c32 /mnt/loop/boot/extlinux/
cp /tmp/$SYSLINUX/com32/modules/reboot.c32 /mnt/loop/boot/extlinux/
cp /tmp/memtest /mnt/loop/boot/
cp /tmp/syslinux.cfg /mnt/loop/boot/extlinux/extlinux.conf
/tmp/$SYSLINUX/extlinux/extlinux -i boot/extlinux/
cd ${RDIR}
umount /mnt/loop
kpartx -d /dev/loop/0
losetup -d /dev/loop/0
else
mkfs.msdos -v -n DOSboot /dev/mapper/0p$PART
mount /dev/mapper/0p$PART /mnt/loop/
mkdir -p /mnt/loop/boot/syslinux/
cp /tmp/$SYSLINUX/com32/menu/menu.c32 /mnt/loop/boot/syslinux/
cp /tmp/$SYSLINUX/com32/modules/reboot.c32 /mnt/loop/boot/syslinux/
cp /tmp/memtest /mnt/loop/boot/
cp /tmp/syslinux.cfg /mnt/loop/boot/syslinux/
umount /mnt/loop
kpartx -d /dev/loop/0
losetup -d /dev/loop/0
/tmp/$SYSLINUX/linux/syslinux -sf -o 16384 SD.img ## 3.72
#/tmp/$SYSLINUX/unix/syslinux -sf -o 16384 SD.img ## 3.63
fi
echo "SD image generated: ${RDIR}/SD.img"
exit
++++++ SDformat.sh ++++++++++++++++++++
More information about the Syslinux
mailing list