Ask Your Question
2

Run grub2-mkconfig automatically after kernel upgrade?

asked 2016-03-27 06:25:38 -0500

fat-lobyte gravatar image

Hi!

My Kernel upgrades seem to work very well, and new boot menu entry is created correctly. However, instead of setting the Kernel to be booted by the "Fedora" entry (originally created by grub2-mkconfig), a new entry is created above.

This can cause quite a bit of clutter, when multiple Kernel versions are installed. grub2-mkconfig solves this quite nicely, but unfortunately it is not run on upgrade, like for example in Ubuntu.

Is there a way to run grub2-mkconfig automatically after a new Kernel is installed or one removed?

edit retag flag offensive close merge delete

Comments

I'd write a bash script that does this.

ifohancroft gravatar imageifohancroft ( 2016-03-27 08:14:13 -0500 )edit

what new entry is create above ?

sergiomb gravatar imagesergiomb ( 2016-03-28 12:10:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-03-27 13:16:24 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Due to frequent kernel updates, it is better to have previous kernels available to boot if something breaks in the new kernel. SO this method is not recommended for new users . Using crontabs you can actually get what you want but not right after an update but at intervals

     #!/bin/bash
    # This script comes with no warranty ...use at own risk 
    # This program is free software; you can redistribute it and/or modify 
    # it under the terms of the GNU General Public License as published by 
    # the Free Software Foundation; version 2 of the License. 
    # 
    # This program is distributed in the hope that it will be useful, 
    # but WITHOUT ANY WARRANTY; without even the implied warranty of 
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    # GNU General Public License for more details. 
    # 
    LOG=/var/log
    echo "--------------------------------------------------------------------------------" >> $LOG/grubby.log
    echo "`date` - YUM UPDATE STARTED" >> $LOG/grubby.log
    echo "`date` - *** CHECKING FOR YUM UPDATES ***" >> $LOG/grubby.log
    $YUM -y update yum | awk '{x="'"`date`"'"; printf "%s - %s\n",x,$0 }'  >> $LOG/grubby.log
    echo "`date` - *** CHECKING FOR SYSTEM UPDATES ***" >> $LOG/grubby.log
    $YUM -y update | awk '{x="'"`date`"'"; printf "%s - %s\n",x,$0 }' >> $LOG/grubby.log
    echo "`date` - YUM UPDATE COMPLETED" >> $LOG/grubby.log
   grub2-mkconfig -o /boot/grub2/grub.cfg | awk '{x="'"`date`"'"; printf "%s - %s\n",x,$0 }'  >> $LOG/grubby.log

Then Edit Corntab

crontab -e

Then add your script to crontab

0 20 * * * /where-did-i-put-it/script.sh

Use the below synatx to help with adding your script to crontab

*     *     *     *     *  /path/to/command.sh
-     -     -     -     -
|     |     |     |     |
|     |     |     |     +----- day of week (0 - 6) (Sunday=0)
|     |     |     +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

P.S I am not proficient in scripting, please modify if you find something wrong

edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-03-27 06:25:38 -0500

Seen: 622 times

Last updated: Mar 27 '16