http://libguestfs.org/guestfish.1.html guestfish命令使用方法详解
此操作在centos7进行
1、安装guestfish 命令
[root@localhost etc]# yum install guestfish
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2016-05-28.00-34._SrfSu.yumtx
[root@localhost etc]# yum load-transaction /tmp/yum_save_tx.2016-05-28.00-34._SrfSu.yumtx
Installed:
libguestfs-tools-c.x86_64 1:1.28.1-1.55.el7.centos.4
Dependency Installed:
hexedit.x86_64 0:1.2.13-5.el7 libconfig.x86_64 0:1.4.9-5.el7
Complete!
[root@localhost etc]# guest
guestfish guestmount guestunmount
安装完成后有三个命令!
2、用root用户挂载这个镜像为可读可写模式
[root@localhost ~]#guestfish --rw -a cirros-0.3.4-x86_64-uec.tar.gz
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs>
进入了 guestfish 会话
在做任何操作之前,必须先在 guestfish提示符运行run命令。它会启动一个虚拟机,用于完成我们所以的对文件的操作。
><fs>run
libvirt: XML-RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
libguestfs: error: could not connect to libvirt (URI = qemu:///system): Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory [code=38 domain=7]
源码安装libvirt:
http://www.mamicode.com/info-detail-247948.html
[root@localhost ~]# wget http://libvirt.org/sources/libvirt-1.2.5.tar.gz
通过list-filesystems命令,我们可查看镜像内的文件系统列表:
><fs> list-filesystems
未完待续。。。。。
subscription-manager attach --auto
virt-filesystems(1) ― display information about filesystems, devices, LVM 显示镜像文件系统信息。
【挂载命令】
guestmount -a centos7_1.qcow2 -m /dev/sda1 --ro /mnt/
【列出虚拟机镜像文件分区信息】
virt-filesystems - List filesystems, partitions, block devices, LVM in a virtual machine or disk image
列出虚拟机镜像文件文件系统,分区,块设备,lvm信息
virt-alignment-scan
【查看文件系统】
virt-list-partitions centos6232.qcow2
/dev/sda1
/dev/sda2
virt-list-filesystems centos6232.qcow2
/dev/sda1
/dev/vmvg/root
yum install libguestfs-tools
http://www.tuicool.com/articles/va2qmmU
subscription-manager register 【ppc64 redhat 更新源】
nco-china-lucy 【用户名密码】
guestmount -a /opt/ywt/centos6.8-ywt.qcoww -m /dev/VolGroup/lv_root --rw /mnt/
vim /mnt/etc/cloud/cloud.cfg.d/05_logging.cfg
guestunmount /mnt/
glance image-create --name centos6.8-ywt --file /opt/ywt/centos6.8-ywt.qcoww --container-format bare --disk-format qcow2 --progress