每次内核更新后,我都必须手动运行
update-burg
。如何让它自动运行?/etc/kernel-img.conf
文件。do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = no
postinst_hook = update-burg
postrm_hook = update-burg
#!/bin/sh
set -e
exec update-grub "$@"
exec update-burg "$@"
/usr/sbin/update-bootloaders
,对其进行chmod +x
操作,然后将update-bootloaders
放入/etc/kernel-img.conf
中,替换update-grub
或update-burg
。alternatives
系统,用于各种引导加载程序。update-grub
。这只是一个发生的事情。系统期望grub成为引导加载程序。假设您将永远不再使用grub,您可以这样做:cd /usr/sbin/
sudo mv update-grub update-grub.backup
sudo ln -s update-burg update-grub
update-grub
移出路径,并在其位置创建一个符号链接,实际上运行的是update-burg
。因此,当安装新内核时,它将调用实际上是update-burg
的update-grub
。cd /usr/sbin/
sudo rm update-grub # this is only a symlink
sudo mv update-grub.backup update-grub
sudo apt-get upgrade
来更新软件包和内核,下面的脚本将解决您的问题,并且100%适用于更新:#!/bin/bash
# Check what kernels are installed.
KERLST=`ls /boot | grep vmlinu`
# Do updates.
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
# Update burg if kernels changed.
if [ "$KERLST" != "`ls /boot | grep vmlinu`" ]; then
sudo update-burg
fi
aupgrade
运行,只需将其放在~/bin
目录下(并删除.sh扩展名)。 - Oli谢谢!
我根据这里提供的最有帮助/最高评级的信息创建了一个脚本。一个微小的变化是引导加载程序可执行文件不再被执行(例如,对于grub,它会退出;因此脚本也会退出,其他加载程序不会被执行(@Ubuntu11))。
该脚本可以配置多个引导加载程序..(如果可执行文件是update-name
并且位于/usr/sbin
中;-)。
它可以扩展以允许非update-name
的更新可执行文件。为此,可以在引导加载程序配置变量中使用name:exec
作为值,并拆分该变量,然后相应地更改执行命令(可能需要使用不同的语言来使其优雅)。
#!/bin/sh
# #################################################################
#
# Updates (multiple) bootloaders after kernel update.
#
# @shell bash
# @see http://askubuntu.com/questions/4905/how-to-automatically-update-burg-after-a-kernel-update
#
# #################################################################
#
# Install:
#
# -----------------------------------------------------------------
# * Save as: /usr/sbin/update-bootloaders
# * Then: chmod +x /usr/sbin/update-bootloaders
# * Edit /etc/kernel-img.conf and append/replace the following parameters:
# ** postinst_hook = update-bootloaders
# ** postrm_hook = update-bootloaders
#
# #################################################################
#
# Configuration:
#
# -----------------------------------------------------------------
# BOOTLOADERS: configuration variable to list bootloaders
BOOTLOADERS="grub burg"
#
# #################################################################
set -e
for BOOTLOADER in ${BOOTLOADERS}; do
EXEC="/usr/sbin/update-${BOOTLOADER}"
if [ -x ${EXEC} ]; then
echo "Updating ${BOOTLOADER}..."
${EXEC} "$@"
fi
done
# eof