QEMU 일반 명령

3789 단어 가상화

QEMU 일반 명령:


1. 이미지 만들기, qcow2 형식과raw 형식의 대비

[root@andriy qemu]# qemu-img create -f raw test.img 5G
Formatting 'test.img', fmt=raw size=5368709120 
[root@andriy qemu]# file test.img
test.img: data
[root@andriy qemu]# qemu-img info test.img
image: test.img
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 0
[root@andriy qemu]# qemu-img create -f qcow2 test2.img 10G
Formatting 'test2.img', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off 
[root@andriy qemu]# file test2.img
test2.img: QEMU QCOW Image (v3), 10737418240 bytes
[root@andriy qemu]# qemu-img info test2.img
image: test2.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
[root@andriy qemu]# ll -h test*
-rw-r--r-- 1 root root 193K Aug 30 14:53 test2.img
-rw-r--r-- 1 root root 5.0G Aug 30 14:53 test.img
[root@andriy qemu]# du -sh test*
196K	test2.img
0	test.img


2. 이미지 파일 확인: raw에서 check이 지원되지 않습니다.

[root@andriy qemu]# qemu-img check test.img 
qemu-img: This image format does not support checks
[root@andriy qemu]# qemu-img check test2.img
No errors were found on the image.
Image end offset: 262144

3. 이미지 파일에 대한 조작 가능 옵션

[root@andriy qemu]# qemu-img create -f qcow2 -o ? test2.img
Supported options:
size             Virtual disk size
compat           Compatibility level (0.10 or 1.1)
backing_file     File name of a base image
backing_fmt      Image format of the base image
encryption       Encrypt the image
cluster_size     qcow2 cluster size
preallocation    Preallocation mode (allowed values: off, metadata, falloc, full)
lazy_refcounts   Postpone refcount updates

4. filename 파일의 변경 사항을 백엔드 지원 미러 파일로 제출합니다(만들 때 backing file을 통해 지정됨).

[root@andriy qemu]# qemu-img commit test2.img

5. 변환 형식

[root@andriy qemu]# qemu-img convert -f qcow2 -O raw test2.img raw.img      #qcow2 raw 
[root@andriy qemu]# qemu-img info raw.img 
image: raw.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 0
[root@andriy qemu]# qemu-img convert -f raw -O qcow2 raw.img qcow2.img      #raw qcow2 
[root@andriy qemu]# qemu-img info qcow2.img 
image: qcow2.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false

6. 미러 확장: raw 확장만 지원

[root@andriy qemu]# qemu-img resize raw.img -/+1G
[root@andriy qemu]# qemu-img resize raw.img 11G
Image resized.
[root@andriy qemu]# qemu-img info raw.img 
image: raw.img
file format: raw
virtual size: 11G (11811160064 bytes)
disk size: 0
[root@andriy qemu]# qemu-img resize raw.img -1G
Image resized.
[root@andriy qemu]# qemu-img info raw.img 
image: raw.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 0

7. 스냅샷 작업

“-l”  ,“-a snapshot” ,“-c snapshot” ,“-d” 。
[root@andriy qemu]# qemu-img snapshot -l qcow2.img 
[root@andriy qemu]# qemu-img snapshot -c snapshot qcow2.img 
[root@andriy qemu]# ls
qcow2.img  raw.img  test2.img  test.img
[root@andriy qemu]# qemu-img snapshot -l qcow2.img 
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         snapshot                  0 2017-08-30 15:18:25   00:00:00.000
qemu-img snapshot -a 1 qcow2.img
[root@andriy qemu]# qemu-img snapshot -d snapshot qcow2.img

8. 파생 렌즈 사용

[root@andriy qemu]# qemu-img create -f qcow2 vm.qcow2 -o backing_file=qcow2.img

좋은 웹페이지 즐겨찾기