如何在内核更新后自动更新 burg

如何在内核更新后自动更新 burg

每次内核更新后我都必须update-burg手动运行。如何让它自动运行?

答案1

另一种方法是编辑/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

从:https://bugs.launchpad.net/burg/+bug/594431(错误报告与您的经历相似)

这同样可以通过更新来消除,但因为它在/etc/你体内应该(我认为)当更新发生时,会提示保留现有配置。

正如 bug 中人们所说的那样,这仍然不是理想的,因为很有可能有人想要同时运行 burg 和 grub,或者至少让两者保持同步。

您可以更进一步,编写如下新脚本:

#!/bin/sh
set -e
exec update-grub "$@"
exec update-burg "$@"

将其另存为/usr/sbin/update-bootloaderschmod +x它,然后粘贴update-bootloaders在或 的/etc/kernel-img.conf位置。update-grubupdate-burg

我猜想从长远来看,alternatives需要为各种引导加载程序建立一个系统,就像 Java、音频和其他可互换子系统一样。

答案2

通常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-grub实际的update-burg

虽然有点黑客,但是应该可以工作。

扭转:

cd /usr/sbin/
sudo rm update-grub # this is only a symlink
sudo mv update-grub.backup update-grub

答案3

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

另存为文本文件升级文件并将其标记为可执行。此脚本将执行所有可能的更新,检查内核列表是否已更改,并在更改后更新 burg。我从 10.04 版开始使用它(绑定到别名),到目前为止,没有更新破坏它。

但是,如果您喜欢通过突触手动进行更新,那么 Oli 的方法可能会更好。

答案4

谢谢!

我根据此处提供的最有帮助/评价最高的信息创建了一个脚本。一个细微的变化是,引导加载程序可执行文件不再执行(就像 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

相关内容