Skip to content

Instantly share code, notes, and snippets.

@micromaomao
Created October 17, 2025 08:16
Show Gist options
  • Select an option

  • Save micromaomao/239977fa9e675ecb604501e413efc66e to your computer and use it in GitHub Desktop.

Select an option

Save micromaomao/239977fa9e675ecb604501e413efc66e to your computer and use it in GitHub Desktop.
arch-installkernel
#!/bin/bash
# Arch Linux version of installkernel - adopted from Debian's
# different, and passes in a fifth argument, just because it is
# "special". We ignore the fifth argument, and do not flag is as an
# error, which it would be for any arch apart from powerpc
if [ $# -eq 3 ] || [ $# -eq 4 ] || [ $# -eq 5 ] ; then
img="$2"
map="$3"
ver="$1"
if [ $# -ge 4 ] && [ -n "$4" ] ; then
dir="$4"
else
dir="/boot"
fi
else
echo "Usage: installkernel <version> <image> <System.map> <directory>"
exit 1
fi
modulesdir="/lib/modules/$ver"
if [ ! -d "$modulesdir" ]; then
echo "Error: $modulesdir does not exist - module_install not run?" >&2
exit 1
fi
set -e
install -Dm644 "$img" "$modulesdir/vmlinuz"
echo "linux-dev" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
kernel-install add "$ver" "$modulesdir/vmlinuz"
install -Dm644 "$img" "/boot/vmlinuz-$ver"
install -Dm644 "$map" "/boot/System.map-$ver"
mkinitcpio -k "$ver" -g "/boot/initramfs-$ver.img"
if [ -f /boot/grub/grub.cfg ]; then
mv /boot/grub/grub.cfg /boot/grub/grub.cfg.old
fi
grub-mkconfig -o /boot/grub/grub.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment