Saving system when it refuses to boot

14 / Aug / 2012 by avinash 0 comments

So, most of the users here around me are ubuntu users, and it’s not something uncommon that a recent upgrade broke your system and now you are just pulling your hair and cursing the time when you clicked that “Upgrade” button.

So, what is it that you can do from saving yourself in such scenarios.

Step 1. Always keep a backup of your boot folder, in cases of recovery you might need files from this folder. When to keep a backup? Well, when your system is working good, just copy that folder to somewhere “sudo cp -r    /boot       your_backup_location”

Step 2. Most of the time the failures are due to failed install of grub or invalid grub configurations.

In case of failures, try this :

2.a- Either boot through an ubuntu cd, or grab a bootable linux disk, i prefer arch-linux as it provides “arch-chroot” instead of normal chroot that i will use in following lines, benefit is that it populates your /dev nodes properly and ofcourse will save you from hassles when it complains during grub install that it can’t find device in /dev

2.b- mount your installed root partition, for eg. if your root partition in your installed system is /dev/sda1, you can

[shell]

mount /dev/sda6 /mnt

[/shell]

2.c- chroot (and ofcourse, the sweeter arch-chroot of arch linux)

[shell]

chroot /mnt

[/shell]

or if you have the arch-linux install medium

[shell]

arch-chroot /mnt

[/shell]

2.d – run grub update, in case of ubuntu it is

[shell]

update-grub

[/shell]

2.e – run grub-install (This is the scenario mostly that fixes most of the boot fails, a must in case after ubuntu upgrades)

[shell]

grub-install /dev/sda

[/shell]

(mind it, it is sda and not sdaX where X is your partition number)

And above all should really fix your system, Now some info on what I really did above, and how exactly grub works

/boot/grub/grub.cfg – this is the file that is responsible for telling grub boot loader of what to load, update-grub basically re-generates your grub.cfg file while listing all your installed OS in this file

grub-install /dev/sda – this command installs grub bootloader on your hard disk.

There is also a different scenario when you can boot but can’t get past the booting procedure as the system hanged or reported with a panic. Might be that this is due to the kernel upgrade. In such cases, you can always choose the previous version option in your boot menu list of grub. In case you can’t see such option, just boot through live cd following steps 2.a, 2.b, 2.c and

there you can see menu entries

[shell]

menuentry "Ubuntu, linux 2.6.28-14-generic" {
linux    /vmlinuz-2.6.28-14-generic root=UUID=9018bfe2-9de3-4692-9883-fc2f875e6455 ro  quiet splash
initrd    /initrd.img-2.6.28-14-generic
}

[/shell]

replace vmlinux-x.x.xx-xx and initrd.img-x.x.xx-xx with your last working vmlinuz and initrd.img version numbers. (remember? that i mentioned taking backup of boot folder, in case your precious initrd.img and vmlinuz are lost, copy it from there to your boot partition after steps 2.a,2.b,2.c

and reboot, it should load your previous kernel.

Note :

Above is the mostly found case of the system not booting, There can be other scenarios as well, but it never hurts to start looking into bootloader first. Of course above info expects you to know basics of Linux.

An excellent article on grub 2 basics can be found at following link

http://ubuntuforums.org/showthread.php?t=1195275

Oh, and there are pretty more neat ways other than above to fix the things, but then, we all ain’t typical nerds who are gonna get deep into things. You can always ask Mr. Google, he knows it all. When you’re stuck, post in forums, especially distro specific forums, people out there are really willing to help, just on a condition, that you do your part of work.

Oh and while following steps above if you broke something

As developers on xda or other places say

[shell]

/*
* I am not responsible for bleeping computers, dead Drives,
* thermonuclear war, or you getting fired because you spent too much time fixing things. Please
* do some research if you have any concerns about what i shared
* before implementing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your computer, I will laugh at you.
*
*/

[/shell]

And off course, above information is as per my experience, feel free to add info to it. I always welcome a constructive criticism

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *