added extlinux bootloader support

This commit is contained in:
Tobias Powalowski 2010-06-03 19:20:49 +02:00
parent 608eb908d8
commit a4529611ac
2 changed files with 133 additions and 10 deletions

View file

@ -1,7 +1,7 @@
Archboot Guide Archboot Guide
May,30th 2010 June,3th 2010
Tobias Powalowski <tpowa@archlinux.org> Tobias Powalowski <tpowa@archlinux.org>
@ -53,7 +53,7 @@ Introduction
License Arch Linux License Arch Linux
2002-2007 Judd Vinet 2002-2007 Judd Vinet
2007-2009 Aaron Griffin 2007-2010 Aaron Griffin
and are licensed under the GNU General Public License (GPL). and are licensed under the GNU General Public License (GPL).
What is Archboot? What is Archboot?
@ -68,10 +68,7 @@ Introduction
What is the difference to the official install media? What is the difference to the official install media?
* It uses syslinux as initial bootloader. * It provides the long time support kernel as installation option.
* It provides x86_64/i686 architecture in one image.
* It provides the long time support kernel as installation option.
* It uses hybrid iso format.
* It runs a modified Arch Linux system in initramfs. * It runs a modified Arch Linux system in initramfs.
* It is restricted to RAM usage, everything which is not necessary like * It is restricted to RAM usage, everything which is not necessary like
man or info pages etc. is not provided. man or info pages etc. is not provided.
@ -97,7 +94,7 @@ Introduction
mkinitcpio.conf, rc.conf, crypttab and mdadm.conf mkinitcpio.conf, rc.conf, crypttab and mdadm.conf
* Configuration of basic system files * Configuration of basic system files
* Setting root password * Setting root password
* grub, grub2, lilo and syslinux bootloader support * grub, grub2, lilo, extlinux and syslinux bootloader support
Archboot bootparameters Archboot bootparameters

View file

