QEMU支持一种临时的快照,利用临时快照,可以很方便的做实验,然后不会留下使用痕迹,类似于“用后即焚‘的模式。
2. 查看qemu打开的文件
[root@pc qemu]# qemu-system-x86_64 -h|grep "\-snapshot" -A3 -B3 --color
-mtdblock file use 'file' as on-board Flash memory image
-sd file use 'file' as SecureDigital card image
-pflash file use 'file' as a parallel flash image
-snapshot write to temporary files instead of disk image files
-hdachs c,h,s[,t]
force hard disk 0 physical geometry and the optional BIOS
translation (t=none or lba) (usually QEMU can guess them)
使用该模式,会产生一个临时文件,来记录对磁盘的写操作,而对原来的磁盘并不真正执行读写操作。在虚拟机关机的时候,自动将临时文件删除。这样,我们可以在原镜像上安装一个干净的系统,然后通过qemu加上-snapshot启动它,实验完成之后,也不需要手工清除临时文件,真正做到甩手掌柜。
1. 启动操作系统系统
[root@pc images]# qemu -drive if=virtio,file=centos65_base.img -snapshot --enable-kvm --vnc :8 -m 2048
2. 查看qemu打开的文件
[root@pc ~]# ps -ef|grep qemu|grep snapshot|grep -v grep
root 20890 20129 11 17:29 pts/0 00:00:19 qemu -drive if=virtio,file=centos65_base.img -snapshot --enable-kvm --vnc :8 -m 2048
[root@pc ~]# lsof |grep 20890
qemu 20890 root cwd DIR 253,2 4096 21889025 /home/images
qemu 20890 root rtd DIR 253,0 4096 2 /
qemu 20890 root txt REG 253,0 15198134 941595 /usr/local/bin/qemu-system-x8