GRUB rescue recovery in Multiboot

Finding myself stuck with some outdated Linux distributions on an older Toshiba tablet hybrid (without DVD or CD-ROM drive), I decided to upgrade it to a more modern and useful distribution.

IMG_20140725_211508The target computers were two Toshiba M200 laptops, which are quite old, but still very useful, as they are tablet hybrids – you can write and type on them. What sets them back is below par graphics – some old nVidia chipset, 950 or so – that are unable to handle anything over 540p well (the resolution of that small screen goes all the way up to 1400x1050 or so, but that does not translate to video) and cannot be upgraded. An additional issues with these hybrids is that even though the option to boot off a CD-ROM or USB exists in the motherboard (just press F2), in practice very few such devices are recognized by the motherboard, and at the time I had no such device handy. This is not a triumphant story – at least, not yet – but it makes sense to publish it so that it is avoided by me and anybody else in a similar situation in the future.

One way to “update” an old distro (such as Backtrack) to new (Kali) standards is to update to the new repositories via leafpad /etc/apt/sources.list :

deb-src http://security.kali.org/kali-security kali/updates main contrib non-free
deb http://http.kali.org/kali kali main non-free contrib
deb-src http://http.kali.org/kali kali main non-free contrib
deb http://http.kali.org/ /kali main contrib non-free
deb http://http.kali.org/ /wheezy main contrib non-free
deb http://http.kali.org/kali kali-dev main contrib non-free
deb-src http://http.kali.org/kali kali-dev main contrib non-free
deb http://http.kali.org/kali kali-dev main/debian-installer
deb http://http.kali.org/kali kali main/debian-installer
deb http://repo.kali.org/kali kali-bleeding-edge main

You might get lucky and doing “apt-get update && apt-get dist-upgrade” could work for you. I have tried something like that, without much luck. You may also install Kali tools in Ubuntu.

 

There are several ways to install Linux in dual boot on a computer without a DVD or CD-ROM drive:

  1. If you are installing Ubuntu, Wubi (in Windows) or Lubi (in other Linux) are helpful. It may even be possible to use the aforementioned programs to install other distros.
  2. Use Unetbootin, which comes with both Windows and Linux versions and allows the installation of predefined distros as well as any other ISO.

UNetbootin-kaliI went with the second solution, first in Windows, then in Linux. This involved:

  1. Downloading UNetBootIn from Sourceforge.
  2. Run the program as administrator (Windows) or root (Linux)
  3. Select the Linux distro of choice – previously downloaded, latest Kali in my case by clicking “Diskimage” in the lower part of the screen
  4. Choose where do you want to install the distro – choose a USB drive if your  computer can reliably boot from one, or the C: drive if it does not. This older Toshiba laptop has the option to boot from USB or CD-ROM, but it unfortunately does not work with most such devices (they are not recognized by the motherboard at boot, even though they are recognized in Windows or Linux), leaving me with no option but to install it straight to the hard drive.
  5. Unetbootin-rebootUNetbootin will install an additional boot option in the boot menu of your computer. Reboot and select it (in my case, it was right under Windows).
  6. In my case, I had downloaded the Internet install version of the ISO, i.e., the smallest minimalist ISO that relies on the Internet connection to download and install most of the OS files from the repositories. I had placed both UNetBootIn and the ISO on a USB stick. The installation went fine, but it got stuck after having downloaded everything at the “exploding archives / installing” step, with the hard disk LED on the laptop on. After about 1h it became clear that the install had stalled, so I rebooted only to find myself at the dreaded GRUB rescue prompt.
  7. Should the install have been successful (and tested), I would have booted back into the original OS and at the UNetbootin Uninistaller prompt (UNetbootin is currently installed. Remove the existing version?) I would have answered OK, uninstalling the UNetbootin boot entry.

In the end, I erased the partition and reinstalled everything from a full DVD, after finding the one USB device I could reliably connect and be recognized by the motherboard. Trying to fiddle with boot rescue went nowhere, as that procedure relies on finding the Linux partition with ‘ls’ (easily done), loading certain modules (e.g., insmod linux) and then booting up. Unfortunately, in my situation, the modules were not where they were supposed to be (not even in the “backup” location). I had no alternative but to erase everything, get my CD-ROM and reinstall.

I found the following recipe on a forum (link below) and reproduce it here for completeness, although, like its original author, I had not tested it either.

I think the way to do it is something like this (untested):

  1. Format one partition that will be your destination for the installation (I suggest you to choose the ext4 format)

  2. Copy the your files and folders from wubi to the new partition

  3. Make sure you have a folder named /boot/ with at least two files like initrd.img-2.6.38-10-genericand vmlinuz-2.6.38-10-generic

  4. Than you will have to install grub:

These instructions were adapted from: https://wiki.ubuntu.com/Grub2#Recover

"METHOD 3 - CHROOT

This method of installation uses the chroot command to gain access to the broken system's files. Once the chroot command is issued, the LiveCD (in your case the wubi installation) treats the broken system's / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.

1) Boot to the LiveCD Desktop (Ubuntu 9.10 or later) (Open Ubuntu at Wubi). Please note that the Live CD must be the same as the system you are fixing - either 32-bit or 64-bit (if not then the chroot will fail).

2) Open a terminal - Applications, Accessories, Terminal. 3) Determine your normal system partition - (the switch is a lowercase "L")

sudo fdisk -l

If you aren't sure, run

df -Th 
Look for the correct disk size and ext3 or ext4 format. 4) Mount your normal system partition:

Substitute the correct partition: sda1, sdb5, etc.

sudo mount /dev/sdXX /mnt  
# Example: sudo mount /dev/sda1 /mnt 5) Only if you have a separate boot partition: sdYY is the /boot partition designation (for example sdb3)
sudo mount /dev/sdYY /mnt/boot 

6) Mount the critical virtual filesystems:

sudo mount --bind /dev  /mnt/dev
sudo mount --bind /dev/pts  /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys  /mnt/sys 

7) Chroot into your normal system device:

sudo chroot /mnt 

8) If there is no /boot/grub/grub.cfg or it's not correct, create one using

update-grub 

9) Reinstall GRUB 2:

Substitute the correct device - sda, sdb, etc. Do not specify a partition number.

grub-install /dev/sdX 

10) Verify the install (use the correct device, for example sda. Do not specify a partition):

sudo grub-install --recheck /dev/sdX 
11) Exit chroot: CTRL-D on keyboard 12) Unmount virtual filesystems:
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys 

13) If you mounted a separate /boot partition:

sudo umount /mnt/boot 

14) Unmount the LiveCD's /usr directory:

sudo umount /mnt/usr 

15) Unmount last device:

sudo umount /mnt 

16) Reboot.

sudo reboot 
"

I will complete this article with more talk on recovery from the Grub rescue prompt soon.

Sources / More info: hf-m200boot, uf-m200ubuntu, w-h, lubi,

blog comments powered by Disqus
Your gift enables us to continue to provide high quality reporting with little or no advertising.