Skip to main content
  1. Posts/

Cara Membuat Storage Volume di Libvirt

·2 mins·
libvirt kvm libvirt
Table of Contents

Pada tutorial kali ini akan membahas cara untuk membuat Storage Volume di Libvirt menggunakan command virsh. Setelah storage volume dibuat nantinya Anda dapat menambahkan ke VM

Create volume
#

virsh vol-create-as --pool [nama pool] --name [nama volume.qcow2] --capacity 20GiB --format qcow2 --print-xml
Note: 
format - jenis format. bisa berupa qcow2 atau raw
capacity - size volume. MiB atau GiB

Output akan seperti ini

root@srv1:~# virsh vol-create-as --pool pool1 --name ubuntu22-aws-0.qcow2 --capacity 20GiB --format qcow2 --print-xml
<volume>
  <name>ubuntu22-aws-0.qcow2</name>
  <capacity>21474836480</capacity>
  <target>
    <format type='qcow2'/>
  </target>
</volume>

Buat file vol.xml

root@srv1:~# virsh vol-create-as --pool pool1 --name ubuntu22-aws-0.qcow2 --capacity 20GiB --format qcow2 --print-xml  > vol.xml

Selanjutnya buat volume dari file xml tersebut

virsh vol-create --pool [nama pool] --file vol.xml
root@srv1:~# virsh vol-create --pool pool1 --file vol.xml
Vol ubuntu22-aws-0.qcow2 created from vol.xml

Attach volume ke VM
#

virsh attach-disk --domain [domain] --source [path volume] --target [target disk] --cache none --subdriver qcow2 --config
root@srv1:~# virsh attach-disk --domain ubuntu22-aws --source /var/lib/libvirt/images/ubuntu22-aws-0.qcow2 --target vdb --cache none --subdriver qcow2 --live --config
Disk attached successfully

Cek disk VM
#

Jika disk sudah diattach ke VM. Langkah terakhir Anda dapat login ke VM dan cek dengan perintah lsblk

root@aws-cli:~# lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0              7:0    0 63.3M  1 loop /snap/core20/1778
loop1              7:1    0 49.6M  1 loop /snap/snapd/17883
loop2              7:2    0 49.8M  1 loop /snap/snapd/17950
loop3              7:3    0  103M  1 loop /snap/lxd/23541
vda              252:0    0    3G  0 disk
├─vda1           252:1    0  2.9G  0 part
│ └─vg_root-root 253:0    0  2.9G  0 lvm  /
├─vda14          252:14   0    4M  0 part
└─vda15          252:15   0  106M  0 part /boot/efi
vdb              252:16   0   20G  0 disk

Terlihat jika disk vdb berhasil terdeteksi ke system dengan size 20GB

Related

Setting VirtioFS untuk Shared Folder VM
·2 mins
libvirt kvm libvirt
Menambah Space Logical Volume pada LVM
·3 mins
lvm lvm
Setting static website Amazon S3
·2 mins
aws aws
Setup AWS CloudFront distribution dengan S3 Origin
·2 mins
aws aws
Setting Bucket policy Amazon S3
·2 mins
aws aws
Cara membuat Bucket di Amazon S3
·1 min
aws aws