Advertisement
efxtv

How to convert ova/vdi to qcow2 QEMU and extend the disk size

Jan 26th, 2025 (edited)
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | Cryptocurrency | 0 0
  1. How to convert ova to qcow2 QEMU and extend the disk size
  2.  
  3. Running a .ova file in QEMU requires extracting and converting the virtual disk image inside the .ova file to a format that QEMU can use. Here's a step-by-step guide:
  4.  
  5. ##################################################################
  6. JOIN US ON TELEGRAM FOR MORE AND DETAILED CLASSES
  7. VISIT OUR TELEGRAM PROFILE: https://t.me/LinuxClassesEFXTv
  8. ##################################################################
  9.  
  10. Step 1: Extract the .ova File
  11. tar -xvf your_file.ova
  12.  
  13. You will see files like:
  14. your_file.vmdk # (disk image file)
  15. your_file.ovf # (metadata and configuration)
  16. your_file.mf # (optional checksum file)
  17.  
  18. Step 2: Convert .vmdk to .qcow2
  19. Install qemu-img if it's not already installed:
  20. sudo apt install qemu-img
  21.  
  22. Convert the disk VMDK:
  23. # your_file.vmdk: The source VMware disk file.
  24. # your_file.qcow2: The converted QEMU-compatible image.
  25. qemu-img convert -O qcow2 your_file.vmdk your_file.qcow2
  26.  
  27. Convert the disk if it is in VID format:
  28. qemu-img convert -f vdi -O qcow2 Ubuntu24.10.vdi Ubuntu24.10.qcow2
  29.  
  30. Step 3: Run the Converted Disk with QEMU
  31. # -m 4G: Allocates 4 GB of RAM.
  32. # -smp 2: Allocates 2 CPU cores.
  33. # -netdev and -device: Sets up basic networking.
  34. # -vga virtio: Uses VirtIO for graphics.
  35. qemu-system-x86_64 \
  36.   -enable-kvm \
  37.   -m 4G \
  38.   -cpu host \
  39.   -smp 2 \
  40.   -drive file=your_file.qcow2,format=qcow2 \
  41.   -netdev user,id=net0 -device e1000,netdev=net0 \
  42.   -vga virtio
  43.  
  44. Step 4: (Optional) Automate with Virt-Manager
  45. sudo apt install virt-manager
  46. # Import the .qcow2 file as a new virtual machine.
  47.  
  48. Step 0: EXTRA TIPS Expand the Disk Image
  49. Check the Current Size: Use qemu-img to check the size of the disk image:
  50. qemu-img info your_file.qcow2
  51.  
  52. Resize the Disk: Expand the disk to the desired size (e.g., 50 GB):
  53. qemu-img resize your_file.qcow2 50G
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement