How to Import a Linux VM (RHEL, CentOS, SUSE, Debian, Ubuntu)#
Overview#
Key Points
- Linux distributions install drivers only for detected hardware during installation.
- Imported VMs may fail to boot due to missing virtio drivers for VergeOS hardware.
- You can resolve boot issues by adjusting VM configuration and regenerating the initramfs.
- This guide covers RHEL, CentOS, Fedora, SUSE, openSUSE, Debian, and Ubuntu.
This guide explains how to import Linux virtual machines from other hypervisors into VergeOS. It addresses potential problems like VMs not booting or lacking network connectivity after migration, and provides distribution-specific instructions for regenerating the initramfs.
Prerequisites#
- Access to VergeOS and the VergeOS UI.
- Familiarity with the hypervisor environment and VM configuration.
- Imported VM files must be present in the VergeOS environment.
Steps#
1. Update VM Hardware Configuration#
-
Change all hard drives to
virtio-scsi:- In the VergeOS UI, navigate to the VM's settings.
- For each hard drive, change the interface to
virtio-scsifor optimal performance and compatibility.
-
Change all NICs to
virtio:- Ensure that all network interface cards (NICs) are set to
virtiofor enhanced networking support.
- Ensure that all network interface cards (NICs) are set to
-
Adjust Boot Order:
- Make sure that the OS disk is listed as ID 0 in the boot order.
2. Boot into Rescue Mode#
-
Start the VM:
- Power on the VM, and during boot, hold the Left Shift key to access the GRUB boot menu.
-
Select Rescue Mode:
- In the GRUB menu, select the rescue mode to boot into a minimal recovery environment.
SUSE/openSUSE Alternative
If you cannot boot to rescue mode from GRUB (common with SLES15 and openSUSE Leap 15), mount an installation ISO to the VM and boot from it. The ISO will provide a "Rescue System" option.
3. Mount the Root Filesystem and Chroot#
Once booted into rescue mode, log in as root and mount the root filesystem.
-
Find the root partition:
If you don't know which partition contains the root filesystem, list all available partitions:
For systems using LVM, list all logical volumes:
-
Mount the root partition:
Mount the root partition or logical volume to
/mnt:Replace
<device_name>with your root partition (e.g.,sda2,mapper/vg0-root). -
Verify the mount:
Check that you mounted the correct filesystem by listing its contents:
You should see directories like
/root,/boot,/home,/etc, and/var. -
Bind the virtual filesystems:
Use the following for-loop to bind the necessary virtual filesystems:
Alternatively, mount them individually:
-
Chroot into the mounted filesystem:
-
Mount remaining filesystems:
After chrooting, mount any additional partitions defined in fstab:
4. Rebuild Initramfs#
After chrooting into the system, regenerate the initramfs with the necessary virtio drivers.
RHEL / CentOS / Fedora / SUSE (using dracut)#
Run the following command to regenerate the initramfs:
This adds drivers for virtio_blk (block device), virtio_net (network device), and virtio_pci (PCI bus) to the initramfs.
Debian / Ubuntu (using update-initramfs)#
If dracut is not available (common on Debian 10 and Ubuntu), use update-initramfs instead:
-
Add the virtio modules to the initramfs configuration:
-
Regenerate the initramfs:
5. Reboot and Verify#
-
Exit the chroot environment:
-
Reboot the VM:
-
Verify Boot and Network Connectivity:
- Confirm that the VM boots successfully and that network connectivity is functional via the
virtioNIC.
- Confirm that the VM boots successfully and that network connectivity is functional via the
Troubleshooting#
Common Issues
- VM is not booting:
- Solution: Double-check the boot order in the VM settings. The OS disk must be set as ID 0.
- No network connectivity:
- Solution: Ensure that NICs are set to
virtioand that the initramfs was rebuilt with the appropriate network drivers.
Additional Resources#
Feedback#
Need Help?
If you have any questions or encounter issues while importing a VM, please reach out to our support team for assistance.