Search This Blog

Wednesday, November 7, 2012

HowTo: Restore an Ubuntu system with a bad kernel, broken network driver, unbootable system.

http://askubuntu.com/questions/28099/how-to-restore-a-system-after-accidentally-removing-all-kernels

When you lose a network driver, or have a bad kernel for some reason, this will get you going.

You are starting a working system, then setting up the essentials to chroot into your broken system. The kernel, drivers and things you need are borrowed from the working system. Then you can reinstall packages, until it's working again.

First boot from a Live Ubuntu DVD/USB. Select Try without installing. Open a terminal, and follow the instructions in the Link. Your mileage may vary, I'll try an example with sda1 boot, and sda2 root filesystem.

 # Mount the root filesystem to /mnt
 mount /dev/sda2 /mnt
 # Check /mnt for a root filesystem (bin var etc ...)
 ls /mnt
 # Mount the boot partition to /mnt/boot
 mount /dev/sda1 /mnt/boot
 # Check /mnt/boot for kernels, if not, figure out where they are.
 ls /mnt/boot
 # Mount the system partitions from the Host OS.
 mount --bind /proc /mnt/proc
 mount --bind /sys /mnt/sys
 mount --bind /dev /mnt/dev
 # Chroot to your linux where everything works now...
 chroot /mnt
 # now you at / in your old linux.
 # set the environment
 mount -t devpts none /dev/pts
 export HOME=/root
 export LC_ALL=C
 # Verify you have a working network
 nslookup google.com
 ping google.com

At this point you can apt-get packages and fix your system.

--- after chroot
# See what kernels you already have.
ls /boot
# See what kernels you might want.

apt-cache search linux-image
# Depending on space in /boot, install an old and new one you might like
# An old generic one in the preempt list might not appear in the regular list
apt-get install linux-image-<2 .6.32-36=".6.32-36">-generic

You can fix about anything wrong with a bad system with this!


2 comments:

  1. I can see that you are putting a lot of efforts into your blog. Keep posting the good work. Some really helpful information in there. Nice to see your site. For more information visit legal herbal empire for sale

    ReplyDelete
  2. Really appreciated the information and please keep sharing, I would like to share some information regarding online training.Maxmunus Solutions is providing the best quality of this JBOSS Technology And this online training will be very convenient for the learner.And the training will be online and very convenient for the learner.

    For Joining online training batches please feel free to call or email us.
    Email : minati@maxmunus.com
    Contact No.-+91-9066638196/91-9738075708
    website:-http://www.maxmunus.com/page/JBoss-Administration-Training

    ReplyDelete