install_kernel.bash 940 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. set -eu -o pipefail
  3. [[ $EUID != 0 ]] && printf "Please run as root\n" && exit 1
  4. [[ -d /usr/src/linux ]] && cd /usr/src/linux
  5. kver=$(make kernelversion)
  6. # Put boot, config, system-map and initramfs on boot dir
  7. if [[ -e /boot/vmlinuz-$kver ]] ; then
  8. mv /boot/vmlinuz-$kver /boot/vmlinuz-$kver.old
  9. mv /boot/config-$kver /boot/config-$kver.old
  10. mv /boot/System.map-$kver /boot/System.map-$kver.old
  11. fi
  12. # Store the kernel, system-map and initramfs in boot directory
  13. cp ./arch/$(uname -m)/boot/bzImage /boot/vmlinuz-$kver
  14. cp .config /boot/config-$kver
  15. cp System.map /boot/System.map-$kver
  16. printf "Making initramfs using dracut\n"
  17. dracut -f -H --kver=$kver &>/dev/null
  18. printf "Copied kernel, config, system-map and initramfs to /boot\n"
  19. # Install kernel and initramfs
  20. cp /boot/vmlinuz-$kver /boot/efi/boot/bootx64.efi
  21. cp /boot/initramfs-$kver.img /boot/efi/boot/initramfs.img
  22. printf "Copied kernel and initramfs to /boot/efi\n"