使用guestfish或者guestmount命令修改Windows镜像administrator用户密码的方法(要保证Windows镜像是正常关机的,否则会产生系统缓存文件造成guestmount无法挂载磁盘分区。):
1.#yum install libguestfs-winsupport
2.#vim /etc/libvirt/qemu.conf:
把user和group都改成root
3.#systemctl restart libvirtd
4.使用guestfish进行修改镜像:
#guestfish -a win2012-monitor.qcow2
5.执行#run去挂载windows镜像。
6.执行#list-filesystems查看分区。
7.挂载分区,执行#mount /dev/sda2 / 。一般Windows的C盘默认为/dev/sda2。
8.cp /Windows/System32/Utilman.exe /Windows/System32/Utilman.exe.bak 备份轻松访问的程序。
cp /Windows/System32/cmd.exe /Windows/System32/Utilman.exe 使用“命令行提示符”替换“轻松访问”。
exit退出修改镜像的操作命令行。
9.#vim /etc/libvirt/qemu.conf:
注释掉user和group="root"的选项。
10.使用Windows镜像打开虚拟机后,点击“轻松访问”。点击后会弹出Windows的“命令提示符”窗口。
11.在命令提示符窗口中输入net user administrator abcdef123...
12.在命令行提示符窗口中输入输入shutdown.exe -r -f -t 0或者shutdown.exe -s -t 0执行立即重启或者关机,然后打开Windows操作系统,使用 abcdef123...进行系统登录。
13.开启虚拟机系统后,到Windows系统的 文件夹下,重命名Utilman.exe.bak为Utilman.exe,恢复文件的原始数据。