宿主机命令
前提:yum -y install libguestfs libguestfs-tools
1.virt-inspector 查看虚拟磁盘文件所有信息
注意:
1)尽量输入绝对路径,否则提示找不到;后面可以加管道符more,以分页显示
2)建议虚拟机关机操作,只有少数操作支持开机操作
virt-inspector --format=qcow2 -a /kvm_store/centos7.1.qcow2 | more
2.virt-cat 查看虚拟机内部文件信息
virt-cat -a centos7.qcow2 /etc/hostname
3.virt-edit 修改虚拟机文件
virt-edit -a /kvm_store/vmtest03.qcow2 /etc/hostname
修改为:resize
4.virt-df 统计查看虚拟机磁盘使用情况
virt-df -h -a centos7.qcow2
5.virt-copy-out 复制虚拟机文件到外部
virt-copy-out -d clone01 /etc/hostname /tmp/
本地Linux主机查看导出的文件
6.virt-copy-in复制本地文件到虚拟机内部
echo “hehehe” > /root/hehe.txt
virt-copy-in -d clone01 /root/resize.txt /tmp/
virt-cat -a centos7.qcow2 /tmp/hehe.txt
7.guestfish 交互式查看虚拟机内部文件
仅支持部分命令。
guestfish --rw -i -d centos7.0
8.guestmount 挂载虚拟机分区到外部目录,并测试
mkdir /centos7_root
guestmount -a centos7.qcow2 -m /dev/cl/root --rw /centos7_root