zoukankan      html  css  js  c++  java
  • openstack中修改centos7 镜像的root密码

    第一步:需要我们提前准备好镜像,具体的镜像可以自己在官网下载,国内的建议在 (中科大https://mirrors.ustc.edu.cn/

    由于我不知道root的密码,使用下面的方法修改centos7镜像的root密码

    第二步:安装软件libguestfs-tools

    [root@node152 ~]# yum install libguestfs-tools -y

    第三步,设定一个固定密码

    [root@node152 ~]# virt-customize -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --root-password password:123456

    执行过程

    [root@node152 ~]# virt-customize -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --root-password password:123456
    [   0.0] Examining the guest ...
    virt-customize: error: 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 
    '/root/CentOS-7-x86_64-GenericCloud-2009.qcow2' (as uid:107, gid:107): 
    Permission denied [code=38 int1=13]
    If reporting bugs, run virt-customize with debugging enabled and include 
    the complete output:
    virt-customize -v -x [...]

    上面提示错误。 没有LIBGUESTFS_BACKEND 环境变量
    第四步,临时增加LIBGUESTFS_BACKEND 环境变量

    [root@node152 ~]# export LIBGUESTFS_BACKEND=direct
    

    第五步,再次执行设定固定密码的命令,设置密码为123456

    [root@node152 ~]# virt-customize -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --root-password password:123456

    执行过程

    [root@node152 ~]# virt-customize -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --root-password password:123456
    
    [ 0.0] Examining the guest ...
    [ 5.6] Setting a random seed
    [ 5.7] Setting passwords
    [ 7.3] Finishing off
    

    设置成功

    上传镜像并通过该镜像创建实例,使用刚才设置的root密码登录成功。

    openstack上传镜像查看上期博文openstack-glance上传镜像实践

  • 相关阅读:
    Jquery:强大的选择器<一>
    要经营我的园子了!!!
    Json在Struts中的转换与传递
    MyEclipse快捷键大全
    Pyqt在QListWidget中添加右键菜单
    swift中Double转String
    Spring MVC 关于分页的简单实现
    Spring MVC 通过@Value注解读取.properties配置内容
    SQL 查询语句(备份)
    Idea使用说明
  • 原文地址:https://www.cnblogs.com/xzlive/p/15009855.html
Copyright © 2011-2022 走看看