VMware 이미지를 축소하려면 어떻게 해야 합니까?

VMware 이미지를 축소하려면 어떻게 해야 합니까?

무료 VMware Player를 사용하여 Windows Server 2008 시스템의 이미지를 생성하고 최대 하드 드라이브 크기를 100GB로 설정했습니다. 그런 다음 해당 이미지 파일(당시 30GB)을 서버 호스팅 회사에 제공했습니다. 몇 주 후에 나는 그들에게 사본을 돌려달라고 요청했습니다. 이미지 크기는 크게 변경되지 않았어야 했는데, 제가 돌려받은 파일은 전체 100GB 크기였습니다.

저는 VMware 전문가가 아니기 때문에 두 가지 질문이 있습니다.

  1. 전체 동적 디스크를 어떻게/왜 확장했습니까?
  2. 이 이미지를 실제로 데이터가 포함된 크기로 축소할 수 있는 방법이 있나요?

VMware 변환기를 사용해 보았는데 내 이미지(vmdk) 파일을 읽을 수 없는 것 같습니다. 단지 일반적인 오류가 출력될 뿐입니다.

답변1

내 추측은 그들이 이미지에서 VM을 생성할 때 이미지의 전체 크기를 미리 할당했다는 것입니다(이렇게 하면 성능이 더 좋아질 수 있습니다). 내보냈을 때 전체 이미지를 얻었습니다.

VMware 플레이어로 이미지를 축소할 수 있을지 의문입니다. VMware Workstation에는 고정 크기 디스크를 확장 가능한 디스크로 변환하여 이미지 크기를 줄일 수 있는 vmware-vdiskmanager가 함께 제공됩니다. 나는 이것을 시도한 적이 없으므로 그것이 얼마나 잘 작동하는지 말할 수 없습니다.

설명서는 여기에 있습니다:http://www.vmware.com/support/developer/vddk/vddk12_diskmanager.pdf

답변2

VMWare Player에 대해서는 모르지만 VMWare Workstation에는 vmware-vdiskmanager.exe 명령줄 유틸리티가 함께 제공됩니다. C:\Program Files\VMware\VMware Workstation 폴더를 찾으세요.

명령줄 옵션은 다음과 같습니다.

    VMware Virtual Disk Manager - build 385536.
    Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>
    Offline disk manipulation utility
      Operations, only one may be specified at a time:
         -c                   : create disk.  Additional creation options must
                                be specified.  Only local virtual disks can be
                                created.
         -d                   : defragment the specified virtual disk. Only
                                local virtual disks may be defragmented.
         -k                   : shrink the specified virtual disk. Only local
                                virtual disks may be shrunk.
         -n <source-disk>     : rename the specified virtual disk; need to
                                specify destination disk-name. Only local virtual
                                disks may be renamed.
         -p                   : prepare the mounted virtual disk specified by
                                the mount point for shrinking.
         -r <source-disk>     : convert the specified disk; need to specify
                                destination disk-type.  For local destination disks
                                the disk type must be specified.
         -x <new-capacity>    : expand the disk to the specified capacity. Only
                                local virtual disks may be expanded.
         -R                   : check a sparse virtual disk for consistency and attempt
                                to repair any errors.
         -D                   : make disk deletable.  This should only be used on disks
                                that have been copied from another product.

      Other Options:
         -q                   : do not log messages

      Additional options for create and convert:
         -a <adapter>         : (for use with -c only) adapter type
                                (ide, buslogic, lsilogic). Pass lsilogic for other adapter types.
         -s <size>            : capacity of the virtual disk
         -t <disk-type>       : disk type id

      Options for remote disks:
         -h <hostname>        : hostname of remote server
         -u <username>        : username for remote server
         -f <filename>        : file containing password
         -P <port>            : optional TCP port number (default: 902)
         -S                   : specifies that the source disk is remote, by default
                                the remote options are assumed to refer to the
                                destination.
      Disk types:
          0                   : single growable virtual disk
          1                   : growable virtual disk split in 2GB files
          2                   : preallocated virtual disk
          3                   : preallocated virtual disk split in 2GB files
          4                   : preallocated ESX-type virtual disk
          5                   : compressed disk optimized for streaming
          6                   : thin provisioned virtual disk - ESX 3.x and above

         The capacity can be specified in sectors, KB, MB or GB.
         The acceptable ranges:
                               ide adapter : [1MB, 2040.0GB]
                               scsi adapter: [1MB, 2040.0GB]
            ex 1: vmware-vdiskmanager.exe -c -s 850MB -a ide -t 0 myIdeDisk.vmdk
            ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
            ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vmdk
            ex 4: vmware-vdiskmanager.exe -x 36GB myDisk.vmdk
            ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
            ex 6: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 4 -h esx-name.mycompany.com \
                  -u username -f passwordfile "[storage1]/path/to/targetDisk.vmdk"
            ex 7: vmware-vdiskmanager.exe -k myDisk.vmdk
            ex 8: vmware-vdiskmanager.exe -p <mount-point>
                  (A virtual disk first needs to be mounted at <mount-point>)

무료 VMWare Workstation 평가판을 받을 수 있습니다.

답변3

가상 디스크를 축소하는 데는 일반적으로 두 단계가 있습니다.

  1. 닦아. 이렇게 하면 게스트 파일 시스템의 사용되지 않는 블록이 0이 됩니다. 이 작업은 게스트 내에서 수행되어야 합니다..
  2. 압축. 이렇게 하면 삭제 단계에서 .vmdk 파일의 0으로 지정된 블록이 제거됩니다. 이 작업은 호스트가 수행해야 합니다.(게스트에 의해 실행될 수도 있지만)

vmware-vdiskmanager호스트에서 실행하면 압축 단계는 수행할 수 있지만 삭제 단계는 수행할 수 없습니다. 지우는 방법에는 다음과 같은 몇 가지가 있습니다.

  • 달리다 vmware-toolbox-cmd disk shrink LOCATION. 자세한 내용을 보려면 실행하세요 vmware-toolbox-cmd help disk. ( Windows 게스트에서는 vmware-toolbox-cmd이름이 지정됩니다 VMwareToolboxCmd.) 삭제가 완료되면 압축 단계가 시작됩니다.

  • 프로그램 vmshrinkVM Back 타사 도구 패키지. 이는 VMware Tools를 사용할 수 없는 게스트에게는 좋은 대안이 될 수 있습니다. 또한 삭제가 완료되면 압축 단계가 시작됩니다.

  • 아마도 dd게스트에서 (또는 이와 동등한 것)을 사용할 수 있지만 이는 독자의 연습 문제로 남겨 둡니다.

닦는 단계가 필요하지 않은 일부 상황도 있습니다. 예를 들어, 파일 시스템에서 파일을 삭제할 때 게스트가 파일 내용을 이미 0으로 만든 경우 또는 게스트가 Windows인 경우 VMware Workstation은 NTFS 게스트 파티션을 검사하여 사용되지 않은 블록을 확인하는 방법을 자체적으로 알고 있습니다. .

관련 정보