티스토리 뷰

VMware 이미지를 변환하기 전에는 병합이 필요합니다. VMware 이미지 병합은 링크를 참고해주세요.

 

◎ QEMU 을 통한 이미지 변환

QEMU 는?

- 가상화 소프트웨어 가운데 하나입니다.

- Fabrice Bellard 가 만들었으며 x86 이외의 기종을 위해 만들어진 소프트웨어 스택 전체를 가상머신 위에서 실행할 수 있다는 특징이 있습니다.

- 동적 변환기(Portable dynamic translation)를 사용합니다.

- PC 환경을 위한 프로세스 에뮬레이터로 프로세스뿐만 아니라 각종 주변기기까지를 에뮬레이터 합니다.

- 하나의 가상 컴퓨터를 구축해 주는 소프트웨어입니다. vmware, Xen, Virtualbox 와 같은 가상화 솔루션의 하나로 보시면 됩니다.

 

사용자 환경에 따라 리눅스나 윈도우용 QEMU를 설치하면 qemu-img 를 이용하여 이미지를 변환할 수 있습니다.

먼저, qemu-img 를 이용해서 이미지 정보를 확인하고, 생성하는 명령어부터 보겠습니다.

 

[이미지 정보 확인]

# qemu-img info 이미지명

 # qemu-img info image.raw

 

[이미지 생성]

# qemu-img create -f 이미지포맷명 이미지명 이미지크기

 # qemu-img create {-f raw} out.raw 4G

※ 기본포맷이 raw 이기 때문에 생략이 가능합니다.

 

o 이미지 포맷 o

raw : Raw 이미지

vdi : VirtualBox 이미지

vmdk : VMwarw 이미지

※ qemu-img 가 지원하는 이미지 포맷 종류는 더 있으나 여기서는 3가지만 알면 되겠습니다.

 

 # qemu-img create -f vmdk out.vmdk 4G
 또는
 # qemu-img create -f vmdk -o size=4G out.vmdk
 또는
 # qemu-img create -f vdi out.vdi 4G

 

이제 우리가 주로 사용하게 될 이미지를 변환하는 명령어를 보겠습니다.

 

[이미지 변환]

# qemu-img convert {-f 기본포맷} -O 변환포맷 기본이미지명 변환이미지명 {-q} {-p}

※ 기본포맷, -q , -p 옵션은 생략이 가능합니다.

 

o 이미지 포맷 o

raw : Raw 이미지

vdi : VirtualBox 이미지

vmdk : VMwarw 이미지

vhd(x) : HYPER-V 이미지

 # qemu-img convert {-f raw} -O vmdk in.raw out.vmdk
 또는
 # qemu-img convert {-f raw} -O vdi in.raw out.vdi
 또는
 # qemu-img convert {-f vmdk} in.vmdk {-O raw} out.img -p
또는
# qemu-img convert {-f vmdk} -O vhdx in.vmdk out.vhdx

※ VMDK 에서 VDI 는 직접 변환이 불가합니다.

 

-o : compat, backing_file, backing_fmt, encryption, cluster_size, preallocation, lazy_refcounts 등 관련 옵션이 굉장히 많은 듯 싶은데 정확한 설명을 찾아보기가 어렵네요. 특정 옵션의 경우 지원 가능한 포맷이 정해져 있습니다.

-O : 변환될 포맷을 지정합니다.

-p : 진행 상태 바를 표시합니다. (compare, convert, rebase 커맨드 한정) -p 옵션을 지원하지 않는 커맨드의 경우, 진행상황은 프로세스가 SIGUSR1 신호를 받았을 때 보고됩니다.

-q : 침묵 모드로 오류를 제외한 다른 메세지들을 출력하지 않습니다. -q와 -p를 동시에 사용하면 진행 상태 바가 표시되지 않습니다.

 

 Vmdk2Vhd 을 통한 이미지 변환

[이미지 변환]

Vmdk2Vhd는 링크에서 다운받으세요.

다운받은 압축파일을 해제하고 Vmdk2Vhd.exe를 엽니다. VMDK 파일을 선택하는 창이 열립니다.
소스 VMDK 및 대상 VHD를 선택하고 변환을 클릭합니다. 

 

◎ VBoxManage 을 통한 이미지 변환

VirtualBox 설치 시 제공되는 VBoxManage 를 이용해서 이미지를 변황해 보겠습니다.

Raw 이미지를 vmdk로 변환 합니다.

 C:\> VBoxManage convertfromraw in.raw out.vmdk --format VMDK 
 C:\> VBoxManage convertdd in.raw out.vmdk

 

VMDK 에서 VDI 로 직접 변환이 가능합니다.

 C:\> VBoxManage clonehd in.vmdk out.vdi {--format VDI}

※ 기본포맷이 VDI 이기 때문에 생략이 가능합니다.

 

 C:\> VBoxManage convertfromraw in.raw out.vdi --format VDI
 C:\> VBoxManage convertdd in.raw out.vdi

※ Raw 이미지에서 VDI 이미지로 변환도 가능합니다.

 

 C:\> VBoxManage clonehd in.vdi out.raw --format raw
 C:\> VBoxManage internalcommands converttoraw in.vdi out.raw

※ VDI 이미지에서 Raw 이미지로 변환도 가능합니다.

 

[VBoxManage 옵션설명]

VBoxManage clonehd <uuid>|<filename> <outputfile>

[--format VDI|VMDK|VHD|RAW|<other>]

[--variant Standard,Fixed,Split2G,Stream,ESX]

[--existing]

 

o qemu-img 참고사항 o

$ qemu-img --help
qemu-img version 2.0.0, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
QEMU disk image utility


Command syntax:
  check [-q] [-f fmt] [--output=ofmt]  [-r [leaks | all]] filename
  create [-q] [-f fmt] [-o options] filename [size]
  commit [-q] [-f fmt] [-t cache] filename
  compare [-f fmt] [-F fmt] [-p] [-q] [-s] filename1 filename2
  convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] filename [filename2 [...]] output_filename
  info [-f fmt] [--output=ofmt] [--backing-chain] filename
  map [-f fmt] [--output=ofmt] filename
  snapshot [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename
  rebase [-q] [-f fmt] [-t cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
  resize [-q] filename [+ | -]size
  amend [-q] [-f fmt] -o options filename


Command parameters:
  'filename' is a disk image filename
  'fmt' is the disk image format. It is guessed automatically in most cases
  'cache' is the cache mode used to write the output disk image, the valid
    options are: 'none', 'writeback' (default, except for convert), 'writethrough',
    'directsync' and 'unsafe' (default for convert)
  'size' is the disk image size in bytes. Optional suffixes
    'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M),
    'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 1024P)  are
    supported. 'b' is ignored.
  'output_filename' is the destination disk image filename
  'output_fmt' is the destination format
  'options' is a comma separated list of format specific options in a
    name=value format. Use -o ? for an overview of the options supported by the
    used format
  'snapshot_param' is param used for internal snapshot, format
    is 'snapshot.id=[ID],snapshot.name=[NAME]', or
    '[ID_OR_NAME]'
  'snapshot_id_or_name' is deprecated, use 'snapshot_param'
    instead
  '-c' indicates that target image must be compressed (qcow format only)
  '-u' enables unsafe rebasing. It is assumed that old and new backing file
       match exactly. The image doesn't need a working backing file before
       rebasing in this case (useful for renaming the backing file)
  '-h' with or without a command shows this help and lists the supported formats
  '-p' show progress of command (only certain commands)
  '-q' use Quiet mode - do not print any output (except errors)
  '-S' indicates the consecutive number of bytes (defaults to 4k) that must
       contain only zeros for qemu-img to create a sparse image during
       conversion. If the number of bytes is 0, the source will not be scanned for
       unallocated or zero sectors, and the destination image will always be
       fully allocated
  '--output' takes the format in which the output must be done (human or json)
  '-n' skips the target volume creation (useful if the volume is created
       prior to running qemu-img)


Parameters to check subcommand:
  '-r' tries to repair any inconsistencies that are found during the check.
       '-r leaks' repairs only cluster leaks, whereas '-r all' fixes all
       kinds of errors, with a higher risk of choosing the wrong fix or
       hiding corruption that has already occurred.


Parameters to snapshot subcommand:
  'snapshot' is the name of the snapshot to create, apply or delete
  '-a' applies a snapshot (revert disk to saved state)
  '-c' creates a snapshot
  '-d' deletes a snapshot
  '-l' lists all snapshots in the given image


Parameters to compare subcommand:
  '-f' first image format
  '-F' second image format
  '-s' run in Strict mode - fail on different image size or sector allocation
  
Supported formats: vvfat vpc vmdk vhdx vdi sheepdog sheepdog sheepdog raw host_device file qed qcow2 qcow parallels nbd nbd nbd dmg tftp ftps ftp https http cow cloop bochs blkverify blkdebug

 

댓글
공지사항