guestfish 命令修改镜像文件

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 








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值