LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2019, 05:12 AM   #1
N6rV1UUV
LQ Newbie
 
Registered: May 2019
Posts: 5

Rep: Reputation: Disabled
CentOS7 fails boot to grub2 after conversion


I converted centos7 phisical machine with one HDD to vmware VM and process separated boot partition to another virtual disk. So boot fails in grub2 console, I have been able to boot OS normally with mounted supergrub2.iso but I want to fix bootloader.

Code:
grub> ls
(hd0) (hd0,msdos1) (hd1) (hd1,msdos1) (lvm/centos-swap) (lvm/centos-home) (lvm/centos-root)
(hd0,msdos1) is boot partition.

Code:
grub> set
...
prefix=(lvmid/*some garbage*)/boot/grub2
...
root=(lvmid/*some garbage*)
I tried
Code:
set root=(lvm/centos-root)
linux (hd0,msdos1)/vmlinuz...
initrd (hd0,msdos1)/initrd...
boot
which fails to start Switch Root
 
Old 10-19-2019, 12:51 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If you created a non-LVM boot partition on (hd0,msdos1) the grub variables need to be set to that - notably both prefix and root.
 
Old 10-22-2019, 06:39 AM   #3
N6rV1UUV
LQ Newbie
 
Registered: May 2019
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
If you created a non-LVM boot partition on (hd0,msdos1) the grub variables need to be set to that - notably both prefix and root.
I tried:

Code:
set root=(lvm/centos-root)
set prefix=(hd0,msdos1)/grub2
linux (hd0,msdos1)/vmlinuz...
initrd (hd0,msdos1)/initrfs...
boot
Which starts boot process but fails starting initrd-switch-root.service with following error:

Code:
Failed to switch root: Specified switch root path /sysroot does not seem to be an OS tree. os-release file is missing.
This happens with all installed kernel versions
 
Old 10-22-2019, 07:08 AM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
what happens if you boot with supergrub2
and reinstall grub and regenerate grub.conf ?
 
Old 10-22-2019, 07:44 AM   #5
N6rV1UUV
LQ Newbie
 
Registered: May 2019
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Firerat View Post
what happens if you boot with supergrub2
and reinstall grub and regenerate grub.conf ?
There are no option to reinstall grub2.
I have "Super Grub2 Disk 2.04s2-beta2"

EDIT:
sorry I misunderstood you.
I booted with supergrub and tried:
Code:
rm -rf /etc/default/grub
rm -rf /etc/grub.d/*
yum reinstall grub2-tools
grub2-mkconfig -o /boot/grub2/grub.cfg
which had no effect, normal boot still fails the same.

Last edited by N6rV1UUV; 10-22-2019 at 08:13 AM.
 
Old 10-22-2019, 10:45 AM   #6
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
man grub-install

or possibly man grub2-install

I don't have a centOS to hand

Code:
/usr/sbin/grub-install --help
Usage: grub-install [OPTION...] [OPTION] [INSTALL_DEVICE]
Install GRUB on your drive.

      --compress=no|xz|gz|lzo   compress GRUB files [optional]
      --dtb=FILE             embed a specific DTB
  -d, --directory=DIR        use images and modu<snip>
my assumption is that when grub is installed to the device it is "hardcoded" with mapping to the grub.conf

since you created a virtualDisk this mapping is no longer valid
I believe grub-install would fix that
 
1 members found this post helpful.
Old 10-22-2019, 10:51 AM   #7
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Firerat View Post
man grub-install

or possibly man grub2-install

I don't have a centOS to hand
...
Either will work in CentOS.
 
Old 10-22-2019, 10:53 AM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
at the grub memu highlight the centos entry, press e for edit, post what is on the line that starts with Linux.
 
Old 10-23-2019, 12:40 AM   #9
N6rV1UUV
LQ Newbie
 
Registered: May 2019
Posts: 5

Original Poster
Rep: Reputation: Disabled
Code:
grub2-install /dev/sda
fixed the problem
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CentOS7 Grub2 Boot Error BeeRich CentOS 73 09-28-2019 10:13 AM
Any problem if I install CENTOS7 Workstation over CENTOS7 Server? Rich Strebendt Linux - Software 5 05-03-2018 11:05 PM
How to update GRUB2 for dual boot centos7/Ubuntu 14.04.. crocodilehunter Linux - Laptop and Netbook 3 03-19-2016 04:51 PM
FreeIPA Centos7 fails after first reboot due to 389dir service crashing jessedalestacey Linux - Server 1 08-27-2015 10:15 AM
[SOLVED] GRUB2 after a minor update of GRUB2 /boot prefix no longer needed?? wikapuki Linux - Software 1 10-24-2010 02:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration