0

I have been working on a laptop and after the hard drive stopped working, I made an installation of Ubuntu 22.04 on an external 3TB HDD drive. The drive had about 500GB of data and I couldn't move it. I made custom partitions and install everything well. The partions are as follows:

/dev/sda1 - efi, boot partition

/dev/sda2 - NTFS with previous data

/dev/sda3 - Swap area

/dev/sda4 - root partition

/dev/sda5 - home partition

In the installation process, in the drop-down for selecting which device to install the bootloader, selecting /dev/sda would cause an OS panic but after a reinstall and selecting /dev/sda1 everything worked.

The OS worked very well until I ran sudo apt upgrade and I noticed some output about updating of initramfs(shown in the images)

Upgrade Logs 1

Upgrade Logs 2

Upgrade Logs 3

I cannot paste the logs as text since I cannot get into the system. Everything worked and I even used the laptop for over 10 hours. I shutdown the laptop and after starting it, I click Ubuntu and get

error: attempt to read or write outside of disk `hd0`.
error: you need to load the kernel first.
Press any key to continue...

Recovery mode doesn't work and trying to load the kernel from the grub menu gives the same read or write error. This is when I use all versions of vmlinuz found in /boot/. Only

linux /boot/vmlinuz.old

does not give that error. Vmlinuz, vmlinuz-6.2.0-26-generic and vmlinuz-6.5.0-28-generic all error out. When I try running initrd /boot/initrd.img after the successful vmlinuz.old command, I get the same read or write error.

How can I fix this? I cannot currently access a live cd/usb due to many challenges so any help that doesn't need one will be really helpful.

Ajay
  • 2,241
JustG
  • 1

1 Answers1

0

Can you include an image of the full boot message? There may be a grub rescue prompt. Does the grub menu come up? If so, click e when the menu comes up. If the terminal prompt comes up, follow the next steps:

  1. Run ls, the output should look something like this:
grub > ls
(hd0) (hd0, msdos9)
  1. Run ls [(location without spaces)], like the following:
grub > ls (hd0,msdos9)/
grub > ls (hd0,msdos8)/
grub > ls (hd0,msdos5)/ # Lets say this is the root location
grub > ls (hd0,msdos5)/
  1. Set root to your root partition:
grub > set root=(hd0,msdos5)
grub > set prefix=(hd0,msdos5)/boot/grub
grub > insmod normal
grub > normal
  1. Setup grub and kernal:
sudo update-grub
sudo grub-install  /dev/sda # If the drive is hd0 the equivalent is sda, if it's hd1 then use sdb
apt-cache search linux-image
sudo apt install linux-image-your_version_choice linux-headers-your_version_choice linux-modules-extra-your_version_choice

Note: inspired by This Post, please look at this thread for help. If you can boot into grub, I don't know if it's possible without an outside bootable device. Replace with your paths:

/dev/sda1 - efi, boot partition

/dev/sda2 - NTFS with previous data

/dev/sda3 - Swap area

/dev/sda4 - root partition

/dev/sda5 - home partition