Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 179. Hyper-V VM 복사는 robocopy로. [링크 복사], [링크+제목 복사],
조회: 29160
글쓴 사람
정성태 (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분
유수석님 오랜만이세요. ^^
정성태

... 166  167  168  169  170  171  172  173  174  [175]  176  177  178  179  180  ...
NoWriterDateCnt.TitleFile(s)
628정성태12/6/200821057.NET Framework: 115. Marshal 타입 관련 2가지 자원 해제 메서드파일 다운로드1
627정성태12/6/200823408VS.NET IDE: 58. VS.NET IDE 팁 - 커서 위치 이동 [1]
626정성태12/6/200823740오류 유형: 65. TF53018: The application tier XXXXXXX is attempting to connect to a data tier with an incompatible version
625정성태12/6/200823866오류 유형: 64. TFS 2008 SP1 설치 - MsiApplyMultiplePatches returned 0x643
624정성태12/5/200824786.NET Framework: 114. WPF 이벤트에 속한 핸들러 확인 [2]파일 다운로드1
623정성태12/4/200829183디버깅 기술: 22. VS.NET SP1 + .NET Framework 소스 코드 디버깅 [2]파일 다운로드1
622정성태12/1/200831430오류 유형: 63. WPF - XamlParseException 대응 방법 [2]
621정성태11/30/200823629Team Foundation Server: 27. TeamBuild + VDPROJ 셋업 프로젝트 [1]
620정성태11/30/200822483디버깅 기술: 21. 올바른 이벤트 예외 정보 출력
619정성태11/30/200822580디버깅 기술: 20. 예외 처리를 방해하는 WPF Modal 대화창파일 다운로드1
618정성태11/29/200822970.NET Framework: 113. 이벤트에 속한 이벤트 핸들러 확인파일 다운로드1
617정성태11/26/200828634.NET Framework: 112. How to Interop DISPPARAMS [2]파일 다운로드2
616정성태11/26/200822354디버깅 기술: 19. C++/CLI - F11 디버깅 시의 변수 초기화파일 다운로드1
615정성태11/9/200832049.NET Framework: 111. WPF - Window, UserControl 클래스 상속 [1]
614정성태11/9/200831998.NET Framework: 110. WPF - 전역 예외 처리 [4]파일 다운로드1
613정성태11/8/200821646.NET Framework: 109. WPF - SystemColors 색상표파일 다운로드1
612정성태11/1/200826889.NET Framework: 108. WPF + WCF 환경에서는 DataContract를 권장 [1]
611정성태10/31/200821171오류 유형: 62. WPF - Visual Studio 2008 비정상 종료
610정성태10/24/200823414Team Foundation Server: 26. TFS 2008 SP1 + SQL Server 2008 설치
609정성태10/24/200827151.NET Framework: 107. WPF - RadioButton 데이터 바인딩 해제 현상파일 다운로드2
608정성태10/23/200821808오류 유형: 61. TFS 연결 오류: TF31003, TF30331 오류
607정성태10/18/200819797Windows: 32. 자동 실행 경로에 ".." 가 포함된 경우
606정성태10/18/200821816.NET Framework: 106. WCF - 다중 서비스 호스트파일 다운로드1
605정성태10/18/200825266.NET Framework: 105. WPF - 닫기 버튼을 없애려면.
604정성태10/18/200825791오류 유형: 60. System.Management.ManagementException - Generic failure [1]
602정성태10/15/200827747오류 유형: 59. WPF - XAML 로딩 시 Visual Studio 비정상 종료 [1]
... 166  167  168  169  170  171  172  173  174  [175]  176  177  178  179  180  ...