Question:
There was Linux Mint and Windows 7.
Windows flew off.
Reinstalled Windows and wiped out grub. Is it possible to restore the boot sector for linux without reinstalling?
Answer:
You need to boot from the LiveCD , then mount the root partition of the installed Linux system, for example, in the /mnt
folder.
Become a superuser
$ sudo su
Find out what partitions and file systems Linux saw
# fdisk -l /dev/sda
# blkid
# lsblk
Mounting the root
# mount /dev/sda3 /mnt
Where sda3
is the root filesystem partition of the installed Linux.
If the contents of / boot were located on a separate partition from the root filesystem, it must be mounted as well. But in the beginning, of course, the root is always mounted, after that the file system with boot
in /mnt/boot
It is necessary if, after mounting the root, the / boot directory of the installed system is empty.
An example of mounting / boot.
# mount /dev/sda4 /mnt/boot/
Then mount virtual filesystems
# mount --bind /dev /mnt/dev
# mount --bind /dev/pts /mnt/dev/pts
# mount --bind /proc /mnt/proc
# mount --bind /dev /mnt/dev
# mount --bind /sys /mnt/sys
Change the current root
# chroot /mnt
You will find yourself already in your old system, after that execute
# grub-install
# update-grub2
Exit the root of the installed system
# exit
The first command will install the stage1 grub2
in the MBR, the second will update the boot list – it will search for systems and add them to the boot menu.
Next, you need to unmount all file systems in reverse order.
# umount /mnt/sys
# umount /mnt/dev
# umount /mnt/proc
# umount /mnt/dev/pts
# umount /mnt/dev
# umount /mnt/
Then turn off your computer. Turn on. Install boot from hard drive.
# reboot