OPERATING SYSTEMSOS Linux

migrate a physical server to a virtual machine on proxmox

In this video I will migrate my old Server into a virtual machine running under Proxmox (Physical to virtual or “P2V”). We will pass through USB devices such as my satellite receiver, card reader and my eBus interface.The “tiny home server”, i.e. the Proxmox Home Server will host the new machine in a VM. Migration Virtual to Physical on Proxmox is actually very similar to physical to virtualbox migration. I am using the Oracle Virtualbox commands to extract the physical disk.

0:00 describing the subject

0:30 intro jingle
0:40 Content
1:05 TLDR/TLDW
1:15 Preparing the old system for migration
2:24 converting the old machine and importing into Proxmox
3:41 shrinking the disk for migration with Knoppix
7:28 importing the shrinked disk into Proxmox
8:10 mapping the hardware, USB pass through
8:58 starting the migrated server
10:13 closing

My Proxmox home lab server is a Dell OptiPlex 3040 USFF Micro PC i5-6500T but similar PCs (roughly the same price point) would be the Lenovo Thinkcentre M910q Tiny or the HP EliteDesk 800G2 USFF

In a nutshell the steps are as follows:
1. Disable the services on the old machine (that depends on your server – I am only showing this very briefly because it’s very specific and not so relevant to the migration process)
2. Dump the physical disk to a virtual disk (I am using Virtualbox and more precisely the vboxmanage tool to do so)
FROM NOW ON DO ONLY WORK ON THE COPY !!!! If you make any mistakes then you can still revert to your od system.
3. You might want to shrink the disk and/or partitions and copy them over to another disk (like I did with Knoppix gparted and dd to a VMWare vmdk disk. This step is of course optional.
4. Import the the disk to a new VM on the Proxmox server.

===============================================================================
Here are the commands I used to create the virtual disk:
===============================================================================

# the disk that I am dumping is /dev/sde
fdisk /dev/sde
# this showed me the number of bytes
# I mounted a USB disk in /mnt/bigdisk as storage space for the VDI file:
mkdir /mnt/bigdisk
mount -t ext4 /dev/sdd1 /mnt/bigdisk/
# df shows the available disk space
df -h /dev/sdd1
mkdir /mnt/bigdisk/vmexport
cd /mnt/bigdisk/vmexport/
# and this is the virtualbox convert command:
cat /dev/sde | vboxmanage convertfromraw stdin hdd1.vdi 126035288064

===============================================================================
#On the proxmox side I imported as follows:

===============================================================================

qm importdisk 999 /mnt/data/vmexport/NewVirtualDisk.vmdk local-lvm –format vmdk

===============================================================================
Here is the content of the start/stop script which I used to disable all the services on the old machine:
===============================================================================

root@abraracourcix:~# cat alldockerservices.sh
#!/bin/bash

# the docker service unit files are located in
# /lib/systemd/system
# and are called docker-xxx.service

for i in /lib/systemd/system/docker-* ; do
SERVICENAME=$( echo $i | cut -d / -f 5 -)

if [ “start” = $1 ] ; then
systemctl enable $SERVICENAME
systemctl start $SERVICENAME
echo $SERVICENAME started and enabled
fi

if [ “stop” = $1 ] ; then
systemctl stop $SERVICENAME
systemctl disable $SERVICENAME
echo $SERVICENAME stopped and disabled
fi

done
root@abraracourcix:~# ^C

Licence-free music on / Lizenzfreie Musik von https://www.terrasound.de/lizenzfreie-musik-fuer-youtube-videos/

source

by OneMarcFifty

linux foundation

Leave a Reply

Your email address will not be published. Required fields are marked *