[syslinux] Using MTOOLS in place of loopback mounting

Seth David Schoen schoen at loyalty.org
Sun Jun 23 14:49:34 PDT 2002


I am trying to build a distribution without having to be root.  The
SYSLINUX installer typically needs root to do loopback mounting, but
if you have MTOOLS, you can use that instead.  This seems to work so
far:


#!/bin/sh

# A minimal replacement for /usr/bin/syslinux; assumes that ldlinux.sys
# and ldlinux.bss are available in the current directory.  You must
# specify locations of mkdosfs and mcopy.  You need not be root.  The
# image will be overwritten if it exists, and an empty boot disk image
# will be created.  To avoid overwriting existing files, just omit
# the two steps marked "Create fresh image" below.

# General configuation
IMAGE=`pwd`/lnx.img
TEMP=bootsector.tmp
MKDOSFS=mkdosfs
MCOPY=mcopy
DD=dd
DISKSIZE=1440

# MTOOLS configuration
LETTER=Q
CONFIG="drive $LETTER: file=\"$IMAGE\" #TEMP"
MTOOLSRC=~/.mtoolsrc

grep drive.$LETTER ~/.mtoolsrc >/dev/null 2>&1 || echo $CONFIG >> ~/.mtoolsrc

# ### Create fresh image
$DD if=/dev/zero of=$IMAGE bs=1k count=$DISKSIZE
$MKDOSFS $IMAGE
# ### Create fresh image

$MCOPY ldlinux.sys $LETTER:

# values from syslinux.c (calculated and converted to base 10);
# these are the offset and length of the portion of the boot sector
# which stays the same and is not to be altered by copying in the
# SYSLINUX boot sector.
BSCOPYSTART=11
BSCOPYLEN=51

# xpread(dev_fd, sectbuf, 512, offset);
# memcpy(bootsect+bsCopyStart, sectbuf+bsCopyStart, bsCopyLen);
# xpwrite(dev_fd, bootsect, 512, offset);
$DD if=$IMAGE of=$TEMP bs=512 count=1
$DD conv=notrunc if=ldlinux.bss of=$IMAGE bs=512 count=1
$DD conv=notrunc if=$TEMP of=$IMAGE bs=1 seek=$BSCOPYSTART skip=$BSCOPYSTART count=$BSCOPYLEN
rm $TEMP

grep -v "#TEMP" $MTOOLSRC > $MTOOLSRC.NEW
mv $MTOOLSRC.NEW $MTOOLSRC

-- 
Seth David Schoen <schoen at loyalty.org> | Reading is a right, not a feature!
     http://www.loyalty.org/~schoen/   |                 -- Kathryn Myronuk
     http://vitanuova.loyalty.org/     |



More information about the Syslinux mailing list