[ Пред. ] [ Содержание ] [ След. ]

Восстановить grub2

[ @console @update @grub ]

 


*todo переписать внятно — grub2


Mount the partition your Ubuntu Installation is on. If you are not sure which it is, launch GParted (included in the Live CD) and find out. It is usually a EXT4 Partition. Replace the XY with the drive letter, and partition number, for example:

sudo mount /dev/sda1 /mnt.
sudo mount /dev/sdXY /mnt


Now bind the directories that grub needs access to to detect other operating systems, like so.

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


Now we jump into that using chroot.


Now install, check, and update grub.


This time you only need to add the drive letter (usually a) to replace X, for example:

grub-install /dev/sda, grub-install –recheck /dev/sda.
grub-install /dev/sdX
grub-install --recheck /dev/sdX


Now grub is back, all that is left is to exit the chrooted system and unmount everything.

exit &&
sudo umount /mnt/sys &&
sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts &&
sudo umount /mnt/dev &&
sudo umount /mnt


Shut down and turn your computer back on, and you will be met with the default Grub2 screen.


You may want to update grub or re-install burg however you like it.


Congratulations, you have just Repaired/Restored/Reinstalled Grub 2 with a Ubuntu Live CD!


ВТОРОЙ ВАРИАНТ


I) Let’s find where Ubuntu is installed on your hard disk:


sudo fdisk -l


Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20972826 83 Linux
/dev/sda2 2612 60279 463218210 83 Linux
/dev/sda3 60280 60801 4192965 82 Linux swap / Solaris


My ubuntu partition is /dev/sda1 (it has the asterisk under Boot).


II) Armed with this information, mount the Ubuntu partition:


sudo mount /dev/sda1 /mnt


III) Install the GRUB2 boot loader:


sudo grub-install --root-directory=/mnt /dev/sda


That’s /dev/sda — the hard disk itself, not the ubuntu partition – /dev/sda1.


IV) Unmount the Ubuntu partition and restart the computer like so:


sudo umount /dev/sda1 ; sudo reboot


V) If you have more than one OS installed, re-detect OSes like so:


sudo update-grub