@ -2669,6 +2669,130 @@ create_filesystem() {
RUN_CREATE_FILESYSTEM="yes" RUN_CREATE_FILESYSTEM="yes"
} }
doextlinux () {
if [ ! -e $DESTDIR/usr/bin/extlinux ]; then
DIALOG --msgbox "Couldn't find extlinux binary, installing syslinux now ..." 0 0
PACKAGES="syslinux"
run_pacman
# reset PACKAGES after installing
PACKAGES=""
fi
USE_DMRAID=""
activate_special_devices
getrootfs
getraidarrays
getcryptsetup
getrootuuid
getrootlabel
# look for a separately-mounted /boot partition
bootdev=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
# extlinux only can boot from ext2/3/4 and btrfs partitions!
FSTYPE="$(blkid -c /dev/null $bootdev -o value -s TYPE)"
if ! [ "$FSTYPE" = "ext2" -o "$FSTYPE" = "ext3" -o "$FSTYPE" = "ext4" -o "$FSTYPE" = "btrfs" ]; then
DIALOG --msgbox "Error:\nCouldn't find ext2/3/4 or btrfs partition with /boot on it." 0 0
return 1
fi
# extlinux cannot boot from any raid partition, encrypted and dmraid device
if [ "$(echo $bootdev | grep /dev/md*p)" -o "$(echo $bootdev | grep /dev/mapper)" ]; then
DIALOG --msgbox "Error:\EXTLINUX cannot boot from any raid, raid partition, encrypted or dmraid device." 0 0
return 1
fi
# check if raid1 device is used, else fail.
if [ "$(echo $bootdev | grep /dev/md)" ]; then
if ! [ "$(mdadm --detail $bootdev | grep Level | sed -e 's#.*:\ ##g')" = "raid1" ]; then
DIALOG --msgbox "Error:\EXTLINUX cannot boot from none raid1 devices." 0 0
return 1
fi
fi
# check on GUID (gpt)
if [ "$(parted -sl | grep "Partition Table: gpt")" ]; then
DIALOG --defaultno --yesno "Warning:\nSetup detected GUID (gpt) partition table.\n\nEXTLINUX doesn't support booting from GUID (gpt) partition table.\n\nDo you want to install syslinux to an other device, which contains a msdos partition table?" 0 0 || return 1
fi
DIALOG --msgbox "Attention:\nIn order to get a booting system, you need the boot flag on the partition syslinux will boot the kernel from!" 0 0
DEVS="$(findbootloaderdisks _)"
DEVS="$DEVS $(findbootloaderpartitions _)"
if [ "$DEVS" = "" ]; then
DIALOG --msgbox "No hard drives were found" 0 0
return 1
fi
DIALOG --menu "Select the boot device where the EXTLINUX bootloader will be installed (usually the MBR)" 14 55 7 $DEVS 2>$ANSWER || return 1
ROOTDEV=$(cat $ANSWER)
# generate extlinux.conf
TEMPDIR=/tmp
MBR=$DESTDIR/usr/lib/syslinux/mbr.bin
[ -e ${TEMPDIR}/extlinux.conf ] && rm ${TEMPDIR}/extlinux.conf
cat << EOF > ${TEMPDIR}/extlinux.conf
DEFAULT vesamenu.c32
PROMPT 0
MENU TITLE Arch Linux
MENU BACKGROUND splash.png
TIMEOUT 300
MENU WIDTH 78
MENU MARGIN 4
MENU ROWS 10
MENU VSHIFT 10
MENU TIMEOUTROW 15
MENU TABMSGROW 13
MENU CMDLINEROW 11
MENU HELPMSGROW 17
MENU HELPMSGENDROW 29
# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
ONTIMEOUT arch
EOF
sort /tmp/.device-names >> ${TEMPDIR}/extlinux.conf
echo "label arch" >> ${TEMPDIR}/extlinux.conf
echo "TEXT HELP" >> ${TEMPDIR}/extlinux.conf
echo "Boot Arch Linux" >> ${TEMPDIR}/extlinux.conf
echo "ENDTEXT" >> ${TEMPDIR}/extlinux.conf
echo "MENU LABEL Arch Linux" >> ${TEMPDIR}/extlinux.conf
echo "kernel $VMLINUZ" >> ${TEMPDIR}/extlinux.conf
if [ "$NAME_SCHEME_PARAMETER" = "UUID" -o "$NAME_SCHEME_PARAMETER" = "LABEL" ]; then
echo "append initrd=$KERNELPKG.img root=${_rootpart} rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> ${TEMPDIR}/extlinux.conf
else
echo "append initrd=$KERNELPKG.img root=${PART_ROOT} rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> ${TEMPDIR}/extlinux.conf
fi
echo "label fallback" >> ${TEMPDIR}/extlinux.conf
echo "TEXT HELP" >> ${TEMPDIR}/extlinux.conf
echo "Boot Arch Linux Fallback" >> ${TEMPDIR}/extlinux.conf
echo "ENDTEXT" >> ${TEMPDIR}/extlinux.conf
echo "MENU LABEL Arch Linux Fallback" >> ${TEMPDIR}/extlinux.conf
echo "kernel $VMLINUZ" >> ${TEMPDIR}/extlinux.conf
if [ "$NAME_SCHEME_PARAMETER" = "UUID" -o "$NAME_SCHEME_PARAMETER" = "LABEL" ]; then
echo "append initrd=$KERNELPKG-fallback.img root=${_rootpart} rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> ${TEMPDIR}/extlinux.conf
else
echo "append initrd=$KERNELPKG-fallback.img root=${PART_ROOT} rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> ${TEMPDIR}/extlinux.conf
fi
# edit extlinux.conf
DIALOG --msgbox "Before installing SYSLINUX, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, SYSLINUX will be installed." 0 0
[ "$EDITOR" ] || geteditor
$EDITOR ${TEMPDIR}/extlinux.conf
# install syslinux
DIALOG --infobox "Installing the SYSLINUX bootloader..." 0 0
cp ${TEMPDIR}/extlinux.conf ${DESTDIR}/boot/extlinux.conf
cp ${DESTDIR}/usr/lib/syslinux/*.c32 ${DESTDIR}/boot/
cat ${MBR} > ${ROOTDEV}
[ -e ${DESTDIR}/boot/ldlinux.sys ] && rm ${DESTDIR}/boot/ldlinux.sys
chroot /usr/bin/extlinux --install /boot >$LOG 2>&1
if [ $? -gt 0 ]; then
DIALOG --msgbox "Error installing EXTLINUX. (see $LOG for output)" 0 0
return 1
fi
DIALOG --msgbox "EXTLINUX was successfully installed." 0 0
}
dosyslinux() { dosyslinux() {
if [ ! -e $DESTDIR/usr/bin/syslinux ]; then if [ ! -e $DESTDIR/usr/bin/syslinux ]; then
DIALOG --msgbox "Couldn't find syslinux binary, installing syslinux now ..." 0 0 DIALOG --msgbox "Couldn't find syslinux binary, installing syslinux now ..." 0 0
@ -2696,9 +2820,9 @@ dosyslinux() {
DIALOG --msgbox "Error:\nCouldn't find vfat /boot partition." 0 0 DIALOG --msgbox "Error:\nCouldn't find vfat /boot partition." 0 0
return 1 return 1
fi fi
# syslinux cannot boot from any raid, raid partition, ecncrypted and dmraid device # syslinux cannot boot from any raid, raid partition, encrypted and dmraid device
if [ "$(echo $bootdev | grep /dev/md)" -o "$(echo $bootdev | grep /dev/mapper)" ]; then if [ "$(echo $bootdev | grep /dev/md)" -o "$(echo $bootdev | grep /dev/mapper)" ]; then
DIALOG --msgbox "Error:\nSyslinux cannot boot from any raid, raid partition, ecncrypted or dmraid device." 0 0 DIALOG --msgbox "Error:\nSyslinux cannot boot from any raid, raid partition, encrypted or dmraid device." 0 0
return 1 return 1
fi fi
# check on GUID (gpt) # check on GUID (gpt)
@ -3792,15 +3916,17 @@ install_bootloader()
prepare_pacman prepare_pacman
CANCEL="" CANCEL=""
DIALOG --menu "Which bootloader would you like to use?" \ DIALOG --menu "Which bootloader would you like to use?" \
11 55 4 \ 11 55 5 \
"GRUB" "Use the GRUB bootloader (default)" \ "GRUB" "Use the GRUB bootloader (default)" \
"GRUB2" "Use the GRUB2 bootloader (experimental)" \ "GRUB2" "Use the GRUB2 bootloader (experimental)" \
"LILO" "Use the LILO bootloader" \ "LILO" "Use the LILO bootloader" \
"EXTLINUX" "Use the EXTLINUX bootloader" \
"SYSLINUX" "Use the SYSLINUX bootloader" 2>$ANSWER || CANCEL=1 "SYSLINUX" "Use the SYSLINUX bootloader" 2>$ANSWER || CANCEL=1
case $(cat $ANSWER) in case $(cat $ANSWER) in
"GRUB") dogrub ;; "GRUB") dogrub ;;
"GRUB2") dogrub2 ;; "GRUB2") dogrub2 ;;
"LILO") dolilo ;; "LILO") dolilo ;;
"EXTLINUX") doextlinux ;;
"SYSLINUX") dosyslinux ;; "SYSLINUX") dosyslinux ;;
esac esac
if [ "$CANCEL" = "1" ]; then if [ "$CANCEL" = "1" ]; then