Kotkamaa hacklab‎ > ‎

Debian Jessie GRUB2 fix with Live DVD

I am in love. After I found out serious problems in Ubuntu 14.04 when hacking with Pronterface, I started searching for the distro where whole the open 3D printing toolchain would work out of the box. And that is Jessie.

The standard problem is co-existing with Windows. Luckily there is a solution once I have the right tools, namely The Debian Live DVD. I had big help in this from Shaun Mallette, thanks!

Booting from Live DVD and using Gparted I made room for Windows. After installing Win7Pro standard install, I had to deal with the fact that W7 has wiped my MBR and GRUB2 boot was gone. Time to boot with the  Debian Wheezy Live DVD again. Then open the Terminal.

First find out about the partitions.

sudo fdisk -l

I have only one disk so that is /dev/sda and I learned that the Linux-formatted partition is /dev/sda4. That is what counts now. Then it is time to mount the necessary things:

sudo mount /dev/sda4 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc

sudo mount --bind /sys /mnt/sys

Shaun did not mention the fourth line, which is necessary for the GRUB2 to re-find the boot entries. I found it by reading the error message :-)
Next let us chroot :

sudo chroot /mnt

From now on sudo is not necessary, I am the Root. Then it is time to reconfigure GRUB2:


The following lines indicate that all the necessary partitions are located by GRUB. The only thing left here is to write the GRUB to the MBR of my disk:

grub-install /dev/sda

That's it. Now leave the chroot environment:


and reboot the system. The GRUB2 wakes up nicely and gives the first option as Debian as desired. If for some reason I wanted to change the boot order to, say, make the W7 be the default, I had to edit the GRUB2 configuration file. Once in chroot and updated GRUB, edit the configuration file with for example Nano:

nano -w /etc/default/grub

The same applies when modifying timeouts, defaults etc.later, too. The changes get written to the MBR by

grub-install /dev/sda

These need root privileges, of course. So add sudo or use root terminal.