indigoparadox

/etc/grub.d/42_otherlinux

Oct 20th, 2026 (edited)
5,171
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | Software | 0 0
  1. #!/bin/bash
  2.  
  3. _linux_list="fedora ubuntu slack arch"
  4.  
  5. for _linux_key in $_linux_list; do
  6.     # Figure out the boot partition index.
  7.     _linux_boot_uuid=`grep $_linux_key\/boot /etc/fstab | awk '{print $1}' | sed 's/^UUID=//g'`
  8.  
  9.     # Figure out the kernel path.
  10.     _linux_kern=`ls -t /mnt/$_linux_key/boot/vmlinu* | head -1`
  11.     _linux_kern=`basename "$_linux_kern"`
  12.     if [ -z "$_linux_kern" ]; then
  13.         continue
  14.     fi
  15.  
  16.     # Figure out the initramfs path.
  17.     _linux_initr=`ls -t /mnt/$_linux_key/boot/initr* | grep -v fall | head -1`
  18.     _linux_initr=`basename "$_linux_initr"`
  19.     if [ -z "$_linux_initr" ]; then
  20.         continue
  21.     fi
  22.  
  23.     # Get an optional kernel command line from a text file in /etc/cmdline.
  24.     _linux_cmdline=""
  25.     if [ -f /etc/cmdline/$_linux_key ]; then
  26.         _linux_cmdline="`cat /etc/cmdline/$_linux_key`"
  27.     fi
  28.  
  29.     # Some display names are different.
  30.     case $_linux_key in
  31.     slack)
  32.         _linux_display=slackware
  33.         ;;
  34.  
  35.     *)
  36.         _linux_display=$_linux_key
  37.         ;;
  38.     esac
  39.  
  40.     # Create the entry.
  41.     cat << EOF
  42. menuentry '${_linux_display^}' {
  43. insmod part_msdos
  44. insmod ext2
  45. search --no-floppy --fs-uuid --set=root $_linux_boot_uuid
  46. linux /$_linux_kern root=/dev/mapper/vg-root$_linux_key ro quiet splash $_linux_cmdline
  47. initrd /$_linux_initr
  48. }
  49. EOF
  50. done
  51.  
Advertisement
Comments
  • Fihadiq
    4 days
    Comment was deleted
Add Comment
Please, Sign In to add comment