Phong Lan

Chuyển đổi số cho doanh nghiệp tại Việt Nam.


(D241127) KVM QEMU libvirt virsh virt-install CLI on Ubuntu Linux

Trying to have virtual machines on Ubuntu Linux, of course I'm more comfotable on FreeBSD Bhyve.

virt-install

provision new virtual machines

# virt-install --name vm0 --memory 1024 --vcpus 2 \
--os-variant ubuntu24.04 \
--disk size=10 --network bridge=br0 --graphics none --console pty,target_type=serial \
--location /usr/local/etc/iso/ubuntu-24.04.1-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
--extra-args 'console=ttyS0,115200n8 serial'

virsh

management user interface

virsh list --all

virsh start vm0

virsh autostart vm0

virsh autostart --disable vm0

virsh shutdown vm0

virsh destroy vm0

virsh undefine vm0 --remove-all-storage

usb passthrough

$ lsusb   
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 2c7c:0125 Quectel Wireless Solutions Co., Ltd. EC25 LTE modem
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
$ cat usb_ec25.xml 
<hostdev mode='subsystem' type='usb' managed='yes'>
    <source>
        <vendor id='0x2c7c'/>
        <product id='0x0125'/>
    </source>
</hostdev>
# virsh attach-device vm0 --file usb_ec25.xml --config

Attaching and Updating a Device with virsh

« Trang trước