感谢朋友支持本博客,欢迎共同探讨交流,由于能力和时间有限,错误之处在所难免,欢迎指正!
如有转载,请保留源作者博客信息。
如需交流,欢迎大家博客留言。
![](http://static.oschina.net/uploads/img/201603/29092215_Lm3B.jpg)
首先测试默认镜像cirros:
![](http://static.oschina.net/uploads/img/201603/29092215_M9yT.jpg)
1、virt-cat:
![](http://static.oschina.net/uploads/img/201603/29092215_H9ph.jpg)
-a :使用镜像文件
-d :使用domain
![](http://static.oschina.net/uploads/img/201603/29092216_zQXc.jpg)
virt-cat -d instance-0000003f /etc/passwd
|
![](http://static.oschina.net/uploads/img/201603/29092216_OB25.jpg)
可以看到读取出来的文件。
![](http://static.oschina.net/uploads/img/201603/29092216_VIP1.jpg)
virt-edit -d instance-0000003f /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092216_vKpu.jpg)
提示需要关机,关机继续:
![](http://static.oschina.net/uploads/img/201603/29092216_Fm2E.jpg)
修改root密码:
将
修改为:
|
修改成功后:
![](http://static.oschina.net/uploads/img/201603/29092216_yPDz.jpg)
启动虚拟机:
![](http://static.oschina.net/uploads/img/201603/29092216_f4iH.jpg)
显示密码错误,无法登陆,说明密码修改成功了。
接下来测试centos的lvm分区的镜像实例:
![](http://static.oschina.net/uploads/img/201603/29092217_Qiv2.jpg)
virt-cat -d instance-00000040 /etc/passwd
|
![](http://static.oschina.net/uploads/img/201603/29092217_6rrp.jpg)
![](http://static.oschina.net/uploads/img/201603/29092217_vMeH.jpg)
![](http://static.oschina.net/uploads/img/201603/29092217_wKI3.jpg)
![](http://static.oschina.net/uploads/img/201603/29092217_pp0S.jpg)
编译supermin报错:
![](http://static.oschina.net/uploads/img/201603/29092218_H6Zz.jpg)
strace跟踪:
![](http://static.oschina.net/uploads/img/201603/29092218_jNhq.jpg)
yum install glibc-static
![](http://static.oschina.net/uploads/img/201603/29092218_FW5S.jpg)
yum install glib2*
![](http://static.oschina.net/uploads/img/201603/29092218_wmvI.jpg)
出现pcre错误:
![](http://static.oschina.net/uploads/img/201603/29092218_bjHm.jpg)
yum install pcre-devel pcre
![](http://static.oschina.net/uploads/img/201603/29092218_jThy.jpg)
yum install augeas
![](http://static.oschina.net/uploads/img/201603/29092218_wzVD.jpg)
![](http://static.oschina.net/uploads/img/201603/29092219_bI8W.jpg)
编译1.27.31报语法错(应该是最新版的bug)。
重新编译1.27.24版本看是否出现同样问题:
![](http://static.oschina.net/uploads/img/201603/29092219_4Nrg.jpg)
安装1.27.24成功
接下来继续试验上述lvm不能操作问题:
virt-cat -d instance-00000040 /etc/passwd
|
![](http://static.oschina.net/uploads/img/201603/29092219_xMjd.jpg)
说明libvirt没有编译到1.27.24版本:
换个方式试验:
![](http://static.oschina.net/uploads/img/201603/29092219_Og4g.jpg)
验证lvm系统centos6.5镜像文件:
virt-cat -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092219_hNPF.jpg)
再来验证下cirros镜像:
![](http://static.oschina.net/uploads/img/201603/29092219_wrjE.jpg)
得出结论无论是lvm还是sda分区都能virt-cat。
再用root和密码yunjisuan登陆:
![](http://static.oschina.net/uploads/img/201603/29092219_Gvlp.jpg)
登陆成功。
接下来继续试验virt-edit修改密码功能:
原始密码文件:
![](http://static.oschina.net/uploads/img/201603/29092219_zobc.jpg)
virt-edit -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
修改为:
![](http://static.oschina.net/uploads/img/201603/29092220_zNlN.jpg)
保存退出。(
提醒:大家有没有注意到新版的密码修改不需要和老版本一样需要关机!!!!)
重新登陆密码没有成功修改:
![](http://static.oschina.net/uploads/img/201603/29092220_H5Gl.jpg)
再次打开虚拟机密码文件:
virt-edit -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092220_EDRu.jpg)
变成了乱码。汗!!!!
关机重试:
![](http://static.oschina.net/uploads/img/201603/29092220_5S3S.jpg)
virt-edit -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092220_JsXt.jpg)
virt-cat -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092220_dMiT.jpg)
关机之后修改没有出现乱码。
重启机器登陆:
![](http://static.oschina.net/uploads/img/201603/29092220_wfZG.jpg)
页面重启:
![](http://static.oschina.net/uploads/img/201603/29092220_keDr.jpg)
![](http://static.oschina.net/uploads/img/201603/29092221_GhSs.jpg)
可能由于升级了新版的qemu-kvm导致。
![](http://static.oschina.net/uploads/img/201603/29092221_tZbO.jpg)
qemu-kvm在编译libgutstfs时候被替换成1.2.0,因此我们回去之前版本:
![](http://static.oschina.net/uploads/img/201603/29092221_2i2t.jpg)
![](http://static.oschina.net/uploads/img/201603/29092221_rAjF.jpg)
重新生成虚拟机:
![](http://static.oschina.net/uploads/img/201603/29092221_kOe8.jpg)
成功。
![](http://static.oschina.net/uploads/img/201603/29092222_ouHe.jpg)
![](http://static.oschina.net/uploads/img/201603/29092222_iuYA.jpg)
继续上述测试,为了防止乱码,先关闭虚拟机再操作:
![](http://static.oschina.net/uploads/img/201603/29092222_3VeB.jpg)
virt-edit -a /var/lib/nova/instances/76f00ea2-16a8-41e2-b128-6357634edbb9/disk /etc/shadow
|
![](http://static.oschina.net/uploads/img/201603/29092222_jmRl.jpg)
可能由于qemu-kvm被替换掉原因,替换回去1.2.0:
![](http://static.oschina.net/uploads/img/201603/29092222_xWAD.jpg)
接下来就能修改虚拟机文件了:
![](http://static.oschina.net/uploads/img/201603/29092222_lxD5.jpg)
重启机器继续出错:
![](http://static.oschina.net/uploads/img/201603/29092222_Y1V7.jpg)
替换回原来的qemu-kvm:
![](http://static.oschina.net/uploads/img/201603/29092222_ZwWe.jpg)
页面重启虚拟机成功:
![](http://static.oschina.net/uploads/img/201603/29092227_evj8.jpg)
![](http://static.oschina.net/uploads/img/201603/29092227_im21.jpg)
此时用root,cdyanfa 登陆密码不正确,说明lvm镜像面膜被修改成功了。
![](http://static.oschina.net/uploads/img/201603/29092228_6NEH.jpg)
结论:
opesntack中不能将密码或者keypair注入到lvm分区的镜像中去导致原因可能有两个:
1、openstack环境中的libguestfs的版本太低(这个最大)
2、openstack调用libguestfs的驱动模块代码有bug(大概看了下源码,似乎这个也有些问题)
|