Chroot in to reinstall Grub2 reinstall, mnt/ is empty

28,977

First thing to do is to ensure you are able to use the Internet in your mode, as you might need it in case that your installed system doesn't contain grub. Typical way for wired connection is to list your interfaces:

ifconfig -a

choose one that connects you to the Internet (you should be able to tell, it's probably named eth0 or em0) and run dclient on it like this:

dhclient eth0&

Next thing to do is to mount your partition that contains your installed Fedora. Make a mount point for your partition and mount it there:

mkdir /mnt/fedora
mount /dev/mapper/fedora-root /mnt/fedora

If you have a boot partition (you'd know if you had), you should mount it, too. You can check if you need whether grep /boot /etc/fstab gives you any output. If it gives something like /dev/sda1 as a first column, you should do:

mount /dev/sda1 /mnt/fedora/boot

Then bind some important directories - go to /mnt/fedora first, to not overtype:

cd /mnt/fedora
mount -o bind /dev dev
mount -o bind /proc proc
mount -o bind /sys sys
mount -o bind /run /run
mount -t tmpfs tmpfs tmp

And finally chroot:

chroot /mnt/fedora

Now you should check your /boot directory contents. Does it have some files named vmlinuz, initrd, grub directory with grub.cfg in it? If so, good, you can just install grub - assuming your drive you want it to install to being /dev/sda it would be:

grub-install /dev/sda

If it doesn't work, you'll have to install GRUB using yum install grub (I don't know the exact package name, though). If you don't have grub.cfg file, then run:

grub-mkconfig -o /boot/grub/grub.cfg

You might install GRUB again for being sure.

Share:
28,977

Related videos on Youtube

M.Koptak
Author by

M.Koptak

Updated on September 18, 2022

Comments

  • M.Koptak
    M.Koptak over 1 year

    I have a common problem: I installed Fedora 18 on my PC that has Windows on it. When I start the PC I don't get asked which system I want to boot, Windows is chosen always.

    So I found out that I have to reinstall Grub2. So I booted from a Live CD and entered rescue mode (hit e in Grub2 and added single to the line that begins with "linux..").

    Then I should do chroot /mnt/sysimage, but there is no such directory. When I do cd mnt and ls, it is empty. So I have no idea how to change root. When I do fdisk -l, the Fedora instalation is in partition /dev/mapper/fedora-root.

    How can I correctly chroot into the Fedora installation and reinstall Grub2?

    • TNW
      TNW about 11 years
      Rescue mode cuts off some of the starting scripts, thus that might be the reason your /mnt/sysimage doesn't exist. Are you sure that /dev/mapper/fedora-root is your installation? It rather sounds like the root of Live CD to me.
    • M.Koptak
      M.Koptak about 11 years
      any idea what to add, to fix mounting /mnt/sysimage? it is, I remember selecting 40GB partition when I installed fedora into HD. When i do 'fdisk -l', 40GB partition is named /dev/mapper/fedora-root
    • TNW
      TNW about 11 years
      I posted the answer assuming you're right about it. If you're stuck at some point, post it in comments.
  • M.Koptak
    M.Koptak about 11 years
    I have grub2.cfg in /boot directory, I can install it directly. I will try it in an hour, thanks for advice for now
  • TNW
    TNW about 11 years
    Yeah, the locations might be different between distributions.
  • TNW
    TNW about 11 years
    Oops, I forgot the mount point. Fixed.
  • M.Koptak
    M.Koptak about 11 years
    wow, I did everything, but notebook is still booting windows automatically...
  • M.Koptak
    M.Koptak about 11 years
    when i do grub2-mkconfig -o /boot/grub2/grub2.cfg I get following: Generating grub.cfg ... (sda4) can't find ext4 filesystem (sda4) can't find ext4 filesystem (sda4) can't find ext4 filesystem can't find a SQUASHFS superblock on sda4 (sda4) bogus member of reserved sectors (sda4) bogus member of reserved sectors found windows recovery enviroment (loader) on /dev/sda2 done and when I reboot, windows is booted automatically again..
  • M.Koptak
    M.Koptak about 11 years
    when I do ls /boot before I reboot after finishing everything, there are: EFI grub2
  • M.Koptak
    M.Koptak about 11 years
    maybe that's the problem, because when I go to bios, i can choose only LEGACY and UEFI at boot options, but fedora seems to be EFI, it is the problem?
  • TNW
    TNW about 11 years
    It could work with legacy setting, but I'm not sure for UEFI, I don't have much experience with it. Have you partitioned your drive as GPT one?
  • M.Koptak
    M.Koptak about 11 years
    now I will try this guide: superuser.com/questions/549514/…