728x90

Abstract

본 글과 다음 글에서는 GUID Partition Table에 대해 알아볼 것이다. GPT는 EFI에서 사용하는 디스크 파티션 구조로, BIOS 시스템의 MBR을 개선하기 위해 만들어졌으며, 더 큰 주소 비트를 지원하기 때문에 더 큰 디스크를 인식할 수 있게 되었고, 더 많은 파티션을 생성할 수 있게 됐다.

GPT를 알아보기 전에 EFI에 대한 설명을 간략하게 할 것이다. 다만 내용이 길어 본 글에서는 UEFI와 GPT의 개요, 기존 BIOS 시스템과의 호환성 유지를 위한 Protective MBR에 대해 설명하고 주요 내용인 GPT 헤더, 파티션 테이블, 백업 GPT에 대한 설명은 다음 글에서 이어 하도록 하겠다.

GPT

UEFI(Unified Extensible Firmware Interface)

GPT를 알아보기 전에 선수지식으로 UEFI에 대해 알아보고 가자. 바쁘다면 굳이 읽진 않아도 괜찮다.

https://uefi.org/faq
WHAT IS UEFI?

UEFI stands for "Unified Extensible Firmware Interface." The UEFI Specification defines a new model for the interface between personal-computer operating systems and platform firmware. The interface consists of data tables that contain platform-related information, plus boot and runtime service calls that are available to the operating system and its loader. Together, these provide a standard environment for booting an operating system and running pre-boot applications.

UEFI란 "Unifed Extensible Firmware Interface"를 의미한다. UEFI 명세는 개인 컴퓨터 운영체제와 플랫폼 펌웨어 간의 인터페이스를 위한 새로운 모델을 정의한다. 인터페이스는 플랫폼 관련 정보와 더불어 운영체제와 그것의 로더(Loader)가 이용할 수 있는 부팅, 런타임 서비스 호출을 포함하는 데이터 테이블로 구성된다. 이것들은 운영체제를 부팅하고 사전 부팅 어플리케이션을 실행하기 위한 표준 환경을 제공한다.

1990년대 중반 인텔은 16비트 크기의 주소 모드를 사용하는 탓에 1 MB 크기의 메모리, 2 TB의 스토리지만 인식 가능하다는 기존 BIOS의 문제를 해결하고 싶어했다. 고성능 서버 플랫폼에 넣을 아이타니움(Itanium)이라는 새 아키텍처를 만드는 데 있어 작은 주소 비트와 메모리를 가진 BIOS는 너무 제한적이었기 때문이다. 그래서 나온 것이 바로 EFI라고 불리게 되는 Intel Boot Initiative다. EFI 훗날 UEFI 포럼에서 Specification을 관리하게 되며, 라이센스는 인텔이 유지하게 된다. 오늘날 UEFI라고 불리는 것은 EFI 1.10를 기반으로 한 Specification이다.

https://uefi.org/learning_center/logouse

UEFI 로고

EFI는 BIOS 같은 하드웨어와 밀접한 소프트웨어인 펌웨어와 비교적 상위 계층인 운영체제의 사이에 위치하며, 운영체제를 부팅하거나 Pre-Boot 응용 프로그램을 실행하는 표준 환경을 제공한다. "운영체제를 부팅한다"는 말에서 알 수 있 듯 운영체제가 설치된 볼륨을 찾아 해당 볼륨의 운영체제 부트 로더를 실행하는 역할도 한다. 기존 MBR 구조에서는 스토리지의 첫 섹터를 읽어 메모리에 로드한 후 첫 바이트부터 명령을 이어나갔지만 EFI 시스템에서 MBR은 호환성을 위해 남아있을 뿐 GPT라는 구조를 사용해 파티션들을 관리하고 운영체제를 부팅한다.

EFI를 사용하면 MBR보다 더 큰 크기의 스토리지도 인식할 수 있고 Pre-Boot(PXE)를 통한 네트워크 부팅, 부팅 프로세스가 변조되지 않았는지 검사하는 보안 부팅도 가능해진다. 또한 운영체제는 EFI를 통해 GOP(그래픽 출력 프로토콜), 메모리 맵, ACPI, 시간 서비스 등을 이용할 수 있다. EFI는 단독적으로 EFI 응용 프로그램을 실행할 수 있는데, EFI 응용 프로그램의 예시로는 Windows Boot Manager 같은 운영체제 부트 로더가 있다. 그래픽스 기능을 통한 GUI(이 땐 GOP가 아닌 UGA 프로토콜 이용), 다국어 지원, 마우스와 키보드도 사용할 수 있다는 점 덕분에 아래 그림처럼 화려한 BIOS 메뉴를 사용할 수 있게 됐다.

