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

[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13610정성태4/28/2024207닷넷: 2251. C# - 제네릭 인자를 가진 타입을 생성하는 방법 - 두 번째 이야기
13609정성태4/27/2024232닷넷: 2250. PInvoke 호출 시 참조 타입(class)을 마샬링하는 [IN], [OUT] 특성파일 다운로드1
13608정성태4/26/2024426닷넷: 2249. C# - 부모의 필드/프로퍼티에 대해 서로 다른 자식 클래스 간에 Reflection 접근이 동작할까요?파일 다운로드1
13607정성태4/25/2024473닷넷: 2248. C# - 인터페이스 타입의 다중 포인터를 인자로 갖는 C/C++ 함수 연동
13606정성태4/24/2024629닷넷: 2247. C# - tensorflow 연동 (MNIST 예제)파일 다운로드1
13605정성태4/23/2024778닷넷: 2246. C# - Python.NET을 이용한 파이썬 소스코드 연동파일 다운로드1
13604정성태4/22/2024817오류 유형: 901. Visual Studio - Unable to set the next statement. Set next statement cannot be used in '[Exception]' call stack frames.
13603정성태4/21/2024950닷넷: 2245. C# - IronPython을 이용한 파이썬 소스코드 연동파일 다운로드1
13602정성태4/20/2024963닷넷: 2244. C# - PCM 오디오 데이터를 연속(Streaming) 재생 (Windows Multimedia)파일 다운로드1
13601정성태4/19/2024990닷넷: 2243. C# - PCM 사운드 재생(NAudio)파일 다운로드1
13600정성태4/18/20241014닷넷: 2242. C# - 관리 스레드와 비관리 스레드
13599정성태4/17/2024949닷넷: 2241. C# - WAV 파일의 PCM 사운드 재생(Windows Multimedia)파일 다운로드1
13598정성태4/16/2024993닷넷: 2240. C# - WAV 파일 포맷 + LIST 헤더파일 다운로드2
13597정성태4/15/2024987닷넷: 2239. C# - WAV 파일의 PCM 데이터 생성 및 출력파일 다운로드1
13596정성태4/14/20241101닷넷: 2238. C# - WAV 기본 파일 포맷파일 다운로드1
13595정성태4/13/20241071닷넷: 2237. C# - Audio 장치 열기 (Windows Multimedia, NAudio)파일 다운로드1
13594정성태4/12/20241093닷넷: 2236. C# - Audio 장치 열람 (Windows Multimedia, NAudio)파일 다운로드1
13593정성태4/8/20241094닷넷: 2235. MSBuild - AccelerateBuildsInVisualStudio 옵션
13592정성태4/2/20241230C/C++: 165. CLion으로 만든 Rust Win32 DLL을 C#과 연동
13591정성태4/2/20241207닷넷: 2234. C# - WPF 응용 프로그램에 Blazor App 통합파일 다운로드1
13590정성태3/31/20241086Linux: 70. Python - uwsgi 응용 프로그램이 k8s 환경에서 OOM 발생하는 문제
13589정성태3/29/20241164닷넷: 2233. C# - 프로세스 CPU 사용량을 나타내는 성능 카운터와 Win32 API파일 다운로드1
13588정성태3/28/20241535닷넷: 2232. C# - Unity + 닷넷 App(WinForms/WPF) 간의 Named Pipe 통신 [2]파일 다운로드1
13587정성태3/27/20241397오류 유형: 900. Windows Update 오류 - 8024402C, 80070643
13586정성태3/27/20241605Windows: 263. Windows - 복구 파티션(Recovery Partition) 용량을 늘리는 방법
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...