I have a Ubuntu 22.04 which crashes. So I want to reinstall Ubuntu to bring to back. But when I type “sudo apt update” command, it gives me a lot of errors:
Your details mention 22.04 (and end with mention of switching to 20.04?), but your pasted details are NOT from a 22.04 (or 20.04) system. Ubuntu 22.04 LTS’s codename is jammy (20.04’s is focal), where your details are from much older releases.
I tried to upgraded 20.04 to 22.04, but it crashes in the middle. When I tried to reboot, I was trapped in initramfs prompts in which keyboard does not work. All answers I can find in Internet are cliches; no use at all.
So, I first try to get out of the initramfs prompts. To that end,
I went to Walmart to buy a flash drive and made a USB Ubuntu installation disk, and boot it on the machine. Only version 24.04 works. The screen is all black if I use 22.04. Ubuntu just can’t stop making mistakes. Sigh~
Use sudo lsblk -f to figure out the disks and partitions in the machine.
Use sudo dumpe2fs /dev/my_partition | grep -i superblock to locate backup superblocks.
Use sudo e2fsck -f -b 32768 /dev/my_partition to check disk integrity.
Run the following commands to take over the control of the original Ubuntu:
sudo mount /dev/sda2 /mnt/
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
Second, reinstall kernels. Note that chroot makes myself root already, no need to use sudo: grub-install /dev/my_disk update-grub apt install --reinstall grub-common sudo apt install --reinstall linux-image-6.8.0-52-generic sudo update-initramfs -u -k 6.8.0-52-generic
Third, reboot and select the crashed Ubuntu in GRUB. I can enter the CLI of the crashed Ubuntu system, but I encountered the problem asked in this thread. To fix it:
Run ip link show to figure out the network hardware in the machine. Found that the NIC eno1 is not up.
Run sudo ip link set eno1 up to bring the interface up
Run sudo dhclient eno1 to get an IP.
Now I can run sudo apt update without problem.
Finally, reinstall the crashed Ubuntu: sudo apt-get install --reinstall ubuntu-desktop. The GUI login screen is back! There are still other problems, like can’t be accessed from other machine in the LAN. I will ask here if I can’t solve it by myself.
For what it’s worth, I don’t think your original post was very clear. There’s a lot of information in that last one that wasn’t there. Next time you do one of these, please give us all the details so we can better assist.