Sharing Virtualizing Physical Server 2008R2 Experience On CentOS 7

Home » CentOS » Sharing Virtualizing Physical Server 2008R2 Experience On CentOS 7
CentOS No Comments

Not as smooth an experience as I had assumed it would be after a test run with a clean install worked perfectly. So figured I would share the experience in case anybody else runs into similar situation since not all information are consolidated in a single place.

Physical machine in question is a 4yr W2008R2 server (non-raided!)
running custom app from defunct developer which is why I am virtualizing the failing server instead of doing a fresh/newer Windows setup.

Too many articles online saying can’t just dd/clone a Windows drives and expect it to run. So opted to go with the “new” Bare Metal Restore functionality added in 2008R2. https://blogs.technet.microsoft.com/askcore/2011/05/12/bare-metal-restore/

BMR caveats
=========- It can only restore from BIOS to BIOS and UEFI to UEFI (virt-manager in C7 doesn’t appear to do UEFI, see below)

– It can only restore to a disk of same or larger size.

– It doesn’t appear to be possible to trick it using a sparse qcow2
disk file to fit it into a smaller disk (500GB HDD to 250GB SSD in my case)

UEFI
===- current version of libvirt/virt-manager in C7 doesn’t appear come with UEFI firmware/loader

– got it done thanks to http://www.nbalonso.com/CentOS-7-uefi-boot-kvm/

– Summary:
– install ovmf from https://www.kraxel.org/repos/
– using virsh edit, add to the section:
/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd

– sidenote: with the UEFI BIOS, warm reboot of the VM often ends up in an UEFI shell instead of booting directly, and sometimes the shell doesn’t see attached drives. A “cold” reboot of the VM will fix this.

Registry changes before booting
======================After using the S2008R2 installation ISO to do a BMR restore, the restored S2008R2 won’t boot.

– need to boot into recovery mode with the CD again to run regedit to change some registry keys (
http://tech-stuff.org/migrate-windows-2008-server-from-physical-to-virtual-environment-or-to-different-hardware/
)

– specifically for S2008R2
– select HKLM then open the File menu to ‘Load Hive’ from \restored drive\Windows\system32\config\SYSTEM. Give it a name e.g.
‘restored_HLKM’
– navigate through the restored HKLM tree to \ControlSet001\services and set the following for KVM
– intelide > start = 0
– lsi_sas > start = 4
– msahci > start = 0
– pciide > start = 4
– the actual value in my registry are 3 instead of 4 but the changes appear to work regardless.

– Note: I’m using IDE not virtio mode to avoid any added complications.

Multi-core issue
===========For some reason, the restored VM won’t boot if more than 1 core is assigned. There are plenty of hits on this issue but unfortunately mostly related to attempts to do PCI VGA passthrough. Trying out the various suggestions such as emulating core2duo, requiring nx and such did not really helped. What worked in the end is
– single core
– remove section in the guest xml
– core2duo (might not be necessary)
– require nx (might not be necessary)

Resizing drives
==========In my situation, the server barely used 60GB on the old drive across two partitions. So 250GB SSDs was assumed to be enough until I hit the BMR restore issue. Ended up using a temporary 1TB spare drive to install before trying to shrink it down to fit onto a 250GB SSD.

– Windows Disk Manager won’t resize boot partition below 1/2 of original

– Do NOT use Aomei partition assistant (thought it was easier and safer to use a Windows-based tool for this but…)

– gparted livecd won’t boot properly in KVM with UEFI/OVMF so better to just use it on a raw disk on the virtualization host directly.

– Before repartitioning, from here https://wiki.archlinux.org/index.php/GParted (although says it’s for WinXP)
– Delete the registry key HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices

– randomly gparted will get errors:
– about unable to read data on the ntfs partition, fixed by mounting the partition before running gparted.
– or abort a resize/move operation because it can’t find the device in /etc/mtab. It doesn’t quite make sense to me because the partition seems to appear only in /etc/mtab if I mount it in the host. But if I
mount the drive, gparted will indicate it is mounted and needs to be unmounted. Fixed by rebooting the host machine everytime it happens.

– Windows still won’t boot after partition changes despite deleting the registry key. Fixed by manually running chkdsk /f in Windows rescue/repair command prompt. No errors found but for some reason this makes Windows happy.

Transferring to smaller drive
===================The web is full of warnings about trying to clone a bigger drive into a smaller drive using dd. Especially since GPT puts a spare table at the end of the drive. However, I figured it can’t hurt to try since I
will still have the working 1TB to fall back on.

– did a dd if=/dev/vg/lv_temp of=/dev/vg_ssd/lv_ssd1 BS2M conv=notrunc,sync

– appears to work as Windows booted without complains.

I’m still left with the unable to assign more than 1 core issue but so far the virtualized server appears to be working. Making a backup image before I mess around with it further. Hope this helps anybody else who might find themselves in a similar situation.