Arch LinuxでVM
やりたいこと
候補
- VMWare → 多分王道。ただ、ライセンスが気軽に遊べるお値段ではなさそう。
- oVirt @ RHEL or CentOS → 良さそう。ただ、最新CPUを導入予定なので最新カーネルを使いたい気持ちがある。
- libvirt(manager, Cockpit) @ Arch Linux → 使い慣れたArchでできたらいいなって。クラスタ化?
Arch Linuxで検討
KVMベースでの仮想化は普通にできそう。クラスタ化が問題だが一旦目をつぶってクライアントOSのインストールまでやってみる。 複数ホストはTerraformでの監理かoVirtを自前ビルドか。
参考:
QEMU/KVM, libvirtのインストールと設定 | 普段使いのArch Linux
実験
環境確認
といいつつ手元にManjaroが入ってたのでManjaroでお試し。後でArchで追試する。
cat /proc/version ✔ Linux version 5.17.1-3-MANJARO (builduser@fv-az47-788) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.38) #1 SMP PREEMPT Thu Mar 31 12:27:24 UTC 2022
インストール
$ yay -S qemu libvirt ebtables dnsmasq virt-manager
ebtables dnsmasqをインストールすることで、ホストOSでNATされてゲストOSで特に設定することなくネットワークにつながるらしい。
qemu.conf, libvirtd.confの編集
参考サイトの通り
# vim /etc/libvirt/qemu.conf ... # The user for QEMU processes run by the system instance. It can be # specified as a user name or as a user id. The qemu driver will try to # parse this value first as a name and then, if the name doesn't exist, # as a user id. # # Since a sequence of digits is a valid user name, a leading plus sign # can be used to ensure that a user id will not be interpreted as a user # name. # # Some examples of valid values are: # # user = "qemu" # A user named "qemu" # user = "+0" # Super user (uid=0) # user = "100" # A user named "100" or a user with uid=100 # user = "ユーザー名" ←「ユーザー名」は普段使う一般ユーザーのユーザー名に変える。 # The group for QEMU processes run by the system instance. It can be # specified in a similar way to user. group="libvirt" ←グループをlibvirtに変える。 # Whether libvirt should dynamically change file ownership # to match the configured user/group above. Defaults to 1. # Set to 0 to disable file ownership changes. dynamic_ownership = 1 ←コメントアウトを解除。
# vim /etc/libvirt/libvirtd.conf ... unix_sock_group = "libvirt" ... unix_sock_ro_perms = "0777" # set to 0770 to deny non-group libvirt users ... unix_sock_rw_perms = "0770" ... auth_unix_ro = "none" ... auth_unix_rw = "none" ... ...
ユーザーをグループに追加
$ sudo gpasswd -a taiki kvm $ sudo gpasswd -a taiki libvirt
サービスの起動
$ sudo systemctl start libvirtd $ sudo systemctl enable libvirtd
virt-managerの起動
Gnomeでvirt~と打つと仮想マシンマネージャというのが見つかるので起動。 ユーザをグループに正しく追加できていないとパスワードを聞かれる。
仮想マシンの作成
とくに躓くところはなさそう。