Outils pour utilisateurs

Outils du site


tech:import_vm_vdi_qcow2

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
tech:import_vm_vdi_qcow2 [2025/04/04 19:22] Jean-Baptistetech:import_vm_vdi_qcow2 [2026/06/04 13:41] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon Virt FS}}
 +
 +Voir document 
 +* import_vm_vdi_qcow2.odt FIXME
 +
 +# Import VM (VDI QCOW2)
 +
 +## VDI vers RAW
 +
 +~~~
 +$ VBoxManage clonehd --format RAW /home/jibe/tmp/wheezy1.vdi /home/jibe/tmp/wheezy1.img
 +
 +VBoxManage: error: Cannot register the hard disk '/home/jibe/tmp/wheezy1.vdi' {16d89855-060b-4abf-a154-32b869784a26} because a hard disk '/home/jibe/VirtualBox VMs/wheezy1/wheezy1.vdi' with UUID {16d89855-060b-4abf-a154-32b869784a26} already exists
 +VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
 +VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp
 +~~~
 +
 +** Cette erreur disparaît en root** 
 +
 +
 +~~~
 +$ time VBoxManage clonehd --format RAW /home/jibe/tmp/wheezy1.vdi /home/jibe/tmp/wheezy1.img
 +
 +0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
 +Clone hard disk created in format 'RAW'. UUID: 8e3b2b88-31d2-4e60-8792-f42d4e7e107e
 +
 +real 2m59.942s
 +user 0m1.272s
 +sys 0m1.084s
 +~~~
 +
 +** Le format RAW de gérant pas le <lang en>Copy-On-Write</lang> l'image générée sera de la taille maximal (Taille virtuelle) **
 +
 +~~~
 +$ ls -lh ~/tmp/wheezy1.*
 +-rw------- 1 root root 8,0G avril  1 11:38 /home/jibe/tmp/wheezy1.img
 +-rw------- 1 jibe jibe 1,6G mars   7 14:54 /home/jibe/tmp/wheezy1.vdi
 +~~~
 +
 +## Conversion RAW vers QCOW2
 +
 +~~~
 +$ time qemu-img convert -f raw ~/tmp/wheezy1.img -O qcow2 wheezy1.qcow2
 +real 2m17.464s
 +user 0m5.684s
 +sys 0m26.528s
 +~~~
 +
 +La taille de l'image disque redevient celle de l'espace vraiment consommé:
 +~~~
 +$ ls -lh wheezy1.qcow2
 +-rw-r--r-- 1 jibe jibe 1,5G avril  1 12:06 wheezy1.qcow2
 +~~~
 +
 +## Conversion OVA / OVF
 +
 +Un OVA est une archive TAR
 +~~~bash
 +tar xvf plop.ova
 +~~~
 +
 +Lister les formats pris en charge
 +~~~bash
 +qemu-img -h | tail -n1
 +~~~
 +
 +Conversion du VMDK en QCOW2
 +~~~bash
 +qemu-img convert -O qcow2 plop-disk1.vmdk plop.qcow2
 +~~~
 +
 +## info sur l'image 
 +
 +~~~bash
 +qemu-img  info --output json plop.qcow2
 +~~~
 +
 +## Création d'un VMDK
 +
 +~~~bash
 +wget https://download.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.raw.xz
 +xz --decompress Fedora-Cloud-Base-31-1.9.x86_64.raw.xz
 +qemu-img convert -f raw -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized Fedora-Cloud-Base-31-1.9.x86_64.raw Fedora-31.vmdk
 +printf '\x03' | dd conv=notrunc of=Fedora-31.vmdk bs=1 seek=$((0x4))
 +~~~
 +
 +## Conversion VMDK vers VMDK (VMDK2VMDK)
 +
 +Par exemple suite à 
 +~~~bash
 +openstack image save plop --file plop.vmdk
 +~~~
 +
 +Conversion VMDK vers VMDK
 +~~~bash
 +qemu-img convert -O vmdk plop.vmdk plop2.vmdk
 +~~~
 +
 +## Resize VDI
 +
 +~~~winbatch
 +VBoxManage.exe modifyhd D:\VMs\plop\plop.vdi --resize 40000
 +~~~
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki