diff options
| author | ivan-boikov <ik.boikov.public@protonmail.com> | 2022-11-27 22:49:43 +0100 |
|---|---|---|
| committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2022-11-27 22:49:43 +0100 |
| commit | 44431977d67f83b20add1537505c43bfb1787e86 (patch) | |
| tree | 1d5ea10da9307644697f8dec93996318d84484ce /scripts/.local | |
| parent | 665e987db9013639eb985ef3fa051740bf89d942 (diff) | |
1
Diffstat (limited to 'scripts/.local')
| -rwxr-xr-x | scripts/.local/bin/makekernel | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/scripts/.local/bin/makekernel b/scripts/.local/bin/makekernel index a763eec..33ffb30 100755 --- a/scripts/.local/bin/makekernel +++ b/scripts/.local/bin/makekernel @@ -1,53 +1,62 @@ #!/bin/sh + KEYDIR="/etc/efikeys/" -KKERNEL_NAME="vmlinuz-latest-gentoo" +KERNEL_NAME="vmlinuz-latest-gentoo" if [[ $(hostname) = "pc" ]]; then ROOT_DEVICE="/dev/nvme0n1p3" MICROCODE="amd" + KERNEL_DIR="/boot/efi/gentoo" + THREADS=12 else ROOT_DEVICE="/dev/sda3" MICROCODE="intel" + KERNEL_DIR="/boot/efi/EFI/gentoo" + THREADS=4 fi ROOT="/dev/mapper/root" CRYPT_ROOT="$(blkid -s UUID | grep $ROOT_DEVICE | cut -d' ' -f2 | sed 's/"//g')" BOOT_PARAMS="ro crypt_root=$CRYPT_ROOT root=$ROOT rootfsype=btrfs rootflags=subvol=@ root_trim=yes lsm=selinux" +echo -e "Boot parameters:\n$BOOT_PARAMS\n" +echo -e "\"lsblk -f\" output:\n$(lsblk -f)\n" +echo -e "Kernel image will compiled with $THREADS threads and be installed to $KERNEL_DIR\n" + +if [[ $(/usr/bin/id -u) -ne 0 ]]; then + echo "Cannot proceed, need root permissions" + exit 1 +fi -echo -e "Boot parameters:\n$BOOT_PARAMS\n\nblkid output:\n$(blkid)\n\nProceed with kernel compiling?[Y/N]" +echo "Proceed with kernel compiling?[Y/N]" read answer if [ "$answer" != "${answer#[Nn]}" ] ;then - echo "Aborted" + echo "Aborted" exit 1 fi echo "Starting compilation. Asking for root permissions." -exit 1 +#exit 1 cd /usr/src/linux # inject $BOOT_PARAMS into kernel -sudo sed -i "s|^\(CONFIG_CMDLINE=\).*|\1\"$BOOT_PARAMS\"|" .config +sed -i "s|^\(CONFIG_CMDLINE=\).*|\1\"$BOOT_PARAMS\"|" .config -sudo genkernel --no-clean --no-mrproper --no-save-config \ +genkernel --no-clean --no-mrproper --no-save-config \ --microcode="$MICROCODE" \ --integrated-initramfs --compress-initramfs --compress-initramfs-type=lz4 \ --luks --no-zfs \ --btrfs \ --kernel-config=/usr/src/linux/.config \ --kernel-filename="$KERNEL_NAME" \ - --makeopts=-j \ - --loglevel=2 \ + --makeopts="-j$THREADS" \ + --loglevel=3 \ all -#--virtio \ + #--virtio \ -if [[ $(hostname) = "pc" ]]; then - # UEFI does not find images besides bootx64 - sudo cp -v "/boot/$KERNEL_NAME" "/boot/efi/boot/bootx64.efi" -else - sudo sbsign --key "$KEYDIR/db.key" --cert "$KEYDIR/db.crt" -o "/boot/efi/EFI/gentoo/$KERNEL_NAME.efi" "/boot/$KERNEL_NAME" -fi +echo "Signing image" +sbsign --key "$KEYDIR/db.key" --cert "$KEYDIR/db.crt" -o "$KERNEL_DIR/$KERNEL_NAME.efi" "/boot/$KERNEL_NAME" cd - |
