fs:Pre-Formatted Block Device

libvirtd 会自动 mount 分区

  • 准备分区并创建文件系统

一、通过 virt-manager 创建基于分区的存储池

[root@k-node2 ~]# virsh pool-list
名称                         状态     自动开始
-------------------------------------------
default                     活动     是       
guest_images_fs             活动     否       
iso                         活动     是       
vm                          活动     是       

[root@k-node2 ~]# virsh pool-info guest_images_fs
名称:       guest_images_fs
UUID:       43f9df86-498a-4ec0-a95f-e5e399ac6f90
状态:       running
持久:       是
自动启动:    否
容量:       39.25 GiB
分配:       48.02 MiB
可用:       39.20 GiB

[root@k-node2 ~]# ll /guest_images/ -d
drwxr-xr-x 3 root root 4096 5月   4 21:48 /guest_images/

[root@k-node2 ~]# mount |grep sdc1            #<--自动mount
/dev/sdc1 on /guest_images type ext4 (rw,relatime,data=ordered)

二、通过 virsh 创建基于分区的存储池

[root@k-node2 ~]# virsh pool-define-as guest_images_fs fs --source-dev "/dev/sdc1" --target "/guest_images2"
定义池 guest_images_fs
[root@k-node2 ~]# virsh pool-list --all
名称                         状态     自动开始
-------------------------------------------
default                     活动     是       
guest_images_fs             不活跃   否       
iso                         活动     是       
vm                          活动     是       


[root@k-node2 ~]# virsh pool-start guest_images_fs
错误:启动池 guest_images_fs 失败
错误:internal error: 子进程(/usr/bin/mount -t auto /dev/sdc1 /guest_images2)意外 退出状态 32: mount: 挂载点 /guest_images2 不存在

[root@k-node2 ~]# mkdir /guest_images2

[root@k-node2 ~]# virsh pool-start guest_images_fs
池 guest_images_fs 已启动

[root@k-node2 ~]# virsh pool-list --all           
名称                         状态     自动开始
-------------------------------------------
default                     活动     是       
guest_images_fs             活动     否       
iso                         活动     是       
vm                          活动     是      
[root@k-node2 ~]# virsh pool-destroy guest_images_fs
销毁池 guest_images_fs

[root@k-node2 ~]# virsh pool-delete guest_images_fs
池 guest_images_fs 被删除

[root@k-node2 ~]# virsh pool-undefine guest_images_fs
池 guest_images_fs 已经被取消定义