From 09894e4788d85bcd47c2aca98ac93b14530ebcec Mon Sep 17 00:00:00 2001 From: Kyle Glaws Date: Mon, 25 Apr 2022 09:44:18 -0400 Subject: [PATCH] remove UEFI boot --- config.sh | 21 +---- mylfs.sh | 153 ++++++-------------------------- phase4/build_order.txt | 1 + {phase5_bios => phase4}/grub.sh | 0 phase4/linux.sh | 14 --- phase5_bios/build_order.txt | 1 - phase5_uefi/build_order.txt | 7 -- phase5_uefi/efibootmgr.sh | 9 -- phase5_uefi/efivar.sh | 7 -- phase5_uefi/grub.sh | 59 ------------ phase5_uefi/mandoc.sh | 15 ---- phase5_uefi/popt.sh | 7 -- pkgs.sh | 4 - templates/etc__fstab | 2 - 14 files changed, 28 insertions(+), 272 deletions(-) rename {phase5_bios => phase4}/grub.sh (100%) delete mode 100644 phase5_bios/build_order.txt delete mode 100644 phase5_uefi/build_order.txt delete mode 100644 phase5_uefi/efibootmgr.sh delete mode 100644 phase5_uefi/efivar.sh delete mode 100644 phase5_uefi/grub.sh delete mode 100644 phase5_uefi/mandoc.sh delete mode 100644 phase5_uefi/popt.sh diff --git a/config.sh b/config.sh index 19c941f..64dcdd6 100644 --- a/config.sh +++ b/config.sh @@ -25,7 +25,7 @@ export LFSEFILABEL=LFSEFI export LFSFSTYPE=ext4 export KERNELVERS=5.16.9 -export FDISK_INSTR_BIOS=" +export FDISK_INSTR=" o # create DOS partition table n # new partition # default partition type (primary) @@ -36,26 +36,9 @@ y # confirm overwrite (noop if not prompted) w # write to device and quit " -export FDISK_INSTR_UEFI=" -g # create GPT -n # new partition - # default 1st partition - # default start sector (2048) -+512M # 512 MiB -y # confirm overwrite (noop if not prompted) -t # modify parition type -1 # EFI type -n # new partition - # default 2nd partition - # default start sector - # default end sector -y # confirm overwrite (noop if not prompted) -w # write to device and quit -" - KEYS="MAKEFLAGS PACKAGE_LIST PACKAGE_DIR LOG_DIR KEEP_LOGS LFS LFS_TGT"\ " LFS_FS LFS_IMG LFS_IMG_SIZE ROOT_PASSWD RUN_TESTS TESTLOG_DIR LFSHOSTNAME"\ -" LFSROOTLABEL LFSEFILABEL LFSFSTYPE KERNELVERS FDISK_INSTR_BIOS FDISK_INSTR_UEFI" +" LFSROOTLABEL LFSEFILABEL LFSFSTYPE KERNELVERS FDISK_INSTR" for KEY in $KEYS do diff --git a/mylfs.sh b/mylfs.sh index 5d2ea35..65a41e3 100755 --- a/mylfs.sh +++ b/mylfs.sh @@ -25,8 +25,6 @@ your own risk. -V|--verbose The script will output more information where applicable (careful what you wish for). - -f|--uefi Build LFS with UEFI boot instead of the default BIOS boot. - -e|--check Output LFS dependency version information, then exit. It is recommended that you run this before proceeding with the rest of the build. @@ -202,15 +200,8 @@ function init_image { export LOOP=$(losetup -f) # export for grub.sh losetup $LOOP $LFS_IMG - # partition the device - if $UEFI - then - local FDISK_INSTR=$FDISK_INSTR_UEFI - else - local FDISK_INSTR=$FDISK_INSTR_BIOS - fi - - # remove spaces and comments + # partition the device. + # remove spaces and comments from instructions FDISK_INSTR=$(echo "$FDISK_INSTR" | sed 's/ *#.*//') # fdisk fails to get kernel to re-read the partition table @@ -226,34 +217,15 @@ function init_image { sleep 1 # give the kernel a sec losetup -P $LOOP $LFS_IMG - if $UEFI - then - local LOOP_P1=${LOOP}p1 - local LOOP_P2=${LOOP}p2 + local LOOP_P1=${LOOP}p1 - # setup root partition - mkfs -t $LFS_FS $LOOP_P2 &> /dev/null - mkdir -p $LFS - mount -t $LFS_FS $LOOP_P2 $LFS + # setup root partition + mkfs -t $LFS_FS $LOOP_P1 &> /dev/null + mkdir -p $LFS + mount -t $LFS_FS $LOOP_P1 $LFS - # setup EFI partition - mkfs.vfat $LOOP_P1 &> /dev/null - mkdir -p $LFS/boot/efi - mount -t vfat $LOOP_P1 $LFS/boot/efi + e2label $LOOP_P1 $LFSROOTLABEL - # label the partitions - dosfslabel $LOOP_P1 $LFSEFILABEL &> /dev/null - e2label $LOOP_P2 $LFSROOTLABEL - else - local LOOP_P1=${LOOP}p1 - - # setup root partition - mkfs -t $LFS_FS $LOOP_P1 &> /dev/null - mkdir -p $LFS - mount -t $LFS_FS $LOOP_P1 $LFS - - e2label $LOOP_P1 $LFSROOTLABEL - fi rm -rf $LFS/lost+found echo "done." @@ -305,12 +277,7 @@ function init_image { install_template ./templates/etc__lfs-release LFS_VERSION install_template ./templates/etc__lsb-release LFS_VERSION install_template ./templates/etc__os-release LFS_VERSION - install_template ./templates/etc__fstab LFSROOTLABEL LFSEFILABEL LFSFSTYPE - if ! $UEFI - then - sed -i "s/^.*LFSEFILABEL.*$//" $LFS/etc/fstab - sed -i "s/^.*efivars.*$//" $LFS/etc/fstab - fi + install_template ./templates/etc__fstab LFSROOTLABEL LFSFSTYPE # make special device files mknod -m 600 $LFS/dev/console c 5 1 @@ -395,24 +362,11 @@ function mount_image { # attach loop device export LOOP=$(losetup -f) # export for grub.sh local LOOP_P1=${LOOP}p1 - local LOOP_P2=${LOOP}p2 - if $UEFI - then - losetup -P $LOOP $LFS_IMG - sleep 1 # give the kernel a sec + losetup -P $LOOP $LFS_IMG - # mount root fs - mount $LOOP_P2 $LFS - - # mount boot partition - mount -t vfat $LOOP_P1 $LFS/boot/efi - else - losetup -P $LOOP $LFS_IMG - sleep 1 - - mount $LOOP_P1 $LFS - fi + sleep 1 + mount $LOOP_P1 $LFS # mount stuff from the host onto the target disk mount --bind /dev $LFS/dev @@ -544,11 +498,6 @@ function build_phase { CHROOT=true fi - if [ $PHASE -eq 5 ] - then - PHASE=5_$({ $UEFI && echo "uefi"; } || echo "bios") - fi - while read pkg do if $FOUNDSTARTPKG && $ONEOFF @@ -624,14 +573,7 @@ function install_image { $VERBOSE && set -x - # partition the device - if $UEFI - then - local FDISK_INSTR=$FDISK_INSTR_UEFI - else - local FDISK_INSTR=$FDISK_INSTR_BIOS - fi - + # partition the device. # remove spaces and comments FDISK_INSTR=$(echo "$FDISK_INSTR" | sed 's/ *#.*//') @@ -640,55 +582,25 @@ function install_image { echo "ERROR: failed to format $INSTALL_TGT. Consider manually clearing $INSTALL_TGT's parition table." exit fi - - # the kernel might need this. - sleep 1 partprobe $INSTALL_TGT - sleep 1 trap "echo 'install failed.' && unmount_image && exit 1" ERR - local LOOP=$(losetup -f) - losetup -P $LOOP $LFS_IMG - - local LOOP_P1=${LOOP}p1 - local LOOP_P2=${LOOP}p2 - local INSTALL_P1="${INSTALL_TGT}${PART_PREFIX}1" - local INSTALL_P2="${INSTALL_TGT}${PART_PREFIX}2" - mkdir -p $LFS $INSTALL_MOUNT - if $UEFI - then - # setup root partition - mkfs -t $LFS_FS $INSTALL_P2 &> /dev/null - mkdir -p $INSTALL_MOUNT - mount -t $LFS_FS $INSTALL_P2 $INSTALL_MOUNT + # mount IMG file + local LOOP=$(losetup -f) + local LOOP_P1=${LOOP}p1 + losetup -P $LOOP $LFS_IMG - # setup EFI partition - mkfs.vfat -F 32 $INSTALL_P1 &> /dev/null - mkdir -p $INSTALL_MOUNT/boot/efi - mount -t vfat $INSTALL_P1 $INSTALL_MOUNT/boot/efi + # setup install partition + local INSTALL_P1="${INSTALL_TGT}${PART_PREFIX}1" + mkfs -t $LFS_FS $INSTALL_P1 &> /dev/null + e2label $INSTALL_P1 $LFSROOTLABEL - # label the partitions - dosfslabel $INSTALL_P1 $LFSEFILABEL &> /dev/null - e2label $INSTALL_P2 $LFSROOTLABEL - - # mount $LFS_IMG - mount $LOOP_P2 $LFS - mount -t vfat $LOOP_P1 $LFS/boot/efi - else - # setup root partition - mkfs -t $LFS_FS $INSTALL_P1 &> /dev/null - mkdir -p $LFS - mount -t $LFS_FS $INSTALL_P1 $INSTALL_MOUNT - - # add label - e2label $INSTALL_P1 $LFSROOTLABEL - - # mount $LFS_IMG - mount -t $LFS_FS $LOOP_P1 $LFS - fi + # mount install partition + mount $INSTALL_P1 $INSTALL_MOUNT + mount $LOOP_P1 $LFS echo -n "Copying files... " cp -r $LFS/* $INSTALL_MOUNT/ @@ -703,11 +615,6 @@ function install_image { mount -t sysfs sysfs $INSTALL_MOUNT/sys local GRUB_CMD="grub-install $INSTALL_TGT --target i386-pc" - if $UEFI - then - mount -t efivarfs efivarfs $INSTALL_MOUNT/sys/firmware/efi/efivars - GRUB_CMD="grub-install $INSTALL_TGT --bootloader-id=LFS --recheck" - fi echo -n "Installing GRUB. This may take a few minutes... " chroot $INSTALL_MOUNT /usr/bin/bash -c "$GRUB_CMD" @@ -773,7 +680,6 @@ FOUNDSTARTPHASE=false MOUNT=false UNMOUNT=false CLEAN=false -export UEFI=false # exported for linux.sh while [ $# -gt 0 ]; do case $1 in @@ -785,11 +691,6 @@ while [ $# -gt 0 ]; do export VERBOSE=true # exporting for chroot shift ;; - -f|--uefi) - [ ! -d /sys/firmware/efi ] && echo "ERROR: The host system must be booted in UEFI mode in order to build LFS with UEFI support." - UEFI=true - shift - ;; -e|--check) CHECKDEPS=true shift @@ -875,7 +776,7 @@ do done if [ -n "$STARTPHASE" ] && -[ "$STARTPHASE" != 1 -a "$STARTPHASE" != 2 -a "$STARTPHASE" != 3 -a "$STARTPHASE" != 4 -a "$STARTPHASE" != 5 ] +[ "$STARTPHASE" != 1 -a "$STARTPHASE" != 2 -a "$STARTPHASE" != 3 -a "$STARTPHASE" != 4 ] then echo "ERROR: phase '$STARTPHASE' does not exist" exit 1 @@ -952,10 +853,6 @@ $ONEOFF && $FOUNDSTARTPHASE && unmount_image && exit build_phase 4 -$ONEOFF && $FOUNDSTARTPHASE && unmount_image && exit - -build_phase 5 - # final cleanup rm -rf $LFS/tmp/* find $LFS/usr/lib $LFS/usr/libexec -name \*.la -delete diff --git a/phase4/build_order.txt b/phase4/build_order.txt index b59cd23..c776fc8 100644 --- a/phase4/build_order.txt +++ b/phase4/build_order.txt @@ -54,6 +54,7 @@ diffutils gawk findutils groff +grub gzip iproute2 kbd diff --git a/phase5_bios/grub.sh b/phase4/grub.sh similarity index 100% rename from phase5_bios/grub.sh rename to phase4/grub.sh diff --git a/phase4/linux.sh b/phase4/linux.sh index 1bbf651..b91a901 100644 --- a/phase4/linux.sh +++ b/phase4/linux.sh @@ -30,20 +30,6 @@ else config_off CONFIG_UEVENT_HELPER config_on CONFIG_DEVTMPFS config_on CONFIG_MODULES - - if $UEFI - then - config_on CONFIG_EFI - config_on CONFIG_EFI_STUB - config_off CONFIG_EFI_VARS - config_on CONFIG_EFI_RUNTIME_MAP - config_on CONFIG_PARTITION_ADVANCED - config_on CONFIG_EFI_PARTITION - config_on CONFIG_FB - config_on CONFIG_FB_EFI - config_on CONFIG_FRAMEBUFFER_CONSOLE - config_on CONFIG_EFIVAR_FS - fi fi make diff --git a/phase5_bios/build_order.txt b/phase5_bios/build_order.txt deleted file mode 100644 index b7e1eb1..0000000 --- a/phase5_bios/build_order.txt +++ /dev/null @@ -1 +0,0 @@ -grub diff --git a/phase5_uefi/build_order.txt b/phase5_uefi/build_order.txt deleted file mode 100644 index a446ffa..0000000 --- a/phase5_uefi/build_order.txt +++ /dev/null @@ -1,7 +0,0 @@ -# UEFI Boot Dependencies -popt -mandoc -efivar -efibootmgr -grub - diff --git a/phase5_uefi/efibootmgr.sh b/phase5_uefi/efibootmgr.sh deleted file mode 100644 index 4cecf63..0000000 --- a/phase5_uefi/efibootmgr.sh +++ /dev/null @@ -1,9 +0,0 @@ -# efibootmanager Phase 4 -sed -e '/extern int efi_set_verbose/d' -i src/efibootmgr.c - -sed 's/-Werror//' -i Make.defaults - -make EFIDIR=LFS EFI_LOADER=grubx64.efi - -make install EFIDIR=LFS - diff --git a/phase5_uefi/efivar.sh b/phase5_uefi/efivar.sh deleted file mode 100644 index 1b5e4e8..0000000 --- a/phase5_uefi/efivar.sh +++ /dev/null @@ -1,7 +0,0 @@ -# efivar Phase 4 -sed '/prep :/a\\ttouch prep' -i src/Makefile - -make - -make install LIBDIR=/usr/lib - diff --git a/phase5_uefi/grub.sh b/phase5_uefi/grub.sh deleted file mode 100644 index 21cf98c..0000000 --- a/phase5_uefi/grub.sh +++ /dev/null @@ -1,59 +0,0 @@ -# GRUB Phase 4 -mkdir -p /usr/share/fonts/unifont -gunzip -c ../$(basename $PKG_UNIFONT) > /usr/share/fonts/unifont/unifont.pcf - -unset {C,CPP,CXX,LD}FLAGS - -./configure --prefix=/usr \ - --sysconfdir=/etc \ - --disable-efiemu \ - --with-platform=efi \ - --target=x86_64 \ - --disable-werror -# --enable-grub-mkfont (uncomment if using FreeType) - -unset TARGET_CC - -make - -make install - -mv /etc/bash_completion.d/grub /usr/share/bash-completion/completions - -# mount efivars -mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars - -GRUB_OUTPUT=$(grub-install $LOOP --bootloader-id=LFS --recheck) -if [ -n "$(echo $GRUB_OUTPUT | grep "No error reported")" ] -then - echo "An error occured while installing GRUB:" - echo $GRUB_OUTPUT - exit -1 -fi - -# unmount efivars -umount /sys/firmware/efi/efivars - -cat > /boot/grub/grub.cfg <