Recover/Restore unbootable GRUB boot loader on Debian Testing GNU/Linux using Linux LiveCD (Debian Install CD1)

I've recently broke my grub untentianally while whiping out one of my disk partitions who was prepared to run a hackintosh.
Thus yesterday while switching on my notebook I was unpleasently surprised with an error Grub Error 17 and the boot process was hanging before it would even get to grub's OS select menu.

That was nasty and gave me a big headache, since I wasn't even sure if my partitions are still present.
What made things even worse that I haven't created any backups preliminary to prepare for an emergency!
Thus restoring my system was absolutely compulsory at any cost.
In recovering the my grub boot manager I have used as a basis of my recovery an article called How to install Grub from a live Ubuntu cd
Though the article is quite comprehensive, it's written a bit foolish, probably because it targets Ubuntu novice users :)
Another interesting article that gave me a hand during solving my issues was HOWTO: install grub with a chroot
Anyways, My first unsuccessful attempt was following a mix of the aforementioned articles and desperately trying to chroot to my mounted unbootable partition in order to be able to rewrite the grub loader in my MBR.
The error that slap me in my face during chroot was:

chroot: cannot execute /bin/sh : exec format error

Ghh Terrible … After reasoning on the shitty error I came to the conclusion that probably the livecd I'm trying to chroot to my debian linux partition is probably using a different incompatible version of glibc , if that kind of logic is true I concluded that it's most likely that the glibc on my Linux system is newer (I came to that assumption because I was booting from livecds (Elive, Live CentOS as well Sabayon Linux, which were burnt about two years ago).

To proof my guesses I decided to try using Debian testing Squeeze/Sid install cd . That is the time to mention that I'm running Debian testing/unstable under the code name (Squeeze / Sid).
I downloaded the Debian testing amd64 last built image from here burnt it to a cd on another pc.
And booted it to my notebook, I wasn't completely sure if the Install CD would have all the necessary recovery tools that I would need to rebuilt my grub but eventually it happened that the debian install cd1 has everything necessary for emergency situations like this one.

After I booted from the newly burned Debian install cd I followed the following recovery route to be able to recovery my system back to normal.It took me a while until I come with the steps described here, but I won't get into details for brevity

1. Make new dir where you intend to mount your Linux partition and mount /proc, /dev, /dev/pts filesystems and the partition itself

noah:~# mkdir /mnt/root
noah:~# mount -t ext3 /dev/sda8 /mnt/root
noah:~# mount -o bind /dev /mnt/root/dev
noah:~# mount devpts /dev/pts -t devpts

Change /dev/sda8 in the above example commands with your partition name and number.
2. chroot to the mounted partition in order to be able to use your filesystem, exactly like you normally use it when you're using your Linux partition

noah:~# chroot /mnt/root /bin/bash

Hopefully now you should be in locked in your filesystem and use your Linux non-bootable system as usual.

Being able to access your /boot/grub directory I suggest you first check that everything inside:

/boot/grub/menu.lst is well defined and there are no problems with the paths to the Linux partitions.

Next issue the following commands which will hopefully recover your broken grub boot loader.

noah:~# grub
noah:~# find /boot/grub/stage1

The second command find /boot/grub/stage1 should provide you with your partitions range e.g. it should return something like:

root (hd0,7)

Nevertheless in my case instead of the expected root (hd0,7) , I was returned

/boot/grub/stage1 not found

Useless to say this is uncool :)

As a normal reaction I tried experimenting in order to fix the mess. Logically enough I tried to reinstall grub using the

noah:~# grub-install --root-directory=/boot /dev/sda
noah:~# update-grub

To check if that would fix my grub issues I restarted my notebook. Well now grub menu appeared with some error generated by splashy
Trying to boot any of the setup Linux kernels was failing with some kind of error where the root file system was trying to be loaded from /root directory instead of the normal / because of that neither /proc /dev and /sys filesystems was unable to be mounted and the boot process was interrupting in some kind of rescue mode similar to busybox, though it was a was less flexible than a normal busybox shell.

