Création de snapshot/instantané d'image avec Qemu. 1) Information sur l'image de base :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img info vhda.img
image: vhda.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 10G
2) Conversation de l'image au format raw vers une imageau format qcow2 :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img create -b vhda.img -f qcow2 vhda.qcow2
Formatting 'vhda.qcow2', fmt=qcow2 size=10737418240 backing_file=vhda.img encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
3) Information sur la nouvelle image qcow2 :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img info vhda.qcow2
image: vhda.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536
backing file: vhda.img
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
4) Prendre un snapshot :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img snapshot -c snapshot_160104_2040 vhda.qcow2
5) Liste des snapshots lié à l'image de base :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img snapshot -l vhda.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 snapshot_160104_2040 0 2016-01-04 20:40:55 00:00:00.000
6) Lancer la distribution avec l'image qcow2 :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-system-i386 -enable-kvm -k fr -m 1024 -sdl -soundhw hda,ac97 -vga std -hda vhda.qcow2 -boot c -smp 2 -localtime -net nic,macaddr='DE:AD:BE:EF:00:01' -net tap,ifname=tap0,script=no -no-quit
7 ) Installer l'application de traitement d'image "Gimp" : Noter la taille occupé par les données avant et après l'installation sur le disque virtuel : Avant : Taille : 8,6 Go Utilisé : 3,4 Go Disponible : 4,8 go Après : Taille : 8,6 Go Utilisé : 3,5 Go Disponible : 4,7 go 8) Tester le bon fonctionnement de Gimp. 9) Quitter Qemu 10) Créer un snapshot :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img snapshot -c snapshot_gimp vhda.qcow2
11) Liste les snapshots disponible :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img snapshot -l vhda.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 snapshot_160104_2040 0 2016-01-04 20:40:55 00:00:00.000
2 snapshot_gimp 0 2016-01-04 21:02:35 00:00:00.000
12) Charger un ancien snapshot :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img snapshot -a snapshot_160104_2040 vhda.qcow2
13) Lancer Qemu :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-system-i386 -enable-kvm -k fr -m 1024 -sdl -soundhw hda,ac97 -vga std -hda vhda.qcow2 -boot c -smp 2 -localtime -net nic,macaddr='DE:AD:BE:EF:00:01' -net tap,ifname=tap0,script=no -no-quit
Récupérer la taille du disque : Taille : 8,6 Go Utilisé : 3,4 Go Disponible : 4,8 go Gimp n'est pas installé. 14) Conversion d'un snapshot en image raw :
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-img convert -s snapshot_gimp vhda.qcow2 -O raw gimp.img
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ ls -l
total 14514396
-rw-r--r-- 1 util01 util01 10737418240 janv. 5 20:10 gimp.img
-rw-r--r-- 1 util01 util01 10737418240 janv. 4 19:07 vhda.img
-rw-r--r-- 1 util01 util01 178847744 janv. 5 19:13 vhda.qcow2
[~/VIRTUALISATION/PuppyTahr/vhda] ➔ qemu-system-i386 -enable-kvm -k fr -m 1024 -sdl -soundhw hda,ac97 -vga std -hda gimp.img -boot c -smp 2 -localtime -net nic,macaddr='DE:AD:BE:EF:00:01' -net tap,ifname=tap0,script=no -no-quit