Recover (recreate) grub loader on Fedora 20 linux with LVM2 partition
How to recreate grub loader on linux placed at LVM2 volume??
How to repair linux loader and write it again to disk?
I re-installed Windows 7 on disk where exists my home linux installation – Fedora 20 .
After windows reinstall process linux bootloader are removed.
Of course all partition arrangement are not touched – they are stored, none of them are destroyed – just linux now are hidden…
Linux loader (grub) has been removed during Windows install.
To repair my linux and recreate a grub i used a live fedora 20, run from usb stick because my motherboard don’t have a IDE cable – i have a converter USB-2-DVD but, anyway, my dvd drive are broken and mostly don’t work correctly.
Process to create bootable pendrive with linux i described here: make a bootable linux pendrive
Of course you can boot any live-linux distro from CD / DVD drive if you have one…
Upper you see partitions layout.
When i install Windows on /dev/sda1, linux bootloader has been destroyed.
On /deb/sda7 i have /boot partition
On /dev/sda8 i have lvm2 partition (root + swap)
Time to repair this…
003. Bootloader recovery process – linux with LVM2 partition
- Scan for volumes
# pvscan PV /dev/sda8 VG fedora lvm2 [19.68 GiB / 0 free] Total: 1 [19.68 GiB] / in use: 1 [19.68 GiB] / in no VG: 0 [0 ]
– one lv2 volume found
- Scan for volume groups
# vgscan Reading all physical volumes. This may take a while... Found volume group "fedora" using metadata type lvm2
- – one volume group named “fedora” found.
- Activate volume groups
# vgchange -ay 2 logical volume(s) in volume group "fedora" now active
- 2 logical volumes from fedora group activated.
- Preparation for chroot – i make catalog where i will mount all
# mkdir /mnt/fedora
- My volume group have 2 logical volumes (root + swap). I mount my root at previously created catalog.
# mount /dev/mapper/fedora-root /mnt/fedora
- Try to list directory content
# ll /mnt/fedora/ total 84 lrwxrwxrwx. 1 root root 7 May 13 2014 bin -> usr/bin drwxr-xr-x. 3 root root 4096 Nov 16 19:14 boot drwxr-xr-x. 2 root root 4096 Nov 16 19:13 dev drwxr-xr-x. 149 root root 12288 Nov 8 10:02 etc drwxr-xr-x. 3 root root 4096 May 13 2014 home lrwxrwxrwx. 1 root root 7 May 13 2014 lib -> usr/lib lrwxrwxrwx. 1 root root 9 May 13 2014 lib64 -> usr/lib64 drwx------. 2 root root 16384 May 13 2014 lost+found drwxr-xr-x. 11 root root 4096 Sep 17 12:25 media drwxr-xr-x. 4 root root 4096 Nov 16 19:16 mnt drwxr-xr-x. 2 root root 4096 Aug 7 2013 opt drwxr-xr-x. 2 root root 4096 May 13 2014 proc dr-xr-x---. 23 root root 4096 Nov 8 10:27 root drwxr-xr-x. 3 root root 4096 Nov 16 19:18 run lrwxrwxrwx. 1 root root 8 May 13 2014 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Aug 7 2013 srv drwxr-xr-x. 2 root root 4096 May 13 2014 sys drwxrwxrwt. 3 root root 4096 Nov 16 19:14 tmp drwxr-xr-x. 13 root root 4096 May 20 16:38 usr drwxr-xr-x. 20 root root 4096 Nov 8 07:18 var
- change directory to previously mounted root
# cd /mnt/fedora/
- mount main linux directories to mounted partition
# for i in dev proc run sys tmp > do > mount --rbind /$i $i > done
- chroot system to mounted directory
# chroot /mnt/fedora
- mount all from fstab placed on mounted linux partition
# mount -a
- You can skip this part – i made a copy for grub config on my windows partition (only real admins don’t make a backups!)
# mkdir /media/test2 # mount /dev/sda1 /media/test2 # cp /boot/grub2/grub.cfg /media/test2/
Here are my old grub config, you can look… grub.cfg
- create new grub-config
# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.15.10-200.fc20.x86_64 Found initrd image: /boot/initramfs-3.15.10-200.fc20.x86_64.img Found linux image: /boot/vmlinuz-3.14.9-200.fc20.x86_64 Found initrd image: /boot/initramfs-3.14.9-200.fc20.x86_64.img Found linux image: /boot/vmlinuz-3.14.3-200.fc20.x86_64 Found initrd image: /boot/initramfs-3.14.3-200.fc20.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-3b7e507b26dd4217a0e72acf0a43ddb8 Found initrd image: /boot/initramfs-0-rescue-3b7e507b26dd4217a0e72acf0a43ddb8.img Found Windows 7 (loader) on /dev/sda1 done
- install grub loader on disk
# grub2-install /dev/sda /usr/sbin/grub2-bios-setup: warning: Sector 32 is already in use by the program â€FlexNetâ€™; avoiding it. This software may cause boot or other problems in future. Please ask its authors not to store data in the boot track. Installation finished. No error reported.
Entire process are fast and safe.
After rebooting You will can log into Your linux.
In my case drivers for nvidia card fly away into space and boot process hung after a moment due to x-window crash, but i write about this in next tutorial 😀
Tags: boot, bootloader, chroot, config, eng, fedora, grub, grub2, linux, loader, lvm, lvm2, partition, recover, repair