1
0
mirror of https://github.com/krglaws/MyLFS.git synced 2025-08-01 23:54:52 +00:00

remove UEFI boot

This commit is contained in:
Kyle Glaws
2022-04-25 09:44:18 -04:00
parent eb04a7c920
commit 09894e4788
14 changed files with 28 additions and 272 deletions

View File

@ -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

153
mylfs.sh
View File

@ -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

View File

@ -54,6 +54,7 @@ diffutils
gawk
findutils
groff
grub
gzip
iproute2
kbd

View File

@ -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

View File

@ -1 +0,0 @@
grub

View File

@ -1,7 +0,0 @@
# UEFI Boot Dependencies
popt
mandoc
efivar
efibootmgr
grub

View File

@ -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

View File

@ -1,7 +0,0 @@
# efivar Phase 4
sed '/prep :/a\\ttouch prep' -i src/Makefile
make
make install LIBDIR=/usr/lib

View File

@ -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 <<EOF
set default=0
set timeout=5
insmod part_gpt
insmod ext2
if loadfont /boot/grub/fonts/unicode.pf2; then
set gfxmode=auto
insmod all_video
terminal_output gfxterm
fi
menuentry "GNU/Linux, Linux 5.16.9-lfs-11.1" {
search --no-floppy --label $LFSROOTLABEL --set=root
linux /boot/vmlinuz-5.16.9-lfs-11.1 rootwait root=PARTUUID=$PARTUUID ro
}
menuentry "Firmware Setup" {
fwsetup
}
EOF

View File

@ -1,15 +0,0 @@
# mandoc Phase 4
./configure
make mandoc
if $RUN_TESTS
then
set +e
make regress
set -e
fi
install -vm755 mandoc /usr/bin
install -vm644 mandoc.1 /usr/share/man/man1

View File

@ -1,7 +0,0 @@
# Popt Phase 4
./configure --prefix=/usr --disable-static
make
make install

View File

@ -12,8 +12,6 @@ PKG_COREUTILS=https://ftp.gnu.org/gnu/coreutils/coreutils-9.0.tar.xz
PKG_DEJAGNU=https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.3.tar.gz
PKG_DIFFUTILS=https://ftp.gnu.org/gnu/diffutils/diffutils-3.8.tar.xz
PKG_E2FSPROGS=https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.46.5/e2fsprogs-1.46.5.tar.gz
PKG_EFIBOOTMGR=https://github.com/rhboot/efibootmgr/archive/17/efibootmgr-17.tar.gz
PKG_EFIVAR=https://github.com/rhboot/efivar/releases/download/38/efivar-38.tar.bz2
PKG_ELFUTILS=https://sourceware.org/ftp/elfutils/0.186/elfutils-0.186.tar.bz2
PKG_EUDEV=https://github.com/eudev-project/eudev/releases/download/v3.2.11/eudev-3.2.11.tar.gz
PKG_EXPAT=https://prdownloads.sourceforge.net/expat/expat-2.4.6.tar.xz
@ -48,7 +46,6 @@ PKG_LINUX=https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.16.9.tar.xz
PKG_M4=https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz
PKG_MAKE=https://ftp.gnu.org/gnu/make/make-4.3.tar.gz
PKG_MANDB=https://download.savannah.gnu.org/releases/man-db/man-db-2.10.1.tar.xz
PKG_MANDOC=https://mandoc.bsd.lv/snapshots/mandoc-1.14.6.tar.gz
PKG_MANPAGES=https://www.kernel.org/pub/linux/docs/man-pages/man-pages-5.13.tar.xz
PKG_MESON=https://github.com/mesonbuild/meson/releases/download/0.61.1/meson-0.61.1.tar.gz
PKG_MPC=https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
@ -59,7 +56,6 @@ PKG_OPENSSL=https://www.openssl.org/source/openssl-3.0.1.tar.gz
PKG_PATCH=https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz
PKG_PERL=https://www.cpan.org/src/5.0/perl-5.34.0.tar.xz
PKG_PKGCONFIG=https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
PKG_POPT=http://ftp.rpm.org/popt/releases/popt-1.x/popt-1.18.tar.gz
PKG_PROCPS=https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-3.3.17.tar.xz
PKG_PSMISC=https://sourceforge.net/projects/psmisc/files/psmisc/psmisc-23.4.tar.xz
PKG_PYTHON=https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz

View File

@ -2,8 +2,6 @@
# order
LABEL=LFSROOTLABEL / LFSFSTYPE defaults 1 1
LABEL=LFSEFILABEL /boot/efi vfat defaults 0 1
efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0
proc /proc proc nosuid,noexec,nodev 0 0
sysfs /sys sysfs nosuid,noexec,nodev 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0