kvm examples
This commit is contained in:
parent
2e3712f948
commit
6d13bde562
|
@ -0,0 +1,90 @@
|
|||
|
||||
create image:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ qemu-img create -f qcow2 test-image.qcow2 25G
|
||||
Formatting 'test-image.qcow2', fmt=qcow2 size=26843545600 cluster_size=65536 lazy_refcounts=off refcount_bits=16
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ ls -ltr
|
||||
total 196
|
||||
-rw-r--r-- 1 ger ger 197008 apr 8 16:53 test-image.qcow2
|
||||
|
||||
download iso_image
|
||||
|
||||
create/start vm:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ qemu-system-x86_64 -cdrom ../iso/ubuntu-server.iso -cpu host -enable-kvm -m 2G -smp 2 -drive file=./test-image.qcow2,format=qcow2
|
||||
|
||||
start vm after install:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ qemu-system-x86_64 -cpu host -enable-kvm -m 2G -smp 2 -drive file=./test-image.qcow2,format=qcow2 -name vm01
|
||||
|
||||
create extra disk:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ qemu-img create -f qcow2 ./extra_disk.qcow2 5G
|
||||
Formatting './extra_disk.qcow2', fmt=qcow2 size=5368709120 cluster_size=65536 lazy_refcounts=off refcount_bits=16
|
||||
|
||||
$ virsh attach-disk vm01 /home/ger/vm/extra_disk.qcow2 vdb --cache none
|
||||
|
||||
virsh run:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virt-install --name=vm01 --ram=2048 --vcpus=2 --disk path=./test-image.qcow2 --boot=hd
|
||||
WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.
|
||||
|
||||
Starting install..
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh destroy vm01
|
||||
Domain vm01 destroyed
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh start vm01
|
||||
Domain vm01 started
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh list --all
|
||||
Id Name State
|
||||
----------------------
|
||||
2 vm01 running
|
||||
|
||||
add disk via dd:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ dd if=/dev/zero of=./disk_dd.dsk count=5000 bs=1M
|
||||
5000+0 records in
|
||||
5000+0 records out
|
||||
5242880000 bytes (5,2 GB, 4,9 GiB) copied, 6,34483 s, 826 MB/s
|
||||
ger@ger-lpt-werk:~/vm$ du -sh ./disk_dd.dsk
|
||||
4,9G ./disk_dd.dsk
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh attach-disk vm01 /home/ger/vm/disk_dd.dsk vdb --cache none
|
||||
Disk attached successfully
|
||||
|
||||
persistent disk:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh attach-disk vm01 /home/ger/vm/disk_dd.dsk vdb --persistent --cache none
|
||||
Disk attached successfully
|
||||
|
||||
create extra disk ala rdms:
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ qemu-img create -o preallocation=metadata -f qcow2 rdms-prod.qcow2 2G
|
||||
Formatting 'rdms-prod.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
|
||||
|
||||
ger@ger-lpt-werk:~/vm$ virsh attach-disk vm01 --target vdd --persistent --driver qemu --subdriver qcow2 --source /home/ger/vm/rdms-prod.qcow2
|
||||
Disk attached successfully
|
||||
|
||||
root@irods01:/home/ger# lsblk
|
||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
||||
sda 8:0 0 25G 0 disk
|
||||
├─sda1 8:1 0 1M 0 part
|
||||
├─sda2 8:2 0 1.5G 0 part /boot
|
||||
└─sda3 8:3 0 23.5G 0 part
|
||||
└─ubuntu--vg-ubuntu--lv 253:0 0 11.8G 0 lvm /
|
||||
vda 252:0 0 4.9G 0 disk
|
||||
vdb 252:16 0 2G 0 disk
|
||||
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: [1af4:1001] type 00 class 0x010000
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: reg 0x10: [io 0x0000-0x007f]
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: reg 0x14: [mem 0x00000000-0x00000fff]
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: BAR 4: assigned [mem 0x100000000-0x100003fff 64bit pref]
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: BAR 1: assigned [mem 0x80000000-0x80000fff]
|
||||
[Wed Apr 13 07:24:06 2022] pci 0000:00:09.0: BAR 0: assigned [io 0x1000-0x107f]
|
||||
[Wed Apr 13 07:24:06 2022] virtio-pci 0000:00:09.0: enabling device (0000 -> 0003)
|
||||
[Wed Apr 13 07:24:06 2022] virtio_blk virtio3: [vdb] 4194304 512-byte logical blocks (2.15 GB/2.00 GiB)
|
||||
|
Loading…
Reference in New Issue