Grub la ricostruzione

Di solito si rende necessario, almeno nel mio caso quando uso troppe installazioni di windows e linux su una macchina sola, o come in  certi rari casi quando il pinguino aggiorna il kernel e il nuovo non funziona (vedi modifica manuale del grub file) o non riconosce tutte le partizioni

editing del file di configurazione sudo nano /boot/grub/grub.cfg

fonte: http://robertbeal.com/562/rebuilding-grub2-grub-cfg-from-ubuntu-live-cd

Rebuilding Grub2 grub.cfg from Ubuntu Live CD

After installing Windows 7 the other day I lost my Grub install. Not a problem, in the past I’ve used my Super Grub Disc to repair it.

This didn’t work for me though (may be my disc is a bit dated, or maybe it doesn’t support grub 2 just yet). Instead I booted up using my Ubuntu 9.10 Live CD. I could easily re-install grub using the “grub-install” command.

  1. Open up a terminal
  2. sudo apt-get install grub-pc (install grub2 incase the live version doesn’t have it)
  3. sudo fdisk -l (Find the partition you want)
  4. sudo mount /dev/sda5 /mnt (Mount the partition)
  5. sudo grub-install --root-directory=/mnt /dev/sda

I’ve used the drive /dev/sda and partition /dev/sda5 in my example. Notice the exact spelling.

This all went ok, but I was left with a screwed up grub menu (I messed it up myself). There’s a “update-grub” command you can do from within Ubuntu, but I couldn’t actually boot in. I only had the Live CD. Hence updating it proved to be quite difficult, and there’s nothing on the Live CD to help. I eventually found a solution, these are the commands I had to run in order to regenerate it (you can copy and paste the whole lot to run them all at once).

sudo mkdir /mnt &&
sudo mount /dev/sda5 /mnt &&
sudo mount -o bind /dev /mnt/dev &&
sudo mount -o bind /proc /mnt/proc &&
sudo mount -o bind /sys /mnt/sys &&
sudo chroot /mnt bash &&
sudo update-grub &&
reboot;

Without binding the /dev and /proc it would throw an error.

All credit goes to seeker5528′s post for the above solution.

If you simply want to update grub2, and you are able to boot into linux, then you can run the command:

sudo update-grub

It will rebuild your grub config, finding all the available bootable partitions.

Lascia un commento

Effettua il login con uno di questi metodi per inviare il tuo commento:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...