6.7 KiB
+++ categories = ["software"] tags = ["virtualization"] date = 2024-11-10T15:55:42Z description = "Migrating a physical Debian server into Proxmox so it can run alongside a virtualized Windows Server domain controller." draft = false slug = "proxmox-migration" title = "🤖 Server Virtualization Migration" author = "nicholas" +++
I want to run Windows Server for the purpose of running a domain controller for Active Directory. My server is currently running Debian Linux, so some work will need to be done to get this OS virtualized alongside Windows Server, and I will accomplish this with Proxmox Virtual Environment.
Physical-to-Virtual (P2V) Migration
The operation I will be doing is called physical-to-virtual migration. I outline the process below.
- Shrink OS partition
- Create a bootable USB containing gparted software.
- Boot into gparted software so that I can shrink my OS partition. This is necessary because the OS partition, despite containing only around 40 GB of data, occupies roughly the total physical space on the disk, or 500 GB, and this very same disk will later be used to host the Virtualization OS.
- Clone OS disk
- Create bootable USB containing CloneZilla software
- Boot into CloneZilla software to clone my physical, now-shrunken OS partition.
- Install Proxmox
- I will need to install Proxmox on the physical disk. This will erase the OS, but since I made a clone, I can eventually restore this OS to a virtual disk within Proxmox.
- Proxmox provides a software layer to install virtual disks that contain my cloned OS, and other OSes.
- Reconfigure Storage
- Previously, my ZFS ran on bare-metal, and I can still do this again inside Proxmox.
- I need only ZFS import
Shrinking the Partition
This part is sort of tricky. As I described above, I have to install Proxmox on the same physical storage drive that I am migrating from. This means that I will need to shrink the partition that contains my Linux OS so that it may fit on the virtual drive I allocate for the virtualized clone. The sum total of partitions on the drive is 500 GB, so the CloneZilla restore would require a disk equal to or larger than 500 GB. It is not possible for me to create a 500 GB virtual disk on a 500 GB physical disk, so I must shrink the OS partition down to a size that will fit on the virtual disk. For this I will use gparted. I could do this with tools built into CloneZilla, but gparted offers a very nice GUI and it is reassuring to have a live gparted USB around in case my migration goes wrong. I use rufus to configure a USB drive that will allow me to boot my computer into a live environment of gparted. This will allow me to make changes to the partition on the OS disk:
- Boot
- Swap
- OS
I am interested in shrinking the OS partition, which occupies 400+ GB of space on the disk, and containing only ~40 GB of data. This is approximately the size to which I may shrink the partition. Once it is cloned into a virtual disk, I can expand it to fill whatever partition size I allocate. I will allocate approximately 100 GB to Proxmox for the root filesystem. The remaining ~400 GB will be managed by Proxmox's Logical Volume Manager, which will allow me to provision space for the virtual disks that will host the guest VM OSes such as Windows Server, or Windows 11, or Debian, or whatever.
{{< image src="images/gparted_shrink.PNG" caption="gparted shrink" >}}
CloneZilla Live Environment (BACKUP)
I boot to CloneZilla live environment to clone the now-shrunken partitions that compose the original Linux OS disk. Now that the sum of my three partitions is ~40 GB (instead of 400+ GB), it is time to clone them. Again I use Rufus to create a boot environment for CloneZilla Live software. This allows me to boot my server into the CloneZilla Live environment to carry out the disk cloning operation on the OS disk. A useful but perhaps misleading feature of CloneZilla is that it saves and restores only used blocks on the hard disk partitions. Suppose I had not resized the OS root partition down from ~400 GB, and the OS still occupied only 40 GB of that space. If I backup this disk, CloneZilla will indeed save only used blocks on this partition, making the backup directory ~40 GB. This does not mean that the disk that the backup is intended to be restored to may be smaller than the original sum of the partitions -- only that the space required to store backup will be relatively small. The disk being restored to would need to be at least 400 GB, despite the backup only being 40 GB. This is why I shrank down the partitions in the first place.
{{< image src="images/clonezilla_usb.PNG" caption="Creating bootable CloneZilla USB in Rufus" >}}
Cloning
In CloneZilla, I allow the GUI to hand-hold me through the process of creating a backup. This backup is cloned to an external hard drive. When it is time to restore the OS to a VM disk, I will use CloneZilla to do a disk-to-disk backup -- one physical disk (external hard drive) and one virtual (Proxmox virtual hard drive). Once the backup is complete and stored off the OS disk, it is time to install Proxmox at on root filesystem.
Proxmox VE
Once again I create a live boot environment on a USB drive to allow me to boot into and install Proxmox VE. The GUI guides me through the installation and results in a web interface published on the local machine's port 8006. This is where I can configure the system: allocating space on the disk for virtual disks, managing ZFS pool, etc.
CloneZilla Live Environment (RESTORE)
{{< image src="images/clonezilla_restore.PNG" caption="CloneZilla Restore" >}}
Now that I have a working Proxmox host, it is time to create a VM to restore the backup to.
- First, I create a new VM which will eventually host a virtual drive that will boot into my cloned Debian Linux environment. Before I realize this I need to configure the VM to boot into CloneZilla and read the backup from the external hard drive.
- I name the new VM
debianand add a USB device, and a CD/DVD drive to the hardware. - Next I move a CloneZilla live environment ISO to
/var/lib/vz/template/iso. - I mount this to the VM CD/DVD drive and configure the VM to use it as the boot device.
- Now I run the VM and boot into CloneZilla.
- I need to mount the external hard drive, so I enter a terminal.
mkdir /mnt/hdd
mount /dev/sda /mnt/hdd
Now I can use clonezilla to restore my OS to a virtual disk.
Expand OS Root Partition
I shrank it to 40 GB, now i need to fill up the virtual disk. I attach the gparted disk to the VM and boot to it. This time I expand the partition to occupy the remaining used portion of the virtual disk.
Done.