How to disable grub-mkconfig once and forever?

Ralf Mardorf silver.bullet at zoho.com
Tue Jul 12 05:17:02 UTC 2016


On Mon, 11 Jul 2016 11:11:53 +0200, Ralf Mardorf wrote:
>On Mon, 11 Jul 2016 09:58:14 +0100, Colin Watson wrote:
>>dpkg-divert  
>
>Thank you




Copy the script, paste it to an editor and save it as
  
  dpkg-divert-grub.sh

after that make it executable by running

  chmod a+x /path/to/dpkg-divert-grub.sh

Running

  sudo /path/to/dpkg-divert-grub.sh --add

"disables" auto-generating the GRUB menu (/boot/grub/grub.cfg) and running

  sudo /path/to/dpkg-divert-grub.sh --remove

"enables" it.




#!/bin/bash

divert () {
cat<<EOF
#!/bin/dash
name=\$(echo \$(basename \$0) | sed -e 's/[0-9]\+ *//')
printf "\n \033[7m\$(basename \$0) was renamed \$name.real\033[0m\n\n"
exit
EOF
}

case $1 in

  --add)
    for s in grub-mkconfig update-grub
    do
      s=/usr/sbin/$s
      dpkg-divert --add --rename --divert $s.real $s && divert > $s
      chmod a+x $s
    done;;

  --remove)
    for s in grub-mkconfig update-grub
    do
      s=/usr/sbin/$s
      rm $s && dpkg-divert --rename --remove $s
    done;;

  --list)
    dpkg-divert --list | grep "local diversion of"
    ls -hlv /usr/sbin/grub-mkconfig* /usr/sbin/update-grub*|grep -v "gf"
    ;;
  *)
    cat $0;

  esac

exit




More information about the ubuntu-users mailing list