Add intel and amd ucode setup

This commit is contained in:
natemaia
2018-08-27 21:02:52 -07:00
parent 9bc3c70c5a
commit ac48a3640d
2 changed files with 21 additions and 17 deletions

View File

@ -75,10 +75,11 @@ uefi_boot_fallback() {
}
prep_for_grub() {
local ttype
local ucode="$1"
local cfg="$MNT/etc/default/grub"
if [[ $SYS == 'UEFI' ]]; then
local ttype
[[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
else
@ -103,6 +104,8 @@ prep_for_grub() {
}
prep_for_systemd-boot() {
local ucode="$1"
# create the boot entry configs
mkdir -p $MNT/boot/loader/entries
cat > $MNT/boot/loader/loader.conf << EOF
@ -112,7 +115,7 @@ editor no
EOF
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
title $DIST Linux
linux /vmlinuz-${KERNEL}$([[ $(grep 'GenuineIntel' /proc/cpuinfo) && -e $MNT/boot/intel-ucode.img ]] && echo -en "\ninitrd /intel-ucode.img")
linux /vmlinuz-${KERNEL}$([[ $ucode ]] && echo -en "\ninitrd $ucode")
initrd /initramfs-$KERNEL.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
EOF
@ -136,6 +139,7 @@ EOF
}
prep_for_syslinux() {
local ucode="$1"
local cfgdir="$MNT/boot/syslinux"
local cfgsrcdir="/usr/lib/syslinux/bios/"
FILES[9]="/boot/syslinux/syslinux.cfg"
@ -162,14 +166,14 @@ MENU LABEL $DIST Linux
LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
INITRD ../initramfs-$KERNEL.img
$([[ $(grep 'GenuineIntel' /proc/cpuinfo) && -e $MNT/boot/intel-ucode.img ]] && echo -en "\ninitrd /intel-ucode.img")
$([[ $ucode ]] && echo -en "\nINITRD ..$ucode")
LABEL ${DIST}fallback
MENU LABEL $DIST Linux Fallback
LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
INITRD ../initramfs-$KERNEL-fallback.img
$([[ $(grep 'GenuineIntel' /proc/cpuinfo) && -e $MNT/boot/intel-ucode.img ]] && echo -en "\ninitrd /intel-ucode.img")
$([[ $ucode ]] && echo -en "\nINITRD ..$ucode")
EOF
return 0
}
@ -177,9 +181,12 @@ EOF
install_bootloader() {
chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl"
local msg="$_InstBootloader $BOOTLDR\n"
[[ $BOOT_PART != "" ]] && msg="$msg\n$_InstBootDev $BOOT_PART\n"
echo -e "$msg\nMountpoint: ${BMNTS[$SYS-$BOOTLDR]}\n"
local ucode=""
if [[ $(grep 'GenuineIntel' /proc/cpuinfo) && -e $MNT/boot/intel-ucode.img ]]; then
ucode="/intel-ucode.img"
elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) && -e $MNT/boot/amd-ucode.img ]]; then
ucode="/amd-ucode.img"
fi
# if not on an LVM we can use the UUID for booting
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
@ -210,7 +217,7 @@ install_bootloader() {
fi
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
prep_for_$BOOTLDR
prep_for_$BOOTLDR "$ucode"
# run the bootloader command
chroot_cmd "${BCMDS[$BOOTLDR]}"