Recently I had a problem with a computer, I was trying to install the nvidia drivers on a computer and I mistakenly removed my kernel from the system. After this I couldn’t boot the computer.
The idea here is to take a live USB and use it to execute commands on an offline system. This is possible through chroot, which allows to execute statements as if we would be on the offline computer (ish). It can use distribution tools like zypper, yum, apt-get, etc and do all the recovery that is needed.
Download your favourite live CD/USB, I will be using the GNOME Live CD (en.opensuse.org) with openSUSE. This is what I’m used to use.
Burn it on a USB. Use your favourite tool, I won’t be going much into this since I usually have problems with this. A few picks are Rufus (rufus.akeo.ie), UNetbootin (unetbootin.github.io), SUSE Studio Image Writer (en.opensuse.org) depending on your available OS.
Determine the partition that you want to mount. You can do this by opening “files” (nautilus), click on “+ Other Locations” and view the partition that interests you. If you mount the partition with nautilus don’t forget to unmount it before continuing. Look the image below for reference, you would be looking for something like /deb/sdXY.
After you have located the partition that you want to mount, in this case /dev/sda5, open a terminal and type (thanks to stackoverflow: How do I run update-grub from a LiveCD? [askubuntu.com]):
> sudo mount /dev/sda5 /mnt > sudo mount --bind /dev /mnt/dev > sudo mount --bind /sys /mnt/sys > sudo mount --bind /proc /mnt/proc > sudo chroot /mnt
Congratulations, now you have access to the offline system.
You can do all nifty things as:
> sudo zypper ref > sudo zypper up -y
> sudo apt-get update > sudo apt-get upgrade
or anything else you might want to. To exit press ctrl + d.
When done, unmount the mounted partitions:
> sudo umount /mnt/dev > sudo umount /mnt/sys > sudo umount /mnt/proc > sudo umount /mnt/
PS. If you try to ping a domain name and you get a error such as:
> ping www.google.com ping: www.google.com: Name or service not known
but you can ping IP addresses i.e.:
> ping 22.214.171.124 PING 126.96.36.199 (188.8.131.52) 56(84) bytes of data. 64 bytes from 184.108.40.206: icmp_seq=1 ttl=55 time=5.24 ms
You need to add a DNS server in /etc/resolv.conf as shown here:
> sudo bash -c "echo nameserver 220.127.116.11 >> /etc/resolv.conf"
Enjoy till the next time