루트 볼륨 파티션 테이블 형식 변경하기

페이지 이동경로

루트 볼륨 파티션 테이블 형식 변경하기

특정 운영체제(OS) 기반의 인스턴스는 루트 볼륨 디스크의 기본 파티션 테이블 형식이 MBR(Master Boot Record) 파티셔닝 체계입니다. MBR 파티셔닝 체계는 최대 4개의 파티션만 지원하며 최대 2.0TB 용량 이하의 디스크에서만 작동하지만, GPT 파티셔닝 체계는 파티션 수 및 용량에 제한이 없습니다.
카카오 i 클라우드에서는 각 OS의 클라우드 이미지를 설정 변경 없이 그대로 제공하고 있습니다. 현재 카카오 i 클라우드에서 제공 중인 CentOS, CentOS Stream, Rocky Linux OS를 기반으로 하는 인스턴스의 루트 볼륨 파티션 테이블 형식(MBR)을 GPT(GUID Partition Table) 체계로 변경하는 방법은 다음과 같습니다.

카카오 i 클라우드 제공 OS 별 파티션 테이블 형식 및 파일 시스템 타입

OS 이름 버전 Root Volume 파티션 테이블 형식
Ubuntu 18.04 GPT
Ubuntu 20.04 GPT
CentOS 7.9 MBR
CentOS Stream 8.0 MBR
Rocky Linux 8.5 MBR
Alma Linux 9.0 GPT
Windows 2019 MBR
Windows 2022 MBR

CentOS 인스턴스의 루트 볼륨 파티션 테이블 형식 변경하기

CentOS 인스턴스의 디스크 파티션 테이블 형식을 MBR에서 GPT로 변경하는 방법은 다음과 같습니다.

안내
현재 카카오 i 클라우드에서 제공 중인 CentOS 7.9 이미지를 기준으로 안내합니다.(MBR to GPT)

주의
기존에 사용 중인 볼륨의 파티션 테이블 형식을 변경하는 경우, 데이터 보존에 유의해야 하며 변경 전 백업을 권장합니다.

  1. lsblk 명령어로 현재 디스크 정보를 확인합니다.

    코드 예제 Klsblk 명령

    [root@centos7 ~]$ sudo fdisk -l
       
    Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x0009b542
       
    Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048    20971486    10484719+  83  Linux
    
  2. gdisk 명령어로 현재 디스크의 파티션 테이블 정보를 확인합니다.

    코드 예제 gdisk 명령

       [root@centos7 ~]$ sudo gdisk -l /dev/vda
       GPT fdisk (gdisk) version 0.8.10
        
       Partition table scan:
       MBR: MBR only
       BSD: not present
       APM: not present
       GPT: not present
          
       ***************************************************************
       Found invalid GPT and valid MBR; converting MBR to GPT format
       in memory.
       ***************************************************************
          
       Disk /dev/vda: 20971520 sectors, 10.0 GiB
       Logical sector size: 512 bytes
       Disk identifier (GUID): 79C4C601-BF62-45E4-97F8-AB21F158EED7
       Partition table holds up to 128 entries
       First usable sector is 34, last usable sector is 20971486
       Partitions will be aligned on 2048-sector boundaries
       Total free space is 2014 sectors (1007.0 KiB)
          
       Number  Start (sector)    End (sector)  Size       Code  Name
         1            2048        20971486   10.0 GiB    8300  Linux filesystem
    
  3. gdisk 명령어로 파티션 테이블을 MBR에서 GPT로 변경합니다.
    • GPT에서는 boot 파티션이 필요하므로 해당 파티션을 생성합니다.
    • boot 파티션은 first sector 34, last sector 2047로 지정하고, 파티션 코드는 ef02로 선택합니다.

      코드 예제 gdisk 명령

        [root@centos7 ~]$ sudo gdisk /dev/vda
        GPT fdisk (gdisk) version 0.8.10
              
        Partition table scan:
          MBR: MBR only
          BSD: not present
        APM: not present
        GPT: not present
              
              
        ***************************************************************
        Found invalid GPT and valid MBR; converting MBR to GPT format
        in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
        typing 'q' if you don't want to convert your MBR partitions
        to GPT format!
        ***************************************************************
          
        # 'n' 입력(add a new partition)
        Command (? for help): n 
        # 엔터 입력(default :2)
        Partition number (2-128, default 2): 
        # 엔터 입력(default 34)
        First sector (34-2047, default = 34) or {+-}size{KMGTP}: 
        # 엔터 입력(default 2047)
        Last sector (34-2047, default = 2047) or {+-}size{KMGTP}: 
        # 'ef02' 입력
        Current type is 'Linux filesystem'
        Hex code or GUID (L to show codes, Enter = 8300): ef02
        Changed type of partition to 'BIOS boot partition'
          
        # 'w' 입력(write table to disk and exit)
        Command (? for help): w
        Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
        PARTITIONS!!
          
        # 'y' 입력
        Do you want to proceed? (Y/N): y
        OK; writing new GUID partition table (GPT) to /dev/vda.
        Warning: The kernel is still using the old partition table.
        The new table will be used at the next reboot.
        The operation has completed successfully.
      
  4. 신규 boot 파티션에 grub을 설치합니다.

    코드 예제 grub 설치

    #신규 파티션 인식
    [root@centos7 ~]$ sudo partprobe
    #GRUB 설치
    [root@centos7 ~]$ sudo grub2-install /dev/vda
    Installing for i386-pc platform.
    Installation finished. No error reported.
    
  5. 변경사항 반영을 위해 재기동 명령을 실행합니다.

    코드 예제 재기동 명령어

    [root@centos7 ~]$ sudo reboot
    
  6. lsblk 명령어로 디스크 파티션 테이블 형식이 잘 변경되었는지 확인합니다.

    코드 예제 형식 변경 확인

    [root@centos7 ~]$ sudo fdisk -l
    WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. 
    Disk /dev/vda: 3221.2 GB, 3221225472000 bytes, 6291456000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: gpt
    Disk identifier: D9C42684-E18C-4B8F-9388-C2F2CDC093ED 
    #         Start          End    Size  Type            Name
    1         2048   6291455965      3T  Linux filesyste Linux filesystem
    2           34         2047   1007K  BIOS boot       BIOS boot partition