User Tools

Site Tools


box:qemu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
box:qemu [2024/08/27 23:11]
manu [convert disk/image]
box:qemu [2024/09/06 21:03] (current)
manu
Line 22: Line 22:
   qemu-img convert -f vmdk -O qcow2 image.vmdk image.qcow2   qemu-img convert -f vmdk -O qcow2 image.vmdk image.qcow2
  
 +
 +
 +===== Create a VM =====
 +
 +==== Create a virtual disk ====
 +
 +<cli prompt='#'>​
 +root@manu:​~#​ qemu-img create -f qcow2 /​Virtual_srv/​qemu/​rocky9_01_disk.img 20G
 +Formatting '/​Virtual_srv/​qemu/​rocky9_01_disk.img',​ fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
 + .
 +root@manu:​~#​ du -sh /​Virtual_srv/​qemu/​rocky9_01_disk.img
 +196K /​Virtual_srv/​qemu/​rocky9_01_disk.img
 +
 +root@manu:​~#​ qemu-img info /​Virtual_srv/​qemu/​rocky9_01_disk.img
 +image: /​Virtual_srv/​qemu/​rocky9_01_disk.img
 +file format: qcow2
 +virtual size: 20 GiB (21474836480 bytes)
 +disk size: 196 KiB
 +cluster_size:​ 65536
 +Format specific information:​
 +    compat: 1.1
 +    compression type: zlib
 +    lazy refcounts: false
 +    refcount bits: 16
 +    corrupt: false
 +    extended l2: false
 +Child node '/​file':​
 +    filename: /​Virtual_srv/​qemu/​rocky9_01_disk.img
 +    protocol type: file
 +    file length: 192 KiB (197120 bytes)
 +    disk size: 196 KiB
 +</​cli>​
 +
 +qemu-system-x86_64 -k fr -m 512 -drive file=/​Virtual_srv/​qemu/​rocky9_01_disk.img,​format=qcow2 -boot d -cdrom /​home/​manu/​Downloads/​Rocky-9.4-x86_64-minimal.iso -nographic -netdev user,​id=mynet0 -device e1000,​netdev=mynet0
 +
 +<​code>​
 +virt-install \
 +    --memory 1024 \
 +    --vcpus 1 \
 +    --name Rocky9 \
 +    --disk /​Virtual_srv/​qemu/​rocky9_01_disk.img,​device=disk,​bus=virtio,​format=qcow2 \
 +    --disk home/​manu/​Downloads/​Rocky-9.4-x86_64-minimal.iso,​device=cdrom \
 +    --os-variant virt-install \
 +    --memory 1024 \
 +    --vcpus 1 \
 +    --name Rocky9 \
 +    --disk /​Virtual_srv/​qemu/​rocky9_01_disk.img,​device=disk,​bus=virtio,​format=qcow2 \
 +    --disk /​home/​manu/​Downloads/​Rocky-9.4-x86_64-minimal.iso,​device=cdrom \
 +    --os-variant rocky9 \
 +    --virt-type kvm \
 +    --graphics none \
 +    --import
 +</​code>​
 +
 +<cli prompt='​$'>​
 +manu@manu:​~$ virsh domiflist rocky9
 + ​Interface ​  ​Type ​     Source ​   Model    MAC
 +-------------------------------------------------------------
 + ​vnet0 ​      ​network ​  ​default ​  ​virtio ​  ​52:​54:​00:​56:​fe:​1e
 +
 +manu@manu:​~$ virsh list
 + ​Id ​  ​Name ​    State
 +------------------------
 + ​1 ​   rocky9 ​  ​running
 +
 +manu@manu:​~$ virsh shutdown rocky9
 +Domain '​rocky9'​ is being shutdown
 +
 +manu@manu:​~$ virsh list
 + ​Id ​  ​Name ​  State
 +--------------------
 +
 +manu@manu:​~$ virsh start rocky9
 +Domain '​rocky9'​ started
 +
 +manu@manu:​~$ virsh list
 + ​Id ​  ​Name ​    State
 +------------------------
 + ​2 ​   rocky9 ​  ​running
 +</​cli>​
 +
 +Review the provision from the Host OS.
 +<cli prompt='​$'>​
 +manu@manu:​~$ virsh domblklist FMGinternal
 +
 + ​Target ​  ​Source
 +----------------------------------------
 +
 + ​hda ​     /​srv/​VMs/​fmg.qcow2
 + ​hdb ​     /​srv/​VMs/​fortimanager.qcow2
 + ​vdb ​     /​srv/​VMs/​fortimanager2.qcow2
 +
 +
 +manu@manu:​~$ virsh domblkinfo FMGinternal vdb --human
 +
 +Capacity: ​      ​80.000 GiB
 +Allocation: ​    ​196.000 KiB
 +Physical: ​      ​193.250 KiB
 +</​cli>​
 +
 +**In the Host OS:**
 +
 +If the '​virsh'​ command hangs during some operations, restart it. If it still hangs, review the rights of the user and the logs for more clues.
 +  systemctl restart libvirtd
 +
 +Review the logs with '​journalctl'​ and press G to go to the latest ones.
 +  journalctl -b 0
box/qemu.1724793082.txt.gz · Last modified: 2024/08/27 23:11 by manu