如何重新运行引导加载程序?


150

跑步sudo apt-get -f installThe link /vmlinuz.old is a damaged link

you may need to re-run your boot loader[grub]

这是完整的输出:

user@chrubuntu:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
  linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
user@chrubuntu:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
  linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 270 MB disk space will be freed.
Do you want to continue? [Y/n] y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en
en",
    LC_ALL = (unset),
    LC_TIME = "en",
    LC_MONETARY = "en",
    LC_ADDRESS = "en",
    LC_TELEPHONE = "en",
    LC_NAME = "en",
    LC_MEASUREMENT = "en",
    LC_IDENTIFICATION = "en",
    LC_NUMERIC = "en",
    LC_PAPER = "en",
    LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 232120 files and directories currently installed.)
Removing linux-headers-3.13.0-32-generic (3.13.0-32.57) ...
Removing linux-headers-3.13.0-32 (3.13.0-32.57) ...
Removing linux-image-extra-3.13.0-32-generic (3.13.0-32.57) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-32-generic /boot/vmlinuz-3.13.0-32-generic
update-initramfs: Deleting /boot/initrd.img-3.13.0-32-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-32-generic /boot/vmlinuz-3.13.0-32-generic
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old 
 you may need to re-run your boot loader[grub]
Removing linux-image-3.13.0-32-generic (3.13.0-32.57) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-32-generic /boot/vmlinuz-3.13.0-32-generic
update-initramfs: Deleting /boot/initrd.img-3.13.0-32-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-32-generic /boot/vmlinuz-3.13.0-32-generic
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old 
 you may need to re-run your boot loader[grub]
user@chrubuntu:~$

如何重新运行引导加载程序?


2
使用时会遇到相同的问题apt-get autoremove,但是正如Eliah Kagan在他的回答中所说,grub在重新启动后似乎可以正常工作。
Mark Mikofski 2015年

Answers:


189

根据womble对内核卸载后(在Server Fault上损坏的/ vmlinuz和/initrd.img符号链接的回答,在这种情况下,当引导加载程序为GRUB / GRUB2时,您无需执行任何操作,也就是这里。

对于某些其他引导加载程序(至少是LILO),显然有时有时需要手动运行引导加载程序的配置。

如果确实需要告诉GRUB检查现有内核并更新其配置,则运行即可sudo update-grub。运行该命令没有任何危害。但这在这种情况下不是必须的。


好吧,我让他们
TevinYoungz 2014年

3
@TevinYoungz很好。sudo update-grub不应造成任何伤害。
Eliah Kagan 2014年

5
“有时”一词是轻描淡写的。
Simon Richter 2014年

9
考虑到这对错误和解决方案可能会因最愚蠢的设计错误而获奖:拥有一个名为grub的命令,update-grub而不是grub-update逻辑上的命令,并且无法指定在99.99%的情况下有效的修复(命令)。
索林

@sorin我想知道在某个地方有什么错误报告。
Mateusz

31

对于grub,该错误有些奇怪。

当apt安装新的内核版本时,会将/ vmlinuz和/initrd.img移​​至/vmlinuz.old和/initrd.img.old(随后仍指向当前活动的内核。同样,请注意.old扩展名,与“内核卸载后损坏的链接”中链接的故事不同),并创建了两个新文件/ vmlinuz /initrd.img。

当您运行时apt-get autoremove(消息不是由生成的apt-get -f install),它将删除先前处于活动状态的内核(您在安装后重新启动,然后运行自动删除,对吗?),这使链接无效。

完成内核本身的删除后,autoremove本身将调用update-grub:

run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-32-generic /boot/vmlinuz-3.13.0-32-generic

因此:

The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old 
 you may need to re-run your boot loader[grub]

因此,autoremove可以:

  1. 删除旧内核
  2. 运行update-grub
  3. update-grub删除链接到已删除文件的.old文件。

完全不用担心 :-)

问候。


2
如果上次dist升级后没有重新启动怎么办?那呢 我从不重启。那是给新手的。
埃文·卡罗尔

2
除非重新启动,否则无法将新内核放入内存。
simpleuser

另外,在重新引导之前,请注意是否已将/vmlinuz&& /initrd.img链接到内核区域(通常是/ boot)。作为答案,“。old”文件的“损坏的链接”没什么好担心的。投票^
bshea '16

12

$ sudo update-grub

如果您想删除/清除旧软件包,也可以

$ dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge


如果只有3.X图像,则删除所有内容,对吗?
HarkályGergő

从技术上讲,您的第一个命令将回答问题。没有理由添加更多有关pkg维护的信息。
bshea '16
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.