This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
box:qemu [2024/09/05 23:31] manu [Create a virtual disk] |
box:qemu [2024/09/06 21:03] (current) manu |
||
|---|---|---|---|
| Line 29: | Line 29: | ||
| <cli prompt='#'> | <cli prompt='#'> | ||
| - | root@manu-Latitude-5480:/Virtual_srv/VirtualBox VMs# qemu-img create -f qcow2 /Virtual_srv/qemu/rocky9_01_disk.img 20G | + | 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 | 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-Latitude-5480:/Virtual_srv/VirtualBox VMs# du -sh | + | . |
| - | 7.3G . | + | root@manu:~# du -sh /Virtual_srv/qemu/rocky9_01_disk.img |
| - | root@manu-Latitude-5480:/Virtual_srv/VirtualBox VMs# du -sh /Virtual_srv/qemu/rocky9_01_disk.img | + | |
| 196K /Virtual_srv/qemu/rocky9_01_disk.img | 196K /Virtual_srv/qemu/rocky9_01_disk.img | ||
| - | root@manu-Latitude-5480:/Virtual_srv/VirtualBox VMs# qemu-img info /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 | image: /Virtual_srv/qemu/rocky9_01_disk.img | ||
| file format: qcow2 | file format: qcow2 | ||
| Line 55: | Line 55: | ||
| </cli> | </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 | ||