Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 179. Hyper-V VM 복사는 robocopy로. [링크 복사], [링크+제목 복사],
조회: 22732
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

Hyper-V VM 복사는 robocopy로.


오호~~~ Hyper-V VM의 VHDx 이미지를 단순히 탐색기에서 복사하면 안되는군요. 복사 전에는 다음과 같은 식의 보안 설정이 되어 있었는데,

SYSTEM: Full control
Administrators: Full control
Users: Read & execute, Read
[임의의 GUID]: Read, Write

탐색기로 다른 드라이브에 복사하니 GUID에 해당하는 계정이 빠져 있습니다. 가만 보니까, 그 GUID는 Virtual Machines의 ID와 동일한 식별자였습니다.

vm_start_error_1.png

문제는 이 권한을 탐색기의 속성창에서 부여할 수 있는 방법이 없습니다. "E565FF0F-1006-4C89-BE7E-E333E082BAF0"라는 식으로 쓰면 그런 계정이 없다고 나옵니다. VM 파일들에 할당된 이런 특수 계정은 "Virtual Machine Worker Process"인 vmwp.exe의 사용자 계정이기도 합니다.

경우에 따라서, VHDx 이미지뿐만 아니라 VM이 생성되는 폴더 자체에도 "Virtual Machines"라는 계정이 아무 권한없이 포함되어 있는데 이것 역시 해당 폴더를 복사하는 과정에서 누락됩니다.

VM 설정을 가진 xml 파일에 계정이 누락된 상태에서 해당 VM을 Hyper-V에서 시작하니 다음과 같은 식으로 오류가 발생합니다.

An error occurred while attempting to start the selected virtual machine(s).

'...' could not initialize.

An attempt to read or update virtual machine configuration failed.

'...' could not initialize. (Virtual machine ID ...)

'...' could not read or update virtual machine configuration: Unspecified error(0x80004005). (Virtual machine ID ...)

또는 VHDx 파일에 계정이 누락되면 다음과 같은 오류가 발생합니다.

An error occurred while attempting to start the selected virtual machine(s).

'...' failed to start.

Microsoft Emulated IDE conroller (Instance ID ...[guid]...): Failed to Power on with Error 'General access denied error'.

IDE/ATAPI Account does not have sufficient privileges to open attachment '...vhdx'. Error: 'General access denied error'.

Hyper-V Virtual Machine Management service Account does not have sufficient privileges to open attachment '...vhdx'. Error: 'General access denied error'.

일단, 급하다면 문제를 해결하기 위해 VM을 소유한 부모 폴더에 "Users" 그룹의 "Write" 권한만 추가해 주면 VM 시작을 할 수 있습니다. 또는, Users에 대한 보안 적용이 불안하다면 복사를 탐색기가 아닌 robocopy로 해주면 됩니다.

robocopy c:\vhd d:\vhd /S /J /SEC

robocopy에 /SEC 옵션을 주면 보안 설정까지 모두 복사하기 때문에 문제가 없습니다. (/J 옵션은 unbuffered I/O 방식으로 복사하므로 VHDx와 같은 대용량 복사에 적용하면 좋습니다.)




그런데 도대체 과연 이 계정의 정체가 뭘까요?

What is this (Account Unknown) SID ?
; http://social.technet.microsoft.com/Forums/en/w7itproinstall/thread/1a1a157b-6eba-4701-835a-8251f3ae01d6

위의 PowerShell 스크립트를 이용해서 기존 VHDx의 보안을 확인해 보았습니다.

PS C:\Users\SeongTae Jeong>  get-acl "d:\TestVPC\Win7ko\Win7ko.vhdx" | fl

Path   : Microsoft.PowerShell.Core\FileSystem::D:\TestVPC\Win7ko\Win7ko.vhdx
Owner  : BUILTIN\Administrators
Group  : TESTPC\Domain Users
Access : NT VIRTUAL MACHINE\E565FF0F-1006-4C89-BE7E-E333E082BAF0 Allow  Write, Read, Synchronize
         BUILTIN\Administrators Allow  FullControl
         NT AUTHORITY\SYSTEM Allow  FullControl
         BUILTIN\Users Allow  ReadAndExecute, Synchronize
Audit  :
Sddl   : O:BAG:DUD:AI(A;;0x12019f;;;S-1-5-83-1-3848666895-1284052950-870547134-4238755040)(A;ID;FA;;;BA)(A;ID;FA;;;SY)(A;ID;0x1200a9;;;BU)

아하... 완전히 새로운 "NT VIRTUAL MACHINE" 네임스페이스로 되어 있군요. 마찬가지로 "Virtual Machines" 계정은 "NT VIRTUAL MACHINE\Virtual Machines" 계정으로 되어 있습니다. 하지만... ^^; 탐색기 보안 설정창에서 "NT VIRTUAL MACHINE\E565FF0F-1006-4C89-BE7E-E333E082BAF0"라고 입력해도 여전히 인식하지 못합니다. 아무래도 직접적인 입력은 불가능한 것 같습니다.

좀 더 알아보니 PowerShell을 이용하여 ACL만 재설정하는 방법이 있습니다.

Hyper-V “Virtual Machines” Security Group Issue
; http://architectevangelist.wordpress.com/2011/02/20/hyper-v-virtual-machines-security-group-issue/

위의 글에 따라 VHDx의 보안 설정만 탐색기로 복사해 둔 파일에 덮어 쓸 수 있습니다.

$sid=get-acl "D:\TestVPC\Win7ko\Win7ko.vhdx"
set-acl "E:\TestVPC\Win7ko\Win7ko.vhdx" $sid

아쉽게도 VHDx만 변경해서는 안되고 VM 정보를 담은 [...guid...].xml 파일도 함께 변경해 줘야 합니다. 문제는 xml 파일의 경우 권한뿐만 아니라 Owner 자체가 ...guid... 계정으로 되어 있기 때문에 위와 같이 get-acl / set-acl로 변경하면 다음과 같이 오류가 발생합니다.

PS C:\Windows\system32> set-acl "D:\TestVPC\Win7ko\Virtual Machines\E565FF0F-1006-4C89-BE7E-E333E082BAF0.xml" $sid
set-acl : The security identifier is not allowed to be the owner of this object.
At line:1 char:1
+ set-acl "D:\TestVPC\Win7ko\Virtual Machines\E565FF0F-1006-4C89-BE7E-E333E082BAF0 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (D:\TestVPC\Win7ko...E333E082BAF0.xml:String) [Set-Acl], InvalidOperation
   Exception
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetAclCommand

그래서 해당 파일의 Owner를 ...guid... 계정으로 먼저 바꿔주어야 하는데, 이게 잘 안되는군요. 혹시나 싶어 다음과 같이 해보았는데 동일한 오류가 발생할 뿐이었습니다.

// Set Owner with PowerShell: “The security identifier is not allowed to be the owner of this object”
// http://fixingitpro.com/2011/07/08/set-owner-with-powershell-%E2%80%9Cthe-security-identifier-is-not-allowed-to-be-the-owner-of-this-object%E2%80%9D/
$domain = "NT VIRTUAL MACHINE"
$username = "E565FF0F-1006-4C89-BE7E-E333E082BAF0"

$ID = new-object System.Security.Principal.NTAccount($domain, $username)
$acl = get-acl "C:\TestVPC\Win7ko\Virtual Machines\E565FF0F-1006-4C89-BE7E-E333E082BAF0.xml"

$acl.SetOwner($ID)
set-acl -path "D:\TestVPC\Win7ko\Virtual Machines\E565FF0F-1006-4C89-BE7E-E333E082BAF0.xml" -aclObject $acl

최선의 방법은 이미 복사된 대용량의 VHDx 파일은 그냥 get-acl/get-acl로 권한만 복사해 주고 xml 파일만 다시 robocopy로 /SEC 옵션을 사용해 빠르게 복사해 주는 것이 좋겠습니다.

이렇게 하고 끝내려고 했는데 ^^ 혹시나 싶어 검색을 해보았습니다. 오호~~~ icacls.exe에서는 "NT VIRTUAL MACHINE" 네임스페이스의 계정 설정이 가능하다고 나옵니다.

Hyper-V virtual machine fails to start after moving the VHD files
; http://techblog.mirabito.net.au/?p=275

icacls "<virtualmachinefolder>" /grant "NT VIRTUAL MACHINE\<virtualmachineguid>":F /T 

(for example:
icacls "D:\Virtual Server\Virtual Machines\Server" /grant "NT VIRTUAL MACHINE\598AFA1B-1726-44B7-8435-E00B2ACAF2B5":F /T

그런데, SCVMM 설치한 상태에서 위의 명령을 내렸다고 하는데 제 경우에는 설치되어 있지 않아서 그런지 역시 오류가 발생하는군요.

C:\Windows\system32>icacls "D:\TestVPC\Win7ko" /grant "NT VIRTUAL MACHINE\E565FF0F-1006-4C89-BE7E-E333E082BAF0":F /T
NT VIRTUAL MACHINE\E565FF0F-1006-4C89-BE7E-E333E082BAF0: No mapping between account names and security IDs was done.
Successfully processed 0 files; Failed processing 1 files

그냥 ... 이거저거 생각하지 마시고 애당초 robocopy.exe로 복사하는 것이 권장됩니다. (NT 운영체제에 이런 식의 보안이 가능한지 처음 알았군요. ^^)




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 7/10/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2013-01-15 02시33분
[WaterStone] 굿... 땡스...
[guest]
2013-01-16 03시09분
유수석님 오랜만이세요. ^^
정성태

... 16  17  18  19  20  21  22  23  24  25  26  27  28  [29]  30  ...
NoWriterDateCnt.TitleFile(s)
12925정성태1/17/20227604개발 환경 구성: 627. AKS의 준비 단계 - ACR(Azure Container Registry)에 docker 이미지 배포
12924정성태1/15/20229139.NET Framework: 1134. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 비디오 디코딩 예제(decode_video.c) [2]파일 다운로드1
12923정성태1/15/20228002개발 환경 구성: 626. ffmpeg.exe를 사용해 비디오 파일을 MPEG1 포맷으로 변경하는 방법
12922정성태1/14/20227092개발 환경 구성: 625. AKS - Azure Kubernetes Service 생성 및 SLO/SLA 변경 방법
12921정성태1/14/20226009개발 환경 구성: 624. Docker Desktop에서 별도 서버에 설치한 docker registry에 이미지 올리는 방법
12920정성태1/14/20226788오류 유형: 786. Camtasia - An error occurred with the camera: Failed to Add Video Sampler.
12919정성태1/13/20226643Windows: 199. Host Network Service (HNS)에 의해서 점유되는 포트
12918정성태1/13/20226866Linux: 47. WSL - shell script에서 설정한 환경 변수가 스크립트 실행 후 반영되지 않는 문제
12917정성태1/12/20225987오류 유형: 785. C# - The type or namespace name '...' could not be found (are you missing a using directive or an assembly reference?)
12916정성태1/12/20225797오류 유형: 784. TFS - One or more source control bindings for this solution are not valid and are listed below.
12915정성태1/11/20226073오류 유형: 783. Visual Studio - We didn't find any interpreters
12914정성태1/11/20228105VS.NET IDE: 172. 비주얼 스튜디오 2022의 파이선 개발 환경 지원
12913정성태1/11/20228592.NET Framework: 1133. C# - byte * (바이트 포인터)를 FileStream으로 쓰는 방법 [1]
12912정성태1/11/20229275개발 환경 구성: 623. ffmpeg.exe를 사용해 비디오 파일의 이미지를 PGM(Portable Gray Map) 파일 포맷으로 출력하는 방법 [1]
12911정성태1/11/20226454VS.NET IDE: 171. 비주얼 스튜디오 - 더 이상 만들 수 없는 "ASP.NET Core 3.1 Web Application (.NET Framework)" 프로젝트
12910정성태1/10/20226976제니퍼 .NET: 30. 제니퍼 닷넷 적용 사례 (8) - CPU high와 DB 쿼리 성능에 문제가 함께 있는 사이트
12909정성태1/10/20228350오류 유형: 782. Visual Studio 2022 설치 시 "Couldn't install Microsoft.VisualCpp.Redist.14.Latest"
12908정성태1/10/20226158.NET Framework: 1132. C# - ref/out 매개변수의 IL 코드 처리
12907정성태1/9/20226714오류 유형: 781. (youtube-dl.exe) 실행 시 "This app can't run on your PC" / "Access is denied." 오류 발생
12906정성태1/9/20227363.NET Framework: 1131. C# - 네임스페이스까지 동일한 타입을 2개의 DLL에서 제공하는 경우 충돌을 우회하는 방법 [1]파일 다운로드1
12905정성태1/8/20227020오류 유형: 780. Could not load file or assembly 'Microsoft.VisualStudio.TextTemplating.VSHost.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
12904정성태1/8/20229009개발 환경 구성: 623. Visual Studio 2022 빌드 환경을 위한 github Actions 설정 [1]
12903정성태1/7/20227621.NET Framework: 1130. C# - ELEMENT_TYPE_INTERNAL 유형의 사용 예
12902정성태1/7/20227655오류 유형: 779. SQL 서버 로그인 에러 - provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.
12901정성태1/5/20227684오류 유형: 778. C# - .NET 5+에서 warning CA1416: This call site is reachable on all platforms. '...' is only supported on: 'windows' 경고 발생
12900정성태1/5/20229345개발 환경 구성: 622. vcpkg로 ffmpeg를 빌드하는 경우 생성될 구성 요소 제어하는 방법
... 16  17  18  19  20  21  22  23  24  25  26  27  28  [29]  30  ...