我正在研究内核源代码。所以我编译了 Linux 核心内核并安装了它。之后,我从 /boot 分区中删除了所有通用内核。在主线内核应用程序上,它仍然显示 6.2.0.26.26 Ubuntu 内核已安装在我的 PC 上。但我试过sudo apt update-grub
在启动期间我找不到通用 ubuntu 内核。有没有办法恢复它?我无法使用 iso 重新安装整个 ubuntu。因为它会删除我安装的所有程序。解决方法是什么?ubuntu 不是开源的。但是有没有办法安装 ubuntu 内核并在其上启动?就像我们对 linux 内核所做的那样,编译、安装并在其上启动。
我意外地从 /boot 中删除了我的 ubuntu 内核。我安装了一些其他 linux 内核。想恢复我的 ubuntu 内核。
我已经安装了通用内核。
pegasus@pegasus:~$ sudo apt-get install --reinstall linux-image-generic
[sudo] password for pegasus:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
gdal-plugins inxi libarmadillo11 libavcodec-dev libavformat-dev libavutil-dev libboost-filesystem1.71.0 libboost-iostreams1.71.0 libboost-program-options1.71.0 libcfitsio10 libdc1394-dev
libexif-dev libexif-doc libfdk-aac2 libgdal32 libgoogle-perftools4 libgphoto2-dev libmbedtls14 libmbedx509-1 libopencv-highgui406 libopencv-imgcodecs406 libpcrecpp0v5 libqt6qml6
libqt6qmlmodels6 libqt6quick6 libqt6svg6 libqt6waylandclient6 libqt6waylandcompositor6 libqt6waylandeglclienthwintegration6 libqt6waylandeglcompositorhwintegration6
libqt6wlshellintegration6 libraw1394-dev libraw1394-tools libsrt1.5-openssl libssl1.1 libswresample-dev libtcmalloc-minimal4 libxapp-gtk3-module libxapp1 libyaml-cpp0.6 qt6-wayland
xapp-sn-watcher xapps-common
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 110 not upgraded.
Need to get 8,224 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://bd.archive.ubuntu.com/ubuntu lunar-updates/main amd64 linux-image-generic amd64 6.2.0.26.26 [8,224 B]
Fetched 8,224 B in 1s (15.1 kB/s)
(Reading database ... 289865 files and directories currently installed.)
Preparing to unpack .../linux-image-generic_6.2.0.26.26_amd64.deb ...
Unpacking linux-image-generic (6.2.0.26.26) over (6.2.0.26.26) ...
Setting up linux-image-generic (6.2.0.26.26) ...
但在 grub 上它没有显示出来。如何恢复?
pegasus@pegasus:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.5.0-rc3+
Found initrd image: /boot/initrd.img-6.5.0-rc3+
Found linux image: /boot/vmlinuz-6.4.7+
Found initrd image: /boot/initrd.img-6.4.7+
Found linux image: /boot/vmlinuz-6.4.0-rc5
Found initrd image: /boot/initrd.img-6.4.0-rc5
Found linux image: /boot/vmlinuz-6.4.0-rc4+
Found initrd image: /boot/initrd.img-6.4.0-rc4+
Found memtest86+ 64bit EFI image: /boot/memtest86+x64.efi
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme1n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
pegasus@pegasus:~$ dpkg --list | grep linux-image
ii linux-image-5.19.0-1007-nvidia-lowlatency 5.19.0-1007.7 amd64 Signed kernel image nvidia-lowlatency
rc linux-image-5.19.0-41-generic 5.19.0-41.42~22.04.1 amd64 Signed kernel image generic
rc linux-image-5.19.0-42-generic 5.19.0-42.43~22.04.1 amd64 Signed kernel image generic
rc linux-image-6.2.0-20-generic 6.2.0-20.20 amd64 Signed kernel image generic
rc linux-image-6.2.0-23-generic 6.2.0-23.23 amd64 Signed kernel image generic
rc linux-image-6.2.0-24-generic 6.2.0-24.24 amd64 Signed kernel image generic
pi linux-image-6.2.0-26-generic 6.2.0-26.26 amd64 Signed kernel image generic
ii linux-image-generic 6.2.0.26.26 amd64 Generic Linux kernel image
pi linux-image-generic-hwe-22.04 6.2.0.26.26 amd64 Generic Linux kernel image
答案1
我找到了解决办法。
下载:
amd64/linux-headers-6.4.0-060400-generic_6.4.0-060400.202306271339_amd64.deb
amd64/linux-headers-6.4.0-060400_6.4.0-060400.202306271339_all.deb
amd64/linux-image-unsigned-6.4.0-060400-generic_6.4.0-060400.202306271339_amd64.deb
amd64/linux-modules-6.4.0-060400-generic_6.4.0-060400.202306271339_amd64.deb
从https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.4/
然后使用以下方法手动安装所有 deb 包
sudo dpkg -i <package_name>.deb