所有 Linux 都应自带vmlinuz
“ /
”,以及“ /boot/
”。但是,我的系统没有它:
% ls -l /vmlinuz* /initrd* /boot/vmlinuz*
ls: cannot access '/vmlinuz*': No such file or directory
ls: cannot access '/initrd*': No such file or directory
ls: cannot access '/boot/vmlinuz*': No such file or directory
我怎样才能把这三个都找回来?
我试过,
apt-get install --reinstall linux-image-generic linux-headers-generic
update-initramfs -u
根据我读过的文章,这应该已经解决了该问题,因为实际的软件包也被重新安装了:
% apt-get install --reinstall linux-image-generic linux-headers-generic
Preparing to unpack .../linux-headers-generic_4.15.0.20.23_amd64.deb ...
Unpacking linux-headers-generic (4.15.0.20.23) over (4.15.0.20.23) ...
Preparing to unpack .../linux-image-generic_4.15.0.20.23_amd64.deb ...
Unpacking linux-image-generic (4.15.0.20.23) over (4.15.0.20.23) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Processing triggers for systemd (237-3ubuntu10) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up linux-image-generic (4.15.0.20.23) ...
Setting up linux-headers-generic (4.15.0.20.23) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10) ...
但之后我仍然缺少上述三个文件。
答案1
apt-get install --reinstall linux-image-generic
将仅重新安装一个不包含实际内核代码的空包,但仅存在于它所拉取的依赖项中。
为了恢复丢失的文件,应该(重新)安装的/boot
是当前被指向为依赖项的包linux-image-通用.今天就是Linux-映像-4.15.0-20-通用。 所以:
apt-get install --reinstall linux-image-4.15.0-20-generic
应该会使丢失的文件(重新)出现。实际上它只包含最需要的文件:/boot/vmlinuz-4.15.0-20-generic
。同时重新安装其依赖项Linux 模块-4.15.0-20-通用将恢复其他一些丢失的文件/boot
(根据列表):
/boot/System.map-4.15.0-20-generic
/boot/abi-4.15.0-20-generic
/boot/config-4.15.0-20-generic
/boot/retpoline-4.15.0-20-generic
答案2
显然apt-get install --reinstall
没有帮助,所以我首先将它们全部删除,然后再次安装它们:
apt-get --purge remove linux-headers-4.15.0-20 linux-headers-4.15.0-20-generic linux-image-4.15.0-20-generic
apt-get install linux-image-generic linux-headers-generic
% ls -l /vmlinuz* /initrd* /boot/vmlinuz* /boot/initrd*
-rw-r--r-- 1 root root 57592934 Apr 28 16:55 /boot/initrd.img-4.15.0-20-generic
-rw------- 1 root root 8249080 Apr 24 04:42 /boot/vmlinuz-4.15.0-20-generic
lrwxrwxrwx 1 root root 33 Apr 28 16:54 /initrd.img -> boot/initrd.img-4.15.0-20-generic
lrwxrwxrwx 1 root root 33 Apr 28 16:54 /initrd.img.old -> boot/initrd.img-4.15.0-20-generic
lrwxrwxrwx 1 root root 30 Apr 28 16:54 /vmlinuz -> boot/vmlinuz-4.15.0-20-generic
lrwxrwxrwx 1 root root 30 Apr 28 16:54 /vmlinuz.old -> boot/vmlinuz-4.15.0-20-generic
或许这太过严厉,但由于apt-get install --reinstall
行不通,我想不出更好的办法。
答案3
我通过启动 live cd、安装映像和标头并复制丢失的文件解决了此问题。如果是相同的内核,您也可以直接从 cd 复制文件。请注意通过以下方式重新创建 initrd.img:,update-initramfs -c -k [version]
不要复制 live-cd 版本。