grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Managing multiple linux installations on one box


From: John Page
Subject: Re: Managing multiple linux installations on one box
Date: Sun, 1 Jul 2012 18:05:10 +0200

I have always found the grub2 policy of listing all the installed kernels of other linux installations to be messy and rather impolite.
Why should I have to boot into Debian to update the grub menu every time I upgrade the kernel in Ubuntu? That's just a waste of time.

So I editied /etc/grub.d/30_os-prober like this:
    linux)
      LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
      prepare_boot_cache=

      OBOOT=
      for LINUX in ${LINUXPROBED} ; do
        LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
        LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
        LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
        LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
        LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
        LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"

        if [ "x${OBOOT}" = "x${LBOOT}" ]; then
          continue
        fi
        OBOOT="${LBOOT}"

        if [ -z "${LLABEL}" ] ; then
          LLABEL="${LONGNAME}"
        fi

    if [ "${LROOT}" != "${LBOOT}" ]; then
      LKERNEL="${LKERNEL#/boot}"
      LINITRD="${LINITRD#/boot}"
    fi

    if [ -z "${prepare_boot_cache}" ]; then
      prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
      [ "${prepare_boot_cache}" ] || continue
    fi
    found_other_os=1
        cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" --class gnu-linux --class gnu --class os {
EOF
    save_default_entry | sed -e "s/^/\t/"
    printf '%s\n' "${prepare_boot_cache}"

        cat << EOF
        if [ -f /boot/grub/grub.cfg ]; then
          configfile /boot/grub/grub.cfg
        elif [ -f /grub/grub.cfg ]; then
          configfile /grub/grub.cfg
        elif [ -f /boot/grub2/grub.cfg ]; then
          configfile /boot/grub2/grub.cfg
        elif [ -f /grub2/grub.cfg ]; then
          configfile /grub2/grub.cfg
        elif [ -f /boot/grub/menu.lst ]; then
          legacy_configfile /boot/grub/menu.lst
        elif [ -f /grub/menu.lst ]; then
          legacy_configfile /grub/menu.lst
        fi
EOF
#    cat <<  EOF
#    linux ${LKERNEL} ${LPARAMS}
#EOF
#        if [ -n "${LINITRD}" ] ; then
#          cat << EOF
#    initrd ${LINITRD}
#EOF
#        fi
        cat << EOF
}
EOF
      done
    ;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]