MSI Motherboard 제품군의 BIOS 메뉴

EFI와 UEFI의 차이는 뭘까. 그 답도 UEFI 포럼에서 찾을 수 있다.

https://uefi.org/faq
WHAT IS THE RELATIONSHIP BETWEEN EFI AND UEFI?

The UEFI specification is based on the EFI 1.10 specification published by Intel®, with corrections and changes managed by the UEFI Forum. Intel still holds the copyright on the EFI 1.10 specification, but has contributed it to the Forum so that the Forum can evolve it. There will not be any future versions of the EFI specification, but customers who license it can still use it under the terms of their license from Intel. The license to the Unified EFI Specification will come from the Forum, not from Intel.

UEFI 명세는 인텔에 의해 발표된 EFI 1.10 명세를 기반으로 하며 수정 및 변경사항은 UEFI 포럼에 의해 관리된다. 인텔은 여전히 EFI 1.10 명세의 저작권을 유지하고 있지만 포럼이 그것을 발전시킬 수 있도록 포럼에 기여하고 있다. 그 어떤 EFI 명세의 추후 버전은 없을 것이지만 라이센스를 가진 이용자들은 인텔의 라이센스 조건 하에 그것을 사용할 수 있다. UEFI 명세는인텔이 아닌 포럼으로부터 나온다.

단순 부팅뿐만 아니라 메모리에 접근하고, 하드웨어에 저장된 시간 값을 가져오는 등 운영체제가 담당하는 기능도 UEFI를 통해 운영체제가 이용하는 것이다. 그러므로 UEFI는 아래 그림과 같이 운영체제와 펌웨어 중간에 위치해있는 셈이다. 

https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface

소프트웨어 스택에서의 EFI 위치

굳이 추가한다면 사용자와 가까운 User Application은 운영체제 위에, 드라이버는 운영체제와 EFI 사이에 위치할 것이다. 아래 그림에서 Run time과 Boot라고 적힌 것이 EFI가 제공하는 런타임 서비스와 부트 서비스다. Microsoft 커뮤니티에 BIOS와 UEFI 관련해 자세하게 작성된 좋은 글이 있어 참고하면 좋을 듯 하다.

https://answers.microsoft.com/en-us/windows/forum/all/uefi-secure-boot-in-windows-81/65d74e19-9572-4a91-85aa-57fa783f0759

EFI의 위치와 역할

본 글의 주제인 GPT에 대한 Specification도 UEFI Specification에서 명시하고 있다. 최신 버전의 UEFI Specification은 아래 링크에서 볼 수 있다. 가장 최신 버전 UEFI Specification을 보면 목차에 GPT에 대한 내용이 있는 걸 볼 수 있다.

https://uefi.org/specifications

GPT(GUID Partition Table)

그렇다면 GPT는 무엇인가. GPT는 EFI가 사용하는 파티션 테이블 구조다. MBR에서는 디스크의 첫 섹터 영역 중 446~510 바이트 영역에 16 바이트 크기의 엔트리 4개를 두고 각각의 파티션 정보를 저장했다. 그리고 파티션 정보가 저장된 영역을 우리는 파티션 테이블이라고 했다. 즉 GPT도 파티션의 시작 섹터, 크기 등을 담은 정보가 담겨있다. 확장 파티션이라는 구조를 사용해 5개 이상의 파티션을 나타내야 했던 MBR과 다르게 GPT는 처음부터 많은 수의 파티션을 나타낼 수 있도록 되어있다.

GPT 시스템은 크게 보호용 또는 하이브리드 MBR, GPT 헤더, 파티션 테이블, 파티션 영역, 백업 영역으로 나뉜다.

GPT Disk Layout

UEFI Specification에서 설명하는 GPT의 이점은 아래와 같다(UEFI 2.9 Specification의 "5.1 GPT and MBR disk layout comparison" 참조).

  • Logical Block Addresses (LBAs) are 64 bits (rahter than 32 bits).
  • Supports many partitions (rather than just four primary partitions).
  • Provides both a primary and backup partition table for redundancy.
  • Uses version number and size fields for future expansions.
  • Uses CRC32 fields for imporved data integrity.
  • Defines a GUID for uniquely idetifying each partition.
  • Uses a GUID and attributes to define partition content type.
  • Each partition contains a 36 character human readable name.

GUID

이름에서도 알 수 있듯이 GPT는 GUID를 사용한다. GUID를 보기 전에 UUID(Universally Unique IDentifier)를 먼저 잠깐 보자.

UUID는 각각의 주체를 고유하게 구분하기 위한 식별자(의 형식과 생성 방법에 대한) 표준이다. 각 주체가 스스로 이름(식별자)을 짓되 고유성을 충족할 수 있도록 하기 위한 방법이 필요했고, 이를 위해 오픈 소프트웨어 재단(OSF)에서 분산 컴퓨팅 환경(DCE)의 일부로 표준화했다. UUID는 16 Octets (128 Bits) 길이의 수(2^128 개가 만들어짐)이며, 표현 방식은 32자의 Hexadecimal과 4개의 하이픈('-')을 사용해 36자를 사용한다.

ex) 01234567-0123-0123-0123-0123456789AB

GUID는 UUID를 기반으로 만들어진 유사 난수다. 응용 프로그램에서 사용되며 특히 MS의 Windows에서 Component를 구별하는 식별자로 자주 사용된다. 예를 들면 WFP(Windows Filtering Platform)에서 필터, 콜아웃 객체들을 식별하는 데 있어 32 비트, 64 비트 정수도 사용되지만 GUID를 사용한 Key로도 이들을 식별할 수 있다. 그래서 GUID와 UUID는 겉보기에는 차이가 없으며 생성방법에만 차이가 있다.

아래 그림은 Windows에서 AMSI Provider를 구분하는 데 GUID를 사용하는 모습이다.

V3Lite의 AMSI Provider GUID

MBR

EFI는 MBR 위치의 부트코드를 사용하지 않는다. 하지만 GPT 시스템에서 디스크의 가장 첫번째 섹터(LBA 0)는 MBR을 사용하던 기존 BIOS와의 호환성을 위해 Legacy MBR이 위치될 수 있다. non-UEFI 모드에서는 MBR의 부트코드가 실행되지만 GPT를 사용하는 시스템에선 MBR의 부트코드는 실행되지 않는다.

GPT 시스템의 MBR Partition Table Entry는 파티션 타입 값으로 아래 값들을 가질 수 있다.

  • 0xEE: 전체 디스크를 다루는(covering) 가짜 파티션(a fake partition)을 정의하기 위해 Protective MBR에서 사용된다.
  • 0xEF: UEFI 시스템 파티션임을 나타낸다.

부팅 가능한 디스크에서 Protective MBR은 GPT 디스크 레이아웃의 LBA 0 섹터에 위치해야 한다. GPT 파티션 구조를 이해하지 못하는 툴들과의 호환성을 유지하기 위해 Protective MBR은 GPT 파티션 테이블 헤더(LBA 1)보다 앞서있다. Protective MBR은 아래 표와 같은 값을 가진다.

영역 오프셋 크기 내용
Boot Code 0 440 Unused by UEFI systems.
Unique MBR Disk Signauter 440 4 Unused. Set to zero.
Unknown 444 2 Unused. Set to zero.
Partition Record 446 16 * 4 Array of four MBR partition records.
Signature 510 2 Set to 0x55AA

Protective MBR의 파티션 테이블은 첫번째 엔트리만 사용하며, 디스크 전체 영역을 예약(reserving)하기 위한 값들이 저장된다. 나머지 3개 엔트리는 모두 0으로 채워진다. 디스크의 크기가 2 TB를 넘어 Protective MBR Partition Table Entry로 전체 디스크를 예약하지 못해도 GPT가 2 TB 크기를 넘어 인식할 수 있기 때문에 대용량 디스크도 사용하는 데 문제가 없다. 첫번째 엔트리에는 다음 값들이 들어갈 수 있다.

영역 오프셋 크기 내용
BootIndicator 0 1 Set to zero.
StartingCHS 1 3 Set to 0x200.
OSType 4 1 Set to 0xEE (i.e., GPT Protective)
EndingCHS 5 3 Set to 1.
StartingLBA 8 4 Set to 1.
SizeInLBA 12 4 Set to -1(0xFFFFFFFF).

EFI가 아닌 BIOS 서비스를 사용해 GPT 기반의 부팅을 지원하는 운영체제에서는 디스크의 첫번째 섹터(LBA 0)는 GPT 파티션 시스템을 인식할 수 있도록 수정된 부트로더 코드를 저장하는 데 사용될 수 있다. 이 경우 디스크의 기본 섹터 크기가 512 바이트가 아닐 수 있다. 이는 Hybrid MBR이라고 한다.

Close

