美文网首页
guesfs-tools 心得

guesfs-tools 心得

作者: ShingV | 来源:发表于2017-04-13 15:47 被阅读0次

    安装guestfish
    我的环境是centos7
    安装:

    $yum -y  install libguestfs-tools  
    

    ** 打开镜像:**
    遇到的问题

    libguestfs: error: could not create appliance through libvirt.

    Try running qemu directly without libvirt using this >environment variable:
    export LIBGUESTFS_BACKEND=direct

    Original error from libvirt: Cannot access storage file '/home/user/xenial-server-cloudimg-amd64-disk1.img' (as uid:107, gid:107): Permission denied [code=38 int1=13]
    解决方法:
    http://manpages.ubuntu.com/manpages/xenial/man1/guestfs-faq.1.html

    "Permission denied" when running libguestfs as root
    You get a permission denied error when opening a disk image, even
    though you are running libguestfs as root.

       This is caused by libvirt, and so only happens when using the libvirt
       backend.  When run as root, libvirt decides to run the qemu appliance
       as user "qemu.qemu".  Unfortunately this usually means that qemu cannot
       open disk images, especially if those disk images are owned by root, or
       are present in directories which require root access.
    
       There is a bug open against libvirt to fix this:
       https://bugzilla.redhat.com/show_bug.cgi?id=1045069
    
       You can work around this by one of the following methods:
    
       ·   Switch to the direct backend:
    
            export LIBGUESTFS_BACKEND=direct
    
       ·   Don't run libguestfs as root.
    
       ·   Chmod the disk image and any parent directories so that the qemu
           user can access them.
    
       ·   (Nasty) Edit /etc/libvirt/qemu.conf and change the "user" setting.
    
    $ sudo guestfish --rw -a trusty-server-cloudimg-amd64-disk1.img  
    
    如有必要,请加上sudo.
    **运行镜像**:
    

    <fs> run
    100% [############################################] 00:00

    **列出所有的文件系统:**
    

    <fs> list-filesystems
    /dev/sda1: ext4

    **挂载到根目录**:
    

    <fs> mount /dev/sda1 /

    **编辑/etc/cloud/cloud.cfg文件,修改默认用户ubuntu的密码**:
    

    <fs> vi /etc/cloud/cloud.cfg

    找到default_user字段
    1.把lock_passwd:True修改为:lock_passwd:false.lock_passwd默认为true,锁定密码禁用密码登陆,因此我们要改成false
    2.增加plain_text_passwd:'你要设置的密码'.例如我的:
    

    然后退出,将镜像上传到openstack,启动实例,就能使用用户名密码登陆了.

    相关文章

      网友评论

          本文标题:guesfs-tools 心得

          本文链接:https://www.haomeiwen.com/subject/fzbbattx.html