Use labels to find release media instead of hard-coded device paths. This

makes booting more reliable (and working at all on USB sticks). While here,
move responsibility for setting up fstab into the various platform mk-*.sh
scripts.

Suggested by:	many
This commit is contained in:
Nathan Whitehorn 2011-03-22 01:14:53 +00:00
parent 6359b5731c
commit 0877c11eda
8 changed files with 31 additions and 30 deletions

View File

@ -127,9 +127,7 @@ system: packagesystem
touch ${.OBJDIR}/${.TARGET} touch ${.OBJDIR}/${.TARGET}
release.iso: system release.iso: system
echo kernel_options=\"-C\" > ${.OBJDIR}/release/boot/loader.conf
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release
rm ${.OBJDIR}/release/boot/loader.conf
memstick: system memstick: system
sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick

View File

@ -32,12 +32,14 @@ if [ -e ${2} ]; then
exit 1 exit 1
fi fi
echo '/dev/gpt/FreeBSD_Install / ufs rw,noatime 1 1' > ${1}/etc/fstab
rm -f ${tempfile} rm -f ${tempfile}
makefs ${tempfile} ${1} makefs -B little ${tempfile} ${1}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "makefs failed" echo "makefs failed"
exit 1 exit 1
fi fi
rm ${1}/etc/fstab
# #
# Use $BLOCKSIZE for transfers to improve efficiency. When calculating # Use $BLOCKSIZE for transfers to improve efficiency. When calculating
@ -46,7 +48,7 @@ fi
# #
filesize=`stat -f "%z" ${tempfile}` filesize=`stat -f "%z" ${tempfile}`
blocks=$(($filesize / ${BLOCKSIZE} + 2)) blocks=$(($filesize / ${BLOCKSIZE} + 256))
dd if=/dev/zero of=${2} bs=${BLOCKSIZE} count=${blocks} dd if=/dev/zero of=${2} bs=${BLOCKSIZE} count=${blocks}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "creation of image file failed" echo "creation of image file failed"
@ -59,19 +61,12 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
fdisk -BIq /dev/${unit} gpart create -s GPT ${unit}
if [ $? -ne 0 ]; then gpart add -t freebsd-boot -s 64K ${unit}
echo "fdisk failed" gpart bootcode -b ${1}/boot/pmbr -p ${1}/boot/gptboot -i 1 ${unit}
exit 1 gpart add -t freebsd-ufs -l FreeBSD_Install ${unit}
fi
bsdlabel -B -w /dev/${unit} dd if=${tempfile} of=/dev/${unit}p2 bs=$BLOCKSIZE conv=sync
if [ $? -ne 0 ]; then
echo "bsdlabel failed"
exit 1
fi
dd if=${tempfile} of=/dev/${unit}a bs=$BLOCKSIZE conv=sync
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "copying filesystem into image file failed" echo "copying filesystem into image file failed"
exit 1 exit 1

View File

@ -54,4 +54,7 @@ fi
LABEL=$1; shift LABEL=$1; shift
NAME=$1; shift NAME=$1; shift
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $*
rm $1/etc/fstab

View File

@ -32,12 +32,14 @@ if [ -e ${2} ]; then
exit 1 exit 1
fi fi
echo '/dev/gpt/FreeBSD_Install / ufs rw,noatime 1 1' > ${1}/etc/fstab
rm -f ${tempfile} rm -f ${tempfile}
makefs ${tempfile} ${1} makefs -B little ${tempfile} ${1}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "makefs failed" echo "makefs failed"
exit 1 exit 1
fi fi
rm ${1}/etc/fstab
# #
# Use $BLOCKSIZE for transfers to improve efficiency. When calculating # Use $BLOCKSIZE for transfers to improve efficiency. When calculating
@ -46,7 +48,7 @@ fi
# #
filesize=`stat -f "%z" ${tempfile}` filesize=`stat -f "%z" ${tempfile}`
blocks=$(($filesize / ${BLOCKSIZE} + 2)) blocks=$(($filesize / ${BLOCKSIZE} + 256))
dd if=/dev/zero of=${2} bs=${BLOCKSIZE} count=${blocks} dd if=/dev/zero of=${2} bs=${BLOCKSIZE} count=${blocks}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "creation of image file failed" echo "creation of image file failed"
@ -59,19 +61,12 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
fdisk -BIq /dev/${unit} gpart create -s GPT ${unit}
if [ $? -ne 0 ]; then gpart add -t freebsd-boot -s 64K ${unit}
echo "fdisk failed" gpart bootcode -b ${1}/boot/pmbr -p ${1}/boot/gptboot -i 1 ${unit}
exit 1 gpart add -t freebsd-ufs -l FreeBSD_Install ${unit}
fi
bsdlabel -B -w /dev/${unit} dd if=${tempfile} of=/dev/${unit}p2 bs=$BLOCKSIZE conv=sync
if [ $? -ne 0 ]; then
echo "bsdlabel failed"
exit 1
fi
dd if=${tempfile} of=/dev/${unit}a bs=$BLOCKSIZE conv=sync
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "copying filesystem into image file failed" echo "copying filesystem into image file failed"
exit 1 exit 1

View File

@ -57,4 +57,7 @@ fi
LABEL=$1; shift LABEL=$1; shift
NAME=$1; shift NAME=$1; shift
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $*
rm $1/etc/fstab

View File

@ -91,6 +91,8 @@ fi
publisher="The FreeBSD Project. http://www.freebsd.org/" publisher="The FreeBSD Project. http://www.freebsd.org/"
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
$MKISOFS $BOOTOPTS -r -J -V $LABEL -publisher "$publisher" -o $NAME $BASE $* $MKISOFS $BOOTOPTS -r -J -V $LABEL -publisher "$publisher" -o $NAME $BASE $*
rm -f $BASE/$EFIPART rm -f $BASE/$EFIPART
rm $1/etc/fstab
exit 0 exit 0

View File

@ -54,4 +54,7 @@ fi
LABEL=$1; shift LABEL=$1; shift
NAME=$1; shift NAME=$1; shift
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
mkisofs $bootable -l -r -part -no-desktop -V $LABEL -o $NAME $* mkisofs $bootable -l -r -part -no-desktop -V $LABEL -o $NAME $*
rm $1/etc/fstab

View File

@ -66,5 +66,7 @@ fi
LABEL=$1; shift LABEL=$1; shift
NAME=$1; shift NAME=$1; shift
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $*
rm $1/etc/fstab
rm -f ${IMG} rm -f ${IMG}