글이 길어져 본 글에서는 GPT를 사용하는 EFI란 것에 대한 설명과 GPT에 대한 개요, Protective MBR에 대한 설명에서 끝내고 GPT의 주요 내용들은 다음 글에서 이어 작성하도록 하겠다.

 

 

https://geun-yeong.tistory.com/70

 

#1 GPT - GUID Partition Table (1)

Table of Contents Abstract 본 글과 다음 글에서는 GUID Partition Table에 대해 알아볼 것이다. GPT는 EFI에서 사용하는 디스크 파티션 구조로, BIOS 시스템의 MBR을 개선하기 위해 만들어졌으며, 더 큰 주소 비

geun-yeong.tistory.com

 

728x90

I

In this post we will be discussing about the following things.

  • 1.What is MBR partition table?
  • 2.What were the demerits of MBR partition structure?
  • 3.What is GPT Partition table?
  • 4.What are the plus points of GPT?
  • 5.What tools in Linux can be used to create GPT partition structure?

With the increasing demand for large size partitions, the partitioning and file systems are becoming more complex and advanced.

there are two mainly used disk partition styles.They are as follows.

1.MBR (Master Boot Record) partitioning style

2.GPT (GUID Partition Table)

Both the above mentioned schemes are used to identify the location of the partition on the hard disk.the type of partition used is decided when the disk is initiliazed.

the above shown diagram shows a disk initialization dialog in windows, when a new disk is added to the machine. when you initialize the disk these days you are presented with exactly the same options as shown in the above figure.

Master Boot Record (MBR) or Globally Unique Identifier Partition Table (GPT.).Previously there was only one option MBR.

MBR Partitioning style:

in this style the MBR resides in the first 512 bytes of the hard disk. This 512 bytes contains two things in MBR partitioning scheme.

  1. 440 bytes for boot loader(Grub, or windows boot loader)
  2. the remaining space is used for the partition table, ie: there can only be 4 primary partition in an MBR partitioning scheme.this remaining area also has the partition location information.

this can be done by two methods

  • CHS method: in this method a partition is located through cylinder,head,sector method. this is mentioned by a 24 bit number, in this case it can only mention disk at the max of 8gb.
  • LBA method: LBA stands for Logical Block Addressing, in this each and every sector is numbered serially resulting easy addressing of spaces upto 2TB.

Demerits of MBR partitioning scheme:

  1. it only allows four primary partitions.
  2. the workaround for creating more than four partition by making one of them extended(containing logical partitions inside that) this also leads to problems sometimes as some operating systems can only boot from Primary partitions. → Can be possible only some operating system can only boot from primary partititions.
  3. the CHS implementation in MBR partition table can lead to problems because the Cylinder,Head,Sector geometry of the disk can change.
  4. even the LBA scheme implemented puts a 2tb limitation.
  5. Logical partitions are stored in Linked List data structure over the extended partition, and can easily fail, which intern make can make some logical partitions inaccessible.

GPT Partition Style:

Now the MBR type partition table keep the partition table info such as information about the four primary partition in the first 512 bytes of the hard disk. In case of GPT the first sector is kept for "protective MBR" so that, old bios based computers can also boot from GPT partition table.

The GPT partition information starts from the second block or call it LBA 1

Note: LBA is nothing but the sectors numbered in such a way that it can be easily addressed, like LBA 0 is for MBR,LBA 1 for GPT header info etc.


LBA 0 - Protective MBR

LBA 1 - GPT Header information (GPT partition information)

LBA 2 - GPT partition array entry → 128 bytes for each partition array (1byte), which calls partition code

                                                → can reach upto 16,384 bytes. (16 byte), which calls GUID, consisting of randomly UUID


And most of the time LBA 2 contains GPT partition array entry.

the partition array entry typically reserves 128 bytes for each partition entry. Now for a disk of 512-byte sectors the partition array entry can reach upto 16,384 bytes. And in most cases the 34'th sector or call it block is the first usable sector in the disk.

Merits of GPT partition Style:

1.GPT supports up to 128 partitions so there is no need for extended of logical partitions.

2.GPT addresses 64 bit number LBA scheme, so it can address up to 8 ZiB size partitions.

3.GPT structure have primary and secondary header, so recovery is more promising that MBR

4.GPT provides 1 byte partition code, but GPT give you 16byte GUID value to uniquely identify the partition.

Tools for Creating GPT partitions:

Fdisk cannot create a GPT partition so we need to use some other tool to create it.

1.Parted can be used to create GPT partition table, and partitions of more than 2tb size.

2.Gdisk is also a nice tool to create GPT partition table.

+ Recent posts