centos7修改qcow2镜像格式默认密码

libguestfs介绍

libguestfs 是一组 Linux 下的 C 语言的 API ,用来访问或修改虚拟机的磁盘映像文件的工具。具体介绍请浏览:https://libguestfs.org/
下载qcow格式的centos镜像

在这里插入图片描述 启动libvirtd服务

在这里插入图片描述


[root@localhost tmp]# openssl passwd -1 123456   #利用openssl生成123456的加密密文
$1$igJ4poz3$pp1r0UaCtDfii244r0dpe/
[root@localhost tmp]# guestfish CentOS-7-x86_64-GenericCloud-2009.qcow2c 
CentOS-7-x86_64-GenericCloud-2009.qcow2c: unknown command
Did you mean to open a disk image?  guestfish -a disk.img
For a list of commands:             guestfish -h
For complete documentation:         man guestfish
[root@localhost tmp]# guestfish --rw -a CentOS-7-x86_64-GenericCloud-2009.qcow2c 

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> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
><fs> list-filesystems 
/dev/sda1: xfs
><fs> mount /dev/sda1 /
><fs> vi /etc/shadow  #替代root的秘密,利用前面openssl生成的密码
><fs> quit
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值