openstack中修改centos7 镜像的root密码

时间:2021-07-14
本文章向大家介绍openstack中修改centos7 镜像的root密码,主要包括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上传镜像实践

原文地址:https://www.cnblogs.com/xzlive/p/15009855.html