Skip to content

Commit

Permalink
manifold supporting and using ISOLINUX now
Browse files Browse the repository at this point in the history
The corresponding commit 1004CF6A89472F8D29F from MirBSD touching
https://www.mirbsd.org/cvs.cgi/src/sys/arch/i386/stand/bootxx/bootxx.S
introduced support for loading ISOLINUX (with similar hacks as the
isohybrid loader uses since SYSLINUX lacks a stable API).

This commit updates bootgrub.mksh from bootxx.S (and an up-to-date
mkbxinst.sh) and introduces bootilnx.mksh (which is built the same
but with BOOT_TYPE=ilnx on the make command line) to match current
MirBSD sources (and OpenADK, which uses bootgrub.mksh now also).

Furthermore, the default for HYBRID_METHOD is still 'manifold' but
installs ISOLINUX now; the new value 'grub2' asks for the current
behaviour. Note that the templates/boot/grub/ directory (with both
GRUB 2 and GRUB-legacy) is still necessary because they’re addons,
and useful in system rescue and booting purposes.

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
  • Loading branch information
mirabilos authored and mika committed Dec 1, 2010
1 parent 09667d4 commit 7ed3014
Show file tree
Hide file tree
Showing 4 changed files with 357 additions and 47 deletions.
4 changes: 3 additions & 1 deletion etc/grml/grml-live.conf
Expand Up @@ -164,7 +164,9 @@
# *without* having to run grml2usb (like: 'dd if=grml.iso of=/dev/sdX')
# - working both with the same ISO
# HYBRID_METHOD='disable' # do not create a hybrid ISO
# HYBRID_METHOD='isohybrid' # use isohybrid instead of the default (being manifold)
# HYBRID_METHOD='isohybrid' # use isohybrid from SYSLINUX
# HYBRID_METHOD='grub2' # use manifold with GRUB 2
# HYBRID_METHOD='manifold' # use manifold with ISOLINUX (default)

# Binary that should be used for creating the squashfs file.
# Defaults to the executable matching the kernel version, falls back to mksquashfs.
Expand Down
13 changes: 11 additions & 2 deletions grml-live
Expand Up @@ -1088,19 +1088,28 @@ else
fi
# by default use our manifold boot method:
else
# isoinfo is part of both mkisofs and genisoimage so we're good
bootoff=$(isoinfo -l -i "${ISO_OUTPUT}/${ISO_NAME}" | \
sed -n '/^.*\[ *\([0-9]*\)[] ].* ISOLINUX.BIN;1 *$/s//\1/p')
if ! [ -r boot/grub/core.img ] ; then
ewarn "boot/grub/core.img not found, not creating manifold boot ISO file"
elif [ $bootoff -lt 1 ] ; then
ewarn "isolinux.bin not found on the ISO file, disabling manifold boot"
else
log "Creating hybrid ISO file with manifold method"
einfo "Creating hybrid ISO file with manifold method"
(
if [ "$HYBRID_METHOD" = "grub2" ] ; then
# 512 bytes: MBR, partition table, load GRUB 2
echo 4 63 | mksh /usr/share/grml-live/scripts/bootgrub.mksh -A -M 4:0x96 -g $cyls:16:32
# pad to a whole of 2048 bytes (one CD sector)
dd if=/dev/zero bs=512 count=3 2>/dev/null
# append GRUB 2 (must be <=30720 bytes)
cat boot/grub/core.img
) | dd of="${ISO_OUTPUT}/${ISO_NAME}" conv=notrunc 2>/dev/null
else
# read only one but 2048-byte sized (scale: << 2) sector
echo $bootoff $bootoff | \
mksh /usr/share/grml-live/scripts/bootilnx.mksh -A -M 4:0x96 -g $cyls:16:32 -S 2
fi | dd of="${ISO_OUTPUT}/${ISO_NAME}" conv=notrunc 2>/dev/null
eend $?
fi
fi
Expand Down
106 changes: 62 additions & 44 deletions scripts/bootgrub.mksh
@@ -1,9 +1,9 @@
#!/usr/bin/env mksh
# $Id$
# $miros: src/sys/arch/i386/stand/bootxx/mkbxinst.sh,v 1.25 2009/07/24 16:27:56 tg Exp $
# $miros: src/sys/arch/i386/stand/bootxx/bootxx.S,v 1.25 2009/06/29 20:50:59 tg Exp $ +t:GRUB +s:MBR
# $miros: src/sys/arch/i386/stand/bootxx/mkbxinst.sh,v 1.28 2010/11/12 21:20:35 tg Exp $
# $miros: src/sys/arch/i386/stand/bootxx/bootxx.S,v 1.26 2010/12/01 19:56:58 tg Exp $ +t:GRUB +s:MBR
#-
# Copyright (c) 2007, 2008, 2009
# Copyright (c) 2007, 2008, 2009, 2010
# Thorsten Glaser <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
Expand All @@ -26,7 +26,7 @@
# and writes bootxx to standard output, which can subsequentially be
# stored as partition boot record (or floppy boot sector) on disc.