To solve that shitty issue I once again booted with the Debian Testing (Sid / Squeeze ) Install CD1 and used the commands displayed above to mount my linux partition.

Next I reinstalled the following packages:

noah:~# apt-get update
noah:~# apt-get install --reinstall linux-image-amd64 uswsusp hibernate grub grub-common initramfs-tools

Here the grub reinstall actually required me to install the new grub generation 2 (version 2)
It was also necessary to remove the splashy

noah:~# apt-get remove splashy

As well as to grep through all my /etc/ and look for a /dev/sda6 and substitute it with my changed partition name /dev/sda8

One major thing where I substituted /dev/sda6 to my actual linux partition now with a name /dev/sda8 was in:

initramfs-tools/conf.d/resumeThe kernel reinstall and consequently (update) does offered me to substitute my normal /dev/sda* content in my /etc/fstab to some UUIDS like UUID=ba6058da-37f8-4065-854b-e3d0a874fb4e

Including this UUIDs and restarting now rendered my system completely unbootable … So I booted once again from the debian install cd .. arrgh :) and removed the UUID new included lines in /etc/fstab and left the good old declarations.
After rebooting the system now my system booted once again! Hooray! All my data and everything is completely intact now Thanks God! :)

Share this on

Download PDFDownload PDF

Tags: , , , , , , , , , , , , , , , , , , , ,

15 Responses to “Recover/Restore unbootable GRUB boot loader on Debian Testing GNU/Linux using Linux LiveCD (Debian Install CD1)”

  1. [...] Thus yesterday while switching on my notebook I was unpleasently surprised with an error Grub Error 17 and the boot process was hanging before it would even get to grub’s OS select menu More here [...]

  2. [...] Recover/Restore unbootable GRUB boot loader on Debian Testing GNU … [...]

  3. baby nail clippers says:

    I just required to say that I discovered your weblog via Goolge and I am glad I did. Carry on the excellent work and I will make sure to bookmark you for when I have much more free of charge time away from the books. Thanks!

  4. Jayna Garroutte says:

    Numerous with thanks for revealing this fantastic post. Please retain up this webpage as it’s one of my favored website in my reader, thank you .)

  5. Jennette says:

    Intimately, the post is actually the greatest on this valuable topic. I fit in with your conclusions and will thirstily look forward to your coming updates. Saying thanks will not just be enough, for the great lucidity in your writing. I will right away grab your rss feed to stay privy of any updates. Admirable work and much success in your business enterprize!

  6. Babinnes says:

    Good day, Will you be making a follow-up write-up? My hubby and myself have passed some time browsing over your web pages and interestingly you discussed a little something i was talking about only the other week with our daughter. We quite often hear ourselves arguing about the littlest of points, isn’t it childish?

  7. Tyron Princevalle says:

    How long have you had this blog of yours? We really like your blog.

  8. Athena Chestnutt says:

    Fantastic post, thanks. Your blog just got a new permanent visitor.

  9. Mozell Corgiat says:

    Thanks for sharing this with us. I’ve quite appreciated the experience of reading your blog so far. Maybe some cliff notes at the end would be a useful addition to summarize the points… Anyway I will be visiting back here so keep up the fantastic writing, your readers appreciate it.

  10. George Willison says:

    Wow, great blog post.Really thank you! Much obliged.

  11. Mariano Ahal says:

    I got what you mean, thank you for posting. Woh I am happy to find this website through google.

  12. dietas para bajar de peso says:

    Hmm it appears like your website ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I too am an aspiring blog writer but I’m still new to everything. Do you have any helpful hints for beginner blog writers? I’d certainly appreciate it.

    • admin Mozilla Firefox Windows says:

      No hints, you just need experience in writting. The more you write the better you become. Also try to be yourself. Always being yourself is the best thing we can do.


  13. Angel says:

    What a wonderful description! I have no clue how you came up with this’d take me weeks. Well worth it though, I’d assume. Have you considered selling advertising space on your website?

  14. Oertel says:

    I have read a few just right stuff here. Certainly value bookmarking for revisiting. I surprise how a lot effort you place to make such a great informative website.

Leave a Reply