Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 179. Hyper-V VM 복사는 robocopy로. [링크 복사], [링크+제목 복사],
조회: 29064
글쓴 사람
정성태 (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)
13917정성태4/30/202563VS.NET IDE: 199. Directory.Build.props에 정의한 속성에 대해 Condition 제약으로 값을 변경하는 방법
13916정성태4/23/2025468디버깅 기술: 221. WinDbg 분석 사례 - ASP.NET HttpCookieCollection을 다중 스레드에서 사용할 경우 무한 루프 현상 - 두 번째 이야기
13915정성태4/13/20251685닷넷: 2331. C# - 실행 시에 메서드 가로채기 (.NET 9)파일 다운로드1
13914정성태4/11/20251987디버깅 기술: 220. windbg 분석 사례 - x86 ASP.NET 웹 응용 프로그램의 CPU 100% 현상 (4)
13913정성태4/10/20251214오류 유형: 950. Process Explorer - 64비트 윈도우에서 32비트 프로세스의 덤프를 뜰 때 "Error writing dump file: Access is denied." 오류
13912정성태4/9/2025872닷넷: 2330. C# - 실행 시에 메서드 가로채기 (.NET 5 ~ .NET 8)파일 다운로드1
13911정성태4/8/20251116오류 유형: 949. WinDbg - .NET Core/5+ 응용 프로그램 디버깅 시 sos 확장을 자동으로 로드하지 못하는 문제
13910정성태4/8/20251266디버깅 기술: 219. WinDbg - 명령어 내에서 환경 변수 사용법
13909정성태4/7/20251773닷넷: 2329. C# - 실행 시에 메서드 가로채기 (.NET Framework 4.8)파일 다운로드1
13908정성태4/2/20252183닷넷: 2328. C# - MailKit: SMTP, POP3, IMAP 지원 라이브러리
13907정성태3/29/20251991VS.NET IDE: 198. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C# 프로젝트의 출력 경로 변경하기
13906정성태3/27/20252266닷넷: 2327. C# - 초기화되지 않은 메모리에 접근하는 버그?파일 다운로드1
13905정성태3/26/20252304Windows: 281. C++ - Windows / Critical Section의 안정화를 위해 도입된 "Keyed Event"파일 다운로드1
13904정성태3/25/20251916디버깅 기술: 218. Windbg로 살펴보는 Win32 Critical Section파일 다운로드1
13903정성태3/24/20251536VS.NET IDE: 197. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C++ 프로젝트의 출력 경로 변경하기
13902정성태3/24/20251748개발 환경 구성: 742. Oracle - 테스트용 hr 계정 및 데이터 생성파일 다운로드1
13901정성태3/9/20252138Windows: 280. Hyper-V의 3가지 Thread Scheduler (Classic, Core, Root)
13900정성태3/8/20252361스크립트: 72. 파이썬 - SQLAlchemy + oracledb 연동
13899정성태3/7/20251834스크립트: 71. 파이썬 - asyncio의 ContextVar 전달
13898정성태3/5/20252154오류 유형: 948. Visual Studio - Proxy Authentication Required: dotnetfeed.blob.core.windows.net
13897정성태3/5/20252387닷넷: 2326. C# - PowerShell과 연동하는 방법 (두 번째 이야기)파일 다운로드1
13896정성태3/5/20252204Windows: 279. Hyper-V Manager - VM 목록의 CPU Usage 항목이 항상 0%로 나오는 문제
13895정성태3/4/20252248Linux: 117. eBPF / bpf2go - Map에 추가된 요소의 개수를 확인하는 방법
13894정성태2/28/20252284Linux: 116. eBPF / bpf2go - BTF Style Maps 정의 구문과 데이터 정렬 문제
13893정성태2/27/20252225Linux: 115. eBPF (bpf2go) - ARRAY / HASH map 기본 사용법
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...