Easy (enough) recovery from Debian Testing installer’s failure to install grub during setup
Went to install Debian Testing (Wheezy) on my shiny new Dell Latitude E6520, but the installer sadly choked during GRUB install:
GRUB installation failed The 'grub-pc' package failed to install into /target/. Without the GRUB boot loader, the insalled system will not boot.
This of course left me an unbootable system since it also screwed up the existing GRUB installation so I couldn't boot Ubuntu I had previously installed on another partitition.
Recovery though was easy enough and could be done with the installation media.
There's more than one way to skin this cat, but here's how I did it. Chose "Continue" upon receiving the GRUB installation failure message, then selected "Continue without boot loader" from the Debian installer main menu. Noted the partition in the notice that followed (root=/dev/sda2). Hit "Continue" or "Next" (forget which) then once installer reported that installation was finished, rebooted.
Booted to the installation disk again, but instead of "Install", chose "Advanced options" > "Rescue mode". Answered the questions, then chose the partition Debian was installed onto (in my case, "root=/dev/sda2"). Selected "Execute a shell in /dev/sda2".
This dropped me into an ugly shell (what? no autocomplete? I'm so spoiled..). Anyway, could ping debian.org, but aptitude didn't work (e.g. aptitude search couldn't find GRUB). This is because no repository was configured. Ran "nano /etc/apt/sources.list" (because I'm used to vim and get lost in vi) and added:
deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
Saved the file, now can install GRUB:
aptitude update aptitude install grub-pc
Package configuration screen asked where to install GRUB, chose "/dev/sda". Installation was successful, it generated GRUB.cfg, found the Wheezy kernel and initrd (2.6.38-2-amd64) and even found the Ubuntu installation on /dev/sda3. Great.
Upon reboot, got the lovely GRUB screen, booted into Debian, but had a very basic system. To get Gnome, ran:
tasksel install gnome-desktop --new-install
Rebooted, got the GNOME login, but keyboard and mouse didn't work. WTF? The solution was simply to hookup an external keyboard/mouse, fire up the shell, and:
rm -rf /run
And reboot once more. Nice, a working keyboard/mouse (again, what a freakin princess). Now on to installing the Nvidia driver since testing repo didn't have a recent enough driver this NVS 4200m card required. Install steps were the same as for Ubuntu.
Fortunately, Wheezy's kernel was new enough that wired Ethernet adapter worked out of the box (unlike Ubuntu 10.04 LTS Lucid).
Though unlike Ubuntu, I did have to install the nonfree firmware to get the wireless card to work (I love it how Debian seems to have a great Wiki page for every possible problem). Ubuntu of course, made it even easier because they include nonfree firmware so the card worked out of the box (this is because Ubuntu doesn't care about your freedom).