Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  TNW Apr 16 '13 at 9:48
    
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 –  Miloš Lukačka Apr 16 '13 at 10:08
    
I posted the answer assuming you're right about it. If you're stuck at some point, post it in comments. –  TNW Apr 16 '13 at 10:42
add comment

1 Answer 1

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 knew if you had), you should mount it, too. You can check if you need whether grep /boot /etc/passwd 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 -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|improve this answer
    
I have grub2.cfg in /boot directory, I can install it directly. I will try it in an hour, thanks for advice for now –  Miloš Lukačka Apr 16 '13 at 10:46
    
Yeah, the locations might be different between distributions. –  TNW Apr 16 '13 at 10:47
    
Oops, I forgot the mount point. Fixed. –  TNW Apr 16 '13 at 11:24
    
wow, I did everything, but notebook is still booting windows automatically... –  Miloš Lukačka Apr 16 '13 at 11:40
    
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.. –  Miloš Lukačka Apr 16 '13 at 11:49
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.