How to reinstall boot sector/partition in a hyperV vhdx in centos7?
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to reinstall boot sector/partition in a hyperV vhdx in centos7?
I know, I know should have backed up. I even have daily backups but discovered that the VM's weren't selected (doh!)
Its Centos 7 (64bit) in a VM on a low powered (8 core atom) home windows box, the linux VM is my router/firewall/LAMP box (and to play with)
So I cant boot from the vhdx disk image directly, it just immediately fails and switches to trying to boot from the network. I found a year old vhdx backup which boots fine but was just really old. Thinking I might be able to recover some data from the new one I mounted both vhdx at once in Hyper V and to my surprise discovered that the version that came up is the new one, not the old one. All the data inside the vhdx seems fine.
Currently copying off what I can think of that I might have prodded but it seems like all that is wrong is it wont boot, otherwise it seems completely fine as near as I can tell.
The "old" drive is /dev/sda, the current one /dev/sdc with /dev/sdb being a swap drive
I've tried grub2-install /dev/sdc however it complains about
grub2-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.
I'm not finding much help on google and was worried about breaking things further.
The only alternative i can think of is mounting both at once and copying the entire contents of the new over the old but thats complicated by them being logical volumes with the same uid
The root cause was I think hardware failure. Windows bluescreens with IRQ_NOT_LESS_EQUAL when trying to view the drive the vhdx lived on, however viewing/copying the contents via the command prompt worked fine.
You can't rely on which of the two "same-UUID" images you will get access to. At least under Linux - I would guess Windoze is similar.
So make sure you get all your data backed up while you can.
I thought Hyper-V was only available on Pro versions - but it's Windoze, so I happy to be ignorant. I've fired it up only once.
Presuming the guest is an emulated BIOS/MBR setup, try "grub-install --target=i386-pc /dev/sdc" - but if you think the (real) disk is dead/dying, why are you bothering ?.
The vhdx is just a disk image file, like an ISO. The hard drive that that image file was on is dying but I've copied it off that drive to another. The guest is emulated with uefi rather than mbr.
Basically I seem to have lost the "bootable" nature of the Linux disk image, although reading up on uefi it seems it doesn't have a boot sector like the old mbr way so I need some way of reapplying that bootable status.
A suggestion I've got from another forum is to mount the centos install disk with the newer disk image and do a repair. I'm just waiting for the other data on that dodgy drive to finish copying off (new drive only just arrived) before I try that just in case.
So I discovered the reason windows was blue screening, it had corrupted the swap files in some way and was bluescreening whenever the folders they were in were viewed, i.e. the root of the drives. Gotta love windows. Removing the swap files and I can view the drives fine. Presumably one of the bluescreens corrupted the vm while it was running.
However I tried booting off the installer and couldn't find an option to recover. I just seem to have a graphical language selection screen followed by a screen which requires me to choose an installation location, if I choose that it says that the partition only has 2 megs spare and seems to want to format, I've not gone further than that screen.
Edit: Actually now just found it, not sure why that initial menu wasnt coming up before
Last edited by TheOneFinn; 06-10-2017 at 01:07 PM.
Reason: update
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.