set -A thecode 0x66 0x31 0xC9 0x8E 0xD1 0xBC 0xFC 0x7B 0x66 0x51 0x66 0x9D 0x8E 0xC1 0xBE 0x00 0x7C 0x8E 0xD9 0xBB 0x00 0x08 0x53 0x53 0x8E 0xC3 0xBF 0x00 0xFE 0xB5 0x02 0xF3 0xA4 0x1F 0x68 0x6B 0xFE 0xCB 0x30 0x41 0x41 0x41 0x20 0x4C 0x6F 0x61 0x64 0x69 0x6E 0x67 0x20 0x00 0x20 0x65 0x72 0x72 0x6F 0x72 0x0D 0x0A 0x00 0x96 0x02 0x00 0x12 0x00 0x00 0x80 0x65 0xFF 0xB4 0x0E 0xBB 0x07 0x00 0xCD 0x10 0xAC 0x08 0xC0 0x75 0xF4 0xC3 0xE8 0xF7 0xFF 0xB8 0x41 0xFF 0x87 0x06 0x44 0xFE 0x3D 0x41 0xFF 0x75 0x19 0x31 0xC0 0xCD 0x16 0xEA 0xF0 0xFF 0x00 0xF0 0xFB 0x88 0x16 0x43 0xFE 0xBE 0x26 0xFE 0x80 0xFA 0x80 0x72 0xDB 0xE8 0xD2 0xFF 0x31 0xDB 0xBE 0x68 0xFF 0x0F 0xB6 0x2E 0x3D 0xFE 0xAC 0x0F 0xB6 0xC8 0xC0 0xE9 0x05 0x83 0xE0 0x1F 0x40 0x41 0x50 0xBF 0x10 0xFE 0xB8 0x10 0x00 0xAB 0xB0 0x01 0xAB 0x89 0xD8 0xAB 0x8C 0xC8 0xAB 0xF3 0xA4 0x31 0xC0 0xAB 0xAB 0xAB 0xAB 0x5F 0x55 0x56 0xBE 0x10 0xFE 0xFF 0x16 0x44 0xFE 0xBD 0x04 0x00 0x8A 0x16 0x43 0xFE 0x60 0xF9 0xCD 0x13 0x9C 0xB8 0x2E 0x0E 0xBB 0x07 0x00 0xCD 0x10 0x9D 0xFB 0x61 0x73 0x1C 0x4D 0x60 0x9C 0x31 0xC0 0xCD 0x13 0x9D 0xBE 0x34 0xFE 0x0F 0x84 0x77 0xFF 0xB8 0x30 0x0E 0x01 0xE8 0xBB 0x07 0x00 0xCD 0x10 0x61 0xEB 0xD2 0xB4 0x02 0x00 0xE7 0x89 0x5C 0x04 0x00 0xFC 0x72 0x14 0x66 0x83 0x44 0x08 0x01 0x66 0x83 0x54 0x0C 0x00 0x4F 0x75 0xAC 0x5E 0x5D 0x4D 0x0F 0x85 0x7D 0xFF 0xBE 0x3A 0xFE 0xE8 0x3F 0xFF 0x66 0x31 0xD2 0x52 0x66 0x4A 0x8A 0x16 0x43 0xFE 0xB8 0x00 0x82 0x50 0xFA 0xCB 0x60 0x06 0xB4 0x08 0x8A 0x16 0x43 0xFE 0xF9 0xCD 0x13 0xFB 0x07 0xBE 0x34 0xFE 0x0F 0x82 0x21 0xFF 0x80 0xE1 0x3F 0x88 0x0E 0x40 0xFE 0x0F 0xB6 0xC6 0x40 0xA3 0x3E 0xFE 0x61 0x8B 0x0E 0x40 0xFE 0xE3 0xD7 0x8B 0x44 0x08 0x8B 0x54 0x0A 0xF7 0xF1 0x42 0x31 0xC9 0x87 0xD1 0xF7 0x36 0x3E 0xFE 0xC0 0xE4 0x06 0x86 0xC4 0x09 0xC1 0x88 0xD6 0xB8 0x01 0x02 0xC3 0xB4 0x42 0xC3
set -A thecode 0x66 0x31 0xC9 0x8E 0xD1 0xBC 0xFC 0x7B 0x66 0x51 0x66 0x9D 0x8E 0xC1 0xBE 0x00 0x7C 0x8E 0xD9 0xBB 0x00 0x08 0x53 0x53 0x8E 0xC3 0xBF 0x00 0xFE 0xB5 0x02 0xF3 0xA4 0x1F 0x68 0x6B 0xFE 0xCB 0x30 0x41 0x41 0x44 0x20 0x4C 0x6F 0x61 0x64 0x69 0x6E 0x67 0x20 0x00 0x20 0x65 0x72 0x72 0x6F 0x72 0x0D 0x0A 0x00 0x96 0x02 0x00 0x12 0x00 0x00 0x80 0x65 0xFF 0xB4 0x0E 0xBB 0x07 0x00 0xCD 0x10 0xAC 0x08 0xC0 0x75 0xF4 0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0x80 0xE1 0x3F 0x88 0x0E 0x40 0xFE 0x0F 0xB6 0xC6 0x40 0xA3 0x3E 0xFE 0x61 0x8B 0x0E 0x40 0xFE 0xE3 0xD7 0x8B 0x44 0x08 0x8B 0x54 0x0A 0xF7 0xF1 0x42 0x31 0xC9 0x87 0xD1 0xF7 0x36 0x3E 0xFE 0xC0 0xE4 0x06 0x86 0xC4 0x09 0xC1 0x88 0xD6 0xB8 0x01 0x02 0xC3 0xB4 0x42 0xC3
typeset -i ofs_bkcnt=61
typeset -i ofs_geomh=62
typeset -i ofs_geoms=64
Expand Down Expand Up @@ -81,18 +81,18 @@ function record_block {
fi
}

typeset -i partp=0 numheads=0 numsecs=0 sscale=0 bsh=9 mbrpno=0 mbrptp=0
typeset -i partp=0 numheads=0 numsecs=0 sscale=0 bsh=9 mbrpno=0 mbrptp=0 pofs=0
set -A g_code 0 0 0

while getopts ":0:1AB:g:h:M:p:S:s:" ch; do
while getopts ":0:1AB:g:h:M:O:p:S:s:" ch; do
case $ch {
(0) ;;
(1) ;;
(A) numheads=0
numsecs=99
;;
(B) if (( (bsh = OPTARG) < 9 || OPTARG > 15 )); then
print -u2 error: invalid block size "2^'$OPTARG'"
print -u2 Error: invalid block size "2^'$OPTARG'"
exit 1
fi
;;
Expand All @@ -105,45 +105,53 @@ while getopts ":0:1AB:g:h:M:p:S:s:" ch; do
set -A g_code -- $OPTARG
IFS=$saveIFS ;;
(h) if (( (numheads = OPTARG) < 1 || OPTARG > 256 )); then
print -u2 warning: invalid head count "'$OPTARG'"
print -u2 Warning: invalid head count "'$OPTARG'"
numheads=0
fi ;;
(M) if [[ $OPTARG != +([0-9])?(:?(0[Xx])+([0-9])) ]]; then
print -u2 warning: invalid partition info "'$OPTARG'"
print -u2 Warning: invalid partition info "'$OPTARG'"
mbrpno=0
mbrptp=0
fi
saveIFS=$IFS
IFS=:
set -A mbr_code -- $OPTARG
IFS=$saveIFS
(( mbrpno = mbr_code[0] ))
(( mbrptp = mbr_code[1] ))
if (( mbrpno < 1 || mbrpno > 4 )); then
print -u2 warning: invalid partition number "'$OPTARG'"
mbrpno=0
fi
if (( mbrptp < 1 || mbrptp > 255 )); then
print -u2 warning: invalid partition type "'$OPTARG'"
mbrptp=0
else
saveIFS=$IFS
IFS=:
set -A mbr_code -- $OPTARG
IFS=$saveIFS
(( mbrpno = mbr_code[0] ))
(( mbrptp = mbr_code[1] ))
if (( mbrpno < 1 || mbrpno > 4 )); then
print -u2 Warning: invalid partition \
number "'$OPTARG'"
mbrpno=0
fi
if (( mbrptp < 1 || mbrptp > 255 )); then
print -u2 Warning: invalid partition \
type "'$OPTARG'"
mbrptp=0
fi
fi ;;
(O) if [[ $OPTARG != +([0-9]) ]]; then
print -u2 Warning: invalid partition offset "'$OPTARG'"
else
pofs=$OPTARG
fi ;;
(p) if (( (partp = OPTARG) < 1 || OPTARG > 255 )); then
print -u2 warning: invalid partition type "'$OPTARG'"
print -u2 Warning: invalid partition type "'$OPTARG'"
partp=0
fi ;;
(S) if (( (sscale = OPTARG) < 0 || OPTARG > 24 )); then
print -u2 error: invalid input scale "'$OPTARG'"
print -u2 Error: invalid input scale "'$OPTARG'"
exit 1
fi ;;
(s) if (( (numsecs = OPTARG) < 1 || OPTARG > 63 )); then
print -u2 warning: invalid sector count "'$OPTARG'"
print -u2 Warning: invalid sector count "'$OPTARG'"
numsecs=0
fi ;;
(*) print -u2 'Syntax:
bxinst [-1A] [-B blocksize] [-g C:H:S] [-h heads] [-M pno(1..4)[:typ]]
[-p partitiontype] [-S scale] [-s sectors] <sectorlist | \\
[-O partitionofs] [-p type] [-S scale] [-s secs] <sectorlist | \\
dd of=image conv=notrunc
Default values: blocksize=9 heads=16 sectors=63 partitiontype=0x27 scale=0
Default values: blocksize=9 heads=16 sectors=63 part.ofs=0 type=0x27 scale=0
partno=4 if -g (create MBR partition) is given; -A = auto boot geometry'
exit 1 ;;
}
Expand All @@ -169,15 +177,15 @@ if (( psz )); then
"$psz * $((1 << bsh))" | bc) bytes\) in ${g_code[0]} cylinders, \
${g_code[1]} heads, ${g_code[2]} sectors per track
if (( numsecs == 0 || (numsecs != 99 && numheads == 0) )); then
print -u2 warning: using these values for C/H/S boot
print -u2 Warning: using these values for C/H/S boot
numheads=${g_code[1]}
numsecs=${g_code[2]}
fi
(( mbrpno )) || mbrpno=4 # default partition number
fi
if (( mbrpno )); then
bkend=0x1BE
(( psz )) || print -u2 warning: no geometry given, will not \
(( psz )) || print -u2 Warning: no geometry given, will not \
create an MBR partition table entry
fi

Expand All @@ -186,12 +194,12 @@ if (( numsecs == 99 )); then
numsecs=0
else
if (( !numheads )); then
print -u2 warning: using default value of 16 heads
print -u2 Warning: using default value of 16 heads
numheads=16
fi

if (( !numsecs )); then
print -u2 warning: using default value of 63 sectors
print -u2 Warning: using default value of 63 sectors
numsecs=63
fi
fi
Expand All @@ -207,7 +215,7 @@ print -u2 "using $wrec blocks, $((curptr-begptr)) bytes ($((bkend-curptr)) free)

# fill the block table
if (( curptr-- > bkend )); then
print -u2 error: too many blocks
print -u2 Error: too many blocks
exit 1
fi
while (( ++curptr < bkend )); do
Expand All @@ -232,23 +240,33 @@ print -u2 "using sectors of 2^$bsh = $((1 << bsh)) bytes"
# create an MBR partition if desired
if (( psz )); then
(( mbrpno = 0x1BE + ((mbrpno - 1) * 16) ))
set -A o_code # g_code equivalent for partition offset
(( o_code[2] = pofs % g_code[2] + 1 ))
(( o_code[1] = pofs / g_code[2] ))
(( o_code[0] = o_code[1] / g_code[1] + 1 ))
(( o_code[1] = o_code[1] % g_code[1] + 1 ))
# boot flag; C/H/S offset
thecode[mbrpno++]=0x80
thecode[mbrpno++]=0
thecode[mbrpno++]=1
thecode[mbrpno++]=0
(( thecode[mbrpno++] = o_code[1] - 1 ))
(( cylno = o_code[0] > 1024 ? 1023 : o_code[0] - 1 ))
(( thecode[mbrpno++] = o_code[2] | ((cylno & 0x0300) >> 2) ))
(( thecode[mbrpno++] = cylno & 0x00FF ))
# partition type; C/H/S end
(( thecode[mbrpno++] = (mbrptp ? mbrptp : partp ? partp : 0x27) ))
(( thecode[mbrpno++] = g_code[1] - 1 ))
(( cylno = g_code[0] > 1024 ? 1023 : g_code[0] - 1 ))
(( thecode[mbrpno++] = g_code[2] | ((cylno & 0x0300) >> 2) ))
(( thecode[mbrpno++] = cylno & 0x00FF ))
thecode[mbrpno++]=0
thecode[mbrpno++]=0
thecode[mbrpno++]=0
thecode[mbrpno++]=0
(( thecode[mbrpno++] = psz & 0xFF ))
(( thecode[mbrpno++] = (psz >> 8) & 0xFF ))
(( thecode[mbrpno++] = (psz >> 16) & 0xFF ))
(( thecode[mbrpno++] = (psz >> 24) & 0xFF ))
# partition offset, size (LBA)
(( thecode[mbrpno++] = pofs & 0xFF ))
(( thecode[mbrpno++] = (pofs >> 8) & 0xFF ))
(( thecode[mbrpno++] = (pofs >> 16) & 0xFF ))
(( thecode[mbrpno++] = (pofs >> 24) & 0xFF ))
(( pssz = psz - pofs ))
(( thecode[mbrpno++] = pssz & 0xFF ))
(( thecode[mbrpno++] = (pssz >> 8) & 0xFF ))
(( thecode[mbrpno++] = (pssz >> 16) & 0xFF ))
(( thecode[mbrpno++] = (pssz >> 24) & 0xFF ))
fi

# create the output string
Expand Down

0 comments on commit 7ed3014

Please sign in to comment.