Score:0

I had accidentally deleted the ubuntu kernel. How to regain it?

us flag

I am working on the kernel source code. So I compiled the linux core kernel and installed it. After that I removed all the generic kernels from the /boot partition. On the mainline kernel app it still shows the 6.2.0.26.26 Ubuntu kernel is installed on my pc. But I had tried sudo apt update-grub During boot I can't find the generic ubuntu kernel. Is there anyway to regain that? I can't reinstall whole ubuntu using iso. Cause it will delete all my installed programs. What is the fix? ubuntu is not open source. But is there anyways to install the ubuntu kernel and boot on it? Like we do with linux kernel, compile, install, and boot on it.

I have accidentally deleted my ubuntu kernel from /boot. I have some other linux kernels installed. Wanna restore my ubuntu kernel.

I have installed the generic kernel.

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) ...

But on grub it's not showing up. How to restore it?

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
oldfred avatar
cn flag
You always need good backups. Rule is if it takes more than an hour to fix, best to reinstall & restore from backups. You can use choot or Boot-Repair. With Boot-Repair you can use its advanced mode to choose to totally reinstall grub & install latest kernel. https://help.ubuntu.com/community/Boot-Repair & https://sourceforge.net/p/boot-repair/home/Home/ UEFI chroot, must include ESP - efi system partition http://askubuntu.com/questions/53578/can-i-install-in-uefi-mode-with-the-alternate-installer/57380#57380
zeshanahmed nabin avatar
us flag
I have a dual booted pc with two ssds. One is 1TB. Ubuntu takes 750 MB. And the root SSD is 512 GB. The root one and 250 MB goes to windows. Grub is installed on the root SSD. https://sourceforge.net/p/boot-repair/home/Home/ I hope following this link won't mess things up more for me
oldfred avatar
cn flag
Again good backups allow us to make mistakes & easily recovery. (I have needed backups multiple times.) But if you make correct choice in Boot-Repair booted in correct mode UEFI for most systems now, it will reinstall grub & kernel. If Ubuntu only on second drive, I prefer a second ESP on that drive, even though Ubuntu default uses first drive's ESP. You can edit fstab with new UUID & reinstall grub to use second ESP, if desired.
zeshanahmed nabin avatar
us flag
I ran the tool. But my default ubuntu kernel didn't came back
Score:0
us flag

I had found a fix.

downloaded:

  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

From https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.4/

Then manually installed all of the deb packages using sudo dpkg -i <package_name>.deb

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.