computerの日記

Cisco,SHELL,C,Qt,C++,Linux,ネットワーク,Windows Scriptなどの発言です

libvirt の image 保存ディレクトリの変更

Fedora29 を使っていますが、デフォルトのマウント方法なので、/dev/mapper/fedora-root は / に、/dev/mapper/fedora-home が /home マウントされていて、それぞれ 49G と 1.1T の容量となっています。/var/lib/libvirt は、/ に入っているので、/var/lib/libvirt/images にイメージが増えていくと、あっという間に / の容量が一杯になってしまいます。

特に、preallocation=full などとすると、sparse 化できないため、これはいけません。

そこで、images ディレクトリだけ、/home に作成することにしました。

# mkdir /home/<user>/libvirt/images
# ln -sf /home/<user>/libvirt/images /var/lib/libvirt/images
# semanage fcontext -t virt_image_t -a "/home/<user>/libvirt/images"
# restorecon /home/<user>/libvirt/images

qemu ユーザーを、<user> グループに追加することも必要だったかな。

# usermod -a -G <user> qemu

# chmod 770 /home/<user>

お腹すいたなぁ。