1

I have booted rescue linux (init ram fs), and mounted /dev/sda1 on /mnt/sda1

/dev/sda1 is a linux partition, but /dev/sda has no mbr.

How can I install grub on mounted filesystem /mnt/sda1 ?

I tried:

mount /dev/sda1 sda1/
mount -t proc /proc proc/
mount -t sysfs sysfs sys
chroot .

but then, when i do grub-install /dev/sda, I get this error:

Installing for i386-pc platform.
grub-install: error: failed to get canonical path of `/dev/sda1'.

1 Answers1

1

Perhaps you should try one of these options.

Option 1: try to install and run boot-repair if you are able to log on to your system.

  • Open Terminal and install Boot Repair:

sudo add-apt-repository ppa:yannubuntu/boot-repair

sudo apt-get update

sudo apt-get install boot-repair

  • You can find it now on dash. Run it from there and press "recommended repair" button.
  • Restart your system and see if Grub is back to normal.

Option 2: try to restore Grub via Live CD

  • Create a bootable USB device using a flash drive with an Ubuntu image (same version of your OS).

  • Boot from it and choose "Try Ubuntu before you install it".

  • Open Terminal from your live Ubuntu desktop.

  • Mount the partition of your Ubuntu installation. If you are not
    sure about it, launch GParted (included in the Live CD) and find it
    out. It is usually a EXT4 Partition. Replace the XY with the drive
    letter, and partition number, for example: sudo mount /dev/sda1 /mnt.

    Now, follow the instructions below:

sudo mount /dev/sdXY /mnt

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

sudo chroot /mnt

  • Now install, check, and update grub. Now it's only necessary to add
    the drive letter (usually a) to replace X, for example: grub-install /dev/sda or grub-install –recheck /dev/sda.

    Follow the instructions below:

grub-install /dev/sdX

grub-install --recheck /dev/sdX

update-grub

  • Now, Grub should be back. Just exit and unmount everything:

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

Now, restart your system and see if that worked.

I've come to this answer using this post as a reference: https://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd