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

... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
11837정성태3/6/201939840기타: 74. 도서: 시작하세요! C# 7.3 프로그래밍 [10]
11836정성태3/5/201923419오류 유형: 525. Visual Studio 2019 Preview 4/RC - C# 8.0 Missing compiler required member 'System.Range..ctor' [1]
11835정성태3/5/201921889.NET Framework: 810. C# 8.0의 Index/Range 연산자를 .NET Framework에서 사용하는 방법 및 비동기 스트림의 컴파일 방법 [3]파일 다운로드1
11834정성태3/4/201920720개발 환경 구성: 432. Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법
11833정성태3/4/201921238개발 환경 구성: 431. Visual Studio 2019 - CMake를 이용한 공유/실행(so/out) 리눅스 프로젝트 설정파일 다운로드1
11832정성태3/4/201917136오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201917003오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201916650오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201918334개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201926313개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201919221오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201919406오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201924674개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201919085오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201920677오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201919099오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201919866오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201922884오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201922145Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201920212VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/201916544오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201920039Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201918292오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201917085오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201918448.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/201915723오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...