linux-surface-default-kernel.sh 510 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. set -euo pipefail
  3. # get list of surface kernels with timestamp
  4. kernels=$(find /boot -maxdepth 1 -name "vmlinuz-*.surface.*" -printf '%B@\t%p\n')
  5. # sort by timestamp
  6. kernels=$(echo "${kernels}" | sort -n)
  7. # get latest kernel (last line) and extract path
  8. kernel=$(echo "${kernels}" | tail -n1 | cut -f2)
  9. echo $kernel
  10. # update GRUB config
  11. grubby --set-default "${kernel}"
  12. # update timestamp for rEFInd (ensure it's marked as latest across all kernels,
  13. # not just surface ones)
  14. touch "${kernel}"