Last active
October 7, 2018 09:10
-
-
Save metroid2010/3001bc7c4dec6ef8022c21dbc1f42925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script to generate an EFI entry in arch | |
| # so that there is no need for a boot manager, | |
| # as kernel is directly launched from EFI boot process | |
| # Tailored for and tested on a Thinkpad x220 | |
| # by metroid2010 | |
| # uncomment to disable the creation of a fallback entry | |
| #NO_FALLBACK=1 | |
| # Important: if you mount your ESP partition on /boot, $INITRAMD and $UCODE should work as-is | |
| # If the ESP is mounted on /boot/efi, there is a big chance initramfs, ucode and vmlinuz there do NOT get updated | |
| # when the kernel is, so you have to copy them manually to /boot/efi/EFI/arch/, and set $INITRAMD(_FALLBACK) and $UCODE accordingly | |
| # fill next with your own | |
| DISK="/dev/sda" | |
| PART="1" # *boot* partition number, not root! | |
| LABEL="Glorious Arch" #shoutout to r/linux | |
| INITRAMD="\\initramfs-linux.img" # check these three as explained above | |
| INITRAMD_FALLBACK="\\initramfs-linux-fallback.img" | |
| UCODE="\\intel-ucode.img" | |
| SWAP="/dev/sda2" # swap partition | |
| UUID_ROOT="XXXXXXXXXXXXXXXXXXXXXX" | |
| # Next kernel parameters taken from http://forum.notebookreview.com/threads/linux-on-the-x220.575569/page-29#post8075286 | |
| # The acpi_osi one is to get the brightness keys working on a kernel level. I dont quite know how that works, but it does | |
| EXTRA_PARAMS="acpi_osi=\"Windows 2012\" pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1" | |
| # check this was run as root | |
| if [ "${UID}" -ne "0" ]; then | |
| echo "This script must be run with superuser permissions. Aborting" | |
| exit | |
| fi; | |
| # check efibootmgr exists: | |
| if [ -z "$(which efibootmgr)" ]; then | |
| echo "efibootmgr not found. Aborting" | |
| exit | |
| fi; | |
| # Beware of duplicates! remember to check there is no other entry with the same name | |
| if [ ! -z "$(efibootmgr | grep "${LABEL}")" ]; then | |
| echo "Detected EFI entry with same label \"${LABEL}\"" | |
| echo 'Use command '$ efibootmgr' to list entries, then' | |
| echo '"# efibootmgr -b $ENTRY_ID -B" to delete' | |
| exit | |
| fi; | |
| # If fsck hook is loaded in initramfs (see https://wiki.archlinux.org/index.php/Mkinitcpio), | |
| # remember to add 'rw' as a kernel parameter; if not, set it to 'ro' | |
| efibootmgr --disk ${DISK} --part ${PART} --create --label "${LABEL}" --loader /vmlinuz-linux --unicode \ | |
| "root=PARTUUID=${UUID_ROOT} ro initrd=${UCODE} initrd=${INITRAMD} resume=${SWAP} ${EXTRA_PARAMS}" --verbose | |
| if [ -z "${NO_FALLBACK}" ]; then | |
| efibootmgr --disk ${DISK} --part ${PART} --create --label "${LABEL} (fallback)" --loader /vmlinuz-linux --unicode \ | |
| "root=PARTUUID=${UUID_ROOT} ro initrd=${INITRAMD_FALLBACK}" --verbose | |
| fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment