자유 게시판

드라이브 마운트안된 파티션 내용에 접근과 유의할점.

2019.03.07 09:02

Neutrino 조회:464 추천:2

앞서 마운트없이 EFI 파티션에 bcdboot를 수행할수 있다는 글을 올렸는데요

모든 시스템에 인식된 모든 NTFS/FAT 파티션은 마운트에 상관없이 dir 명령으로 접근이 가능합니다. 

mountvol 결과 나오는 디바이스 트리 uuid 부터 경로를 적어주면 됩니다.

 

예 : dir \\?\Volume{ad843443-4ba4-4d58-9122-f5189d69328a}\efi

결과는

 

 \\?\Volume{ad843443-4ba4-4d58-9122-f5189d69328a} 드라이브의 볼륨: system
 볼륨 일련 번호: 0EC0-0A96

 \\?\Volume{ad843443-4ba4-4d58-9122-f5189d69328a}\efi 디렉터리

2019-02-23  오전 05:04    <DIR>          .
2019-02-23  오전 05:04    <DIR>          ..
2019-02-23  오전 05:04    <DIR>          Microsoft
2019-02-23  오전 05:04    <DIR>          Boot
               0개 파일                   0 바이트
               4개 디렉터리      76,914,688 바이트 남음

 

이렇게 잘 나오네요. (내용은 관리자권한일때만 보여짐...)

따라서 bcdedit /store ... 에서도 위 디바이스 트리로부터 BCD 경로를 적어주면 됩니다.

그런데 bcdboot /s 에서는 위의 디바이스 트리 외에 \Device\HarddiskVolume# 형식도 지원하고 (#은 번호)

그냥 # 번호만 써줘도 되는데 중요한건 이때 # 번호가 diskpart의 list vol 에서 나오는 볼륨번호와는 전혀 별개 입니다.

 

즉 diskpart list vol 의 숫자는 임의로 나열순서를 써놓은것일뿐 디바이스 트리와는 전혀 별개이기에 조심해야 합니다.

디바이스트리 의 볼륨은 0 이 아닌 1부터 시작하느것부터 다릅니다. 

 

\Device\HarddiskVolume 형식의 볼륨값은 파워쉘에서 다음의 코드를 봍여넣기 하면 나오지만

마운트 안된것은 나오지가 않습니다.

 

   $DynAssembly = New-Object System.Reflection.AssemblyName('SysUtils')
   $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly($DynAssembly, [Reflection.Emit.AssemblyBuilderAccess]::Run)
   $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('SysUtils', $False)

   # Define [Kernel32]::QueryDosDevice method
   $TypeBuilder = $ModuleBuilder.DefineType('Kernel32', 'Public, Class')
   $PInvokeMethod = $TypeBuilder.DefinePInvokeMethod('QueryDosDevice', 'kernel32.dll', ([Reflection.MethodAttributes]::Public -bor [Reflection.MethodAttributes]::Static), [Reflection.CallingConventions]::Standard, [UInt32], [Type[]]@([String], [Text.StringBuilder], [UInt32]), [Runtime.InteropServices.CallingConvention]::Winapi, [Runtime.InteropServices.CharSet]::Auto)
   $DllImportConstructor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String]))
   $SetLastError = [Runtime.InteropServices.DllImportAttribute].GetField('SetLastError')
   $SetLastErrorCustomAttribute = New-Object Reflection.Emit.CustomAttributeBuilder($DllImportConstructor, @('kernel32.dll'), [Reflection.FieldInfo[]]@($SetLastError), @($true))
   $PInvokeMethod.SetCustomAttribute($SetLastErrorCustomAttribute)
   $Kernel32 = $TypeBuilder.CreateType()

   $Max = 65536
   $StringBuilder = New-Object System.Text.StringBuilder($Max)

   Get-WmiObject Win32_Volume | ? { $_.DriveLetter } | % {
       $ReturnLength = $Kernel32::QueryDosDevice($_.DriveLetter, $StringBuilder, $Max)

       if ($ReturnLength)
       {
           $DriveMapping = @{
               DriveLetter = $_.DriveLetter
               DevicePath = $StringBuilder.ToString()
           }

           New-Object PSObject -Property $DriveMapping
       }
   }

 

저는 다음과 같이 나오는데

 

DevicePath              DriveLetter
----------              -----------
\Device\HarddiskVolume2 C:
\Device\HarddiskVolume3 A:
\Device\HarddiskVolume5 Z:
\Device\HarddiskVolume6 B:

 

여기서 빠진 Volume 1과 Volume 4가 EFI 파티션 입니다. (diskpart list vol 에서는 전혀 다른 순서와 값이 나옴)

이 형식은 dir로 출력은 안되며 다소 고전적인 포맷이라 여겨지며 이유는 위에서 설명드린대로 볼륨순번이 중구난방 이기에

mountvol에서 얻은 \\?\Volume{uuid} 형식이 정상적인 포맷으로 간주되어 잘 쓰이는것 같습니다.

번호 제목 글쓴이 조회 등록일
[공지] 자유 게시판 이용간 유의사항 (정치, 종교, 시사 게시물 자제) [1] gooddew - -
45939 1년6개월 정도된 제 데탑입니다~ [24] Happiness 4453 08-29
45938 아직 마크키 전화인증 가능한데......... [10] 놈강도 4451 08-09
45937 소년출세, 청년정치, 중년상처, 노년무전, 세대별 고달픈 ... [2] rosinante 4450 12-21
45936 이번달 정기 업데이트 대박이네요 ; [13] suk 4439 03-11
45935 국내 최대 비공개 트래커 게릴라 오픈가입 한답니다 [12] 야비군 4439 06-01
45934 한글과 컴퓨터 [34] 늘샘 4438 04-25
45933 노안수술 비용 [7] 무명거사 4436 06-17
45932 희한한(?)경험 [2] Dingdong 4436 11-12
45931 극단적으로 고통스러운 과정....펌 [6] 스킨닥 4435 12-06
45930 8.1 인증 크랙이나 나오면 받아야지요. [7] 복두꺼비 4435 08-29
45929 Windows 10 TH2 버전1511 MSDN 해시값 들입니다 [1] suk 4429 11-13
45928 I T 관련 사이트 [2] 아내구하는 4427 11-28
45927 안과의사가 솔직히 까놓고 말하는 라식 라섹 위험성 [5] nhk 4426 10-06
45926 Easy DriverPacks 5.2.1.1 충격적인 새로운 소식 [4] yellowcap 4425 09-15
45925 윈8 엄청 신기한거 발견했습니다.ㅎㅎ [14] 청향 4424 09-06
45924 windows8 pro k 순수 설치버전 좀 부탁합니다. [4] jmshin722 4423 11-08
45923 [Vista] "Windows 일정" 애용합시다!!! [3] 김용환 4419 11-25
45922 크롬이 아주 빨라졌군요. [11] 클레멘타인 4418 04-12
45921 썬지오 (썬폴더) 무료쿠폰 충전 월 최대 3000원으로 막혔습... 토시바 4411 05-07
45920 몇일전에 올라온 Office2007 Ultimate MSDN 원본 구해봅니다. [2] 마스터 4411 10-26
XE1.11.6 Layout1.4.8