Virtiofs adalah shared file system yang memungkinkan mesin virtual mengakses directory tree yang ada di host
Buat xml memorybacking
edit domain dan attach memorybacking dengan perintah berikut
virt-xml <domain> --edit --memorybacking access.mode=shared,source.type=memfd
Output
[root@srv1 ~]# virt-xml domain --edit --memorybacking access.mode=shared,source.type=memfd
Domain 'domain' defined successfully.
Changes will take effect after the domain is fully powered off.
Lalu poweroff VM dan start kembali
Buat xml untuk virtiofs
Perintahnya seperti berikut
virt-xml <domain> --build-xml --print-xml --filesystem /mnt/iso/,isoblk,driver.type=virtofs,accessmode=passthrough
opsi pada filesystem
- /mnt/iso : folder yang ingin kalian share
- isoblk : nama block device.
Output
<filesystem accessmode="passthrough" type="mount">
<source dir="/mnt/iso/"/>
<target dir="isoblk"/>
<driver type="virtofs"/>
</filesystem>
Attach ke live VM dengan perintah berikut
virsh attach-device --domain <domain> --file fs.xml --live
Output
[root@srv1 ~]# virsh attach-device --domain domain --file fs.xml --live
Device attached successfully
Mount virtiofs di VM
Setelah attach berhasil, selanjutnya coba mounting sesuai nama block device
mount -t virtiofs isoblk /path/dir/
Output
[root@localhost ~]# mount -t virtiofs isoblk /mnt/gud/
[ 311.629239] SELinux: (dev virtiofs, type virtiofs) has no security xattr handler
[ 311.634281] SELinux: (dev virtiofs, type virtiofs) falling back to genfs
Cek file system disk
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 367M 0 367M 0% /dev
tmpfs tmpfs 403M 0 403M 0% /dev/shm
tmpfs tmpfs 403M 11M 392M 3% /run
tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup
/dev/vda1 xfs 7.9G 1.5G 6.4G 19% /
tmpfs tmpfs 81M 0 81M 0% /run/user/0
isoblk virtiofs 23G 6.1G 17G 27% /mnt/gud