本次实验为了验证下面场景下,磁盘是否可以被在线卸载?如果可以被卸载,那么是否可以再次被在线挂载?
场景:磁盘被挂载到虚机后,通过LVM已经创建PV,追加给LV,并且被格式化,将空间扩展给了filesystem。
执行在线卸载磁盘命令,成功!
# virsh detach-disk LDAP05 sdc
Disk detached successfully
再次在线挂载磁盘时,报错:
# virsh attach-disk LDAP05 /var/lib/libvirt/images/LDAP05-02.img sdc --cache none --targetbus scsi --subdriver qcow2 --live
error: Failed to attach disk
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-scsi0-0-0-2' could not be initialized
还以为不支持在线再次挂载,度娘、谷哥半天原因未果!还是回到测试环境,查看/var/log/libvirt/qemu/LDAP05.log日志,发现如下报错:
Image is not in qcow2 format
豁然开朗,/var/lib/libvirt/images/LDAP05-02.img镜像文件是raw格式的!
上一篇内容讲到将qcow2按照raw格式挂载给虚拟机,捕获报错,但是磁盘大小只有一百多KB
本篇碰巧验证了将raw格式磁盘按照qcow2挂载给虚拟机,直接报错:
error: Failed to attach disk
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-scsi0-0-0-4' could not be initialized
引起这个错误的原因很多,需要查看虚机日志文件查看真正的原因进行解决。