LoginSignup
0
0

仮想サーバ(KVM)イメージファイルが作成されるディレクトリのデフォルト値(/var/lib/libvirt/images)を変更する方法

Last updated at Posted at 2024-06-16

概要

Cockpitのブラウザ画面上では、仮想サーバ(KVM)のイメージファイルが作成されるディレクトリ(/var/lib/libvirt/images)を直接変更することはできませんが、コマンドラインツール(virsh)を使用してディレクトリを変更できます。
昔から実装されていますが最新のLinuxディストリビューション1でも実現可能なのか検証してみました。

図1 Cockpit のブラウザ画面(変更前・デフォルト値)
名称未設定.jpeg

図2 Cockpit のブラウザ画面(変更後)
test999.jpeg

変更方法

1. virsh コマンドで仮想サーバ(KVM)イメージファイルが作成される場所に /var/lib/libvirt/images が設定されていることを確認します。

①10行目 < path >の値を確認
# virsh pool-dumpxml default > test.xml
# cat -n test.xml
     1	<pool type='dir'>
     2	  <name>default</name>
     3	  <uuid>xxxx-xxxx-xxxx-xxxx-xxxx</uuid>
     4	  <capacity unit='bytes'>xxxx</capacity>
     5	  <allocation unit='bytes'>xxxx</allocation>
     6	  <available unit='bytes'>xxxx</available>
     7	  <source>
     8	  </source>
     9	  <target>
    10	    <path>/var/lib/libvirt/images</path>
    11	    <permissions>
    12	      <mode>xxxx</mode>
    13	      <owner>x</owner>
    14	      <group>x</group>
    15	    </permissions>
    16	  </target>
    17	</pool>

2. <path>を /var/lib/libvirt/images から別の値2に変更します。

②10行目< path >の値を変更
# vi test.xml 
# cat -n test.xml
     1	<pool type='dir'>
     2	  <name>default</name>
     3	  <uuid>xxxx-xxxx-xxxx-xxxx-xxxx</uuid>
     4	  <capacity unit='bytes'>xxxx</capacity>
     5	  <allocation unit='bytes'>xxxx</allocation>
     6	  <available unit='bytes'>xxxx</available>
     7	  <source>
     8	  </source>
     9	  <target>
    10	    <path>/disk02/vm</path>
    11	    <permissions>
    12	      <mode>xxxx</mode>
    13	      <owner>x</owner>
    14	      <group>x</group>
    15	    </permissions>
    16	  </target>
    17	</pool>

警告
<path>の値に英大文字3が含まれるとエラーメッセージが出力されました。
error: Failed to destroy pool default
error: Requested operation is not valid: storage pool 'default' is not active

3. virsh コマンドで新<path>情報を反映します。

③「Pool default created」メッセージを確認
#  virsh pool-create test.xml
Pool default created from test.xml

4. Cockpit のブラウザ画面でデフォルト値(/var/lib/libvirt/images)から別の値2に変更されたことを確認します。
test999.jpeg

検証環境

カテゴリ バージョン 備考
OS Ubuntu 24.04 LTS
ミドルウェア cockpit 314-1 aptでインストール4

参考文献

libvirt VM イメージのデフォルトの場所を変更する方法

  1. Ubuntu 24.04 LTS で検証

  2. 本文では /disk02/vm に変更 2

  3. 例えば /disk02/VM

  4. # apt install cockpit && apt install cockpit-machines

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0