Wouldn't it be easier if you could build a VM with a YAML file? So, I have created a command called kvm-compose (pseudonym), so I would like to introduce it.
--Centos 8 Minimal installed --Running on VirtualBox --Move with GUI from the middle --It works only with CLI by specifying a bridge that can access the outside.
# dnf update -y
# dnf install -y wget
# dnf module install -y virt
# dnf module install -y "Server with GUI" (virt-When using viewer)
# dnf install -y virt-install virt-viewer git wget
# systemctl start libvirtd
# systemctl enable libvirtd
# git clone https://github.com/naoki2001/kvm-compose
# mkdir /compose/{ images , isos }
# wget http://ftp.riken.jp/Linux/centos/8/isos/x86_64/CentOS-8.2.2004-x86_64-minimal.iso
# mv CentOS-8.2.2004-x86_64-minimal.iso /compose/isos/
# startx (virt-When using viewer)
# cd kvm-compose
# cat kvm-compose.yml
The following formats can work with kvm-compose (although we plan to increase it ...)
kvm-compose.yml
kvm:
- name: test
arch: x86_64
os:
- type: linux
variant: rhel8.0
vcpus: 1
ram: 1024
disk:
- path: /conpose/images/test.img
format: qcow2
size: 8
network:
- bridge: virbr0
location: /compose/isos/CentOS-8.2.2004-x86_64-minimal.iso
extra-args: "console=tty0 console=ttyS0,115200n8"
Each item conforms to virt-install
# ./kvm-compose build
With this, virt-viewer
will start in the GUI, so install the OS.
For CLI, access with VNC.
kvm-compose
-- kvm-compose
is created in Go language based on the `virsh``` and
`virt-install``` commands.
――What you can do
option | Description |
---|---|
build | kvm-compose.Load yml and build VM |
build file.yml | file.Load yml and build VM |
list | View running VMs |
list --inactive | Cover of a non-started VM |
list --all | View all VMs |
start vm_name | vm_Start name. Start and then return to prompt |
shutdown vm_name | vm_Shut down name. Return to prompt when you can confirm that the power is off |
destroy vm_name | vm_Power off name. Return to prompt when you can confirm that the power is turned off |
--If the kvm-compose command does not work Download the source code from https://github.com/naoki2001/kvm-compose-src and try compiling it according to the README.md.
I was able to build a VM for the time being. However, it is not easy to use, so I would like to improve it. If you find any typographical errors, typographical errors, or missing points, we would appreciate it if you could comment.
Posted on 10/21 10/24 Addition of functions (start, shutdown, destroy)
Recommended Posts