EBS 볼륨의 MBR 파티션에 대한 2TiB 제한을 우회하기 위해 EC2 CentOS 인스턴스의 기본 MBR 파티셔닝 체계를 GPT로 변환하려면 어떻게 해야 합니까?

8분 분량
0

내 Amazon Elastic Compute Cloud(Amazon EC2) 인스턴스는 AWS Marketplace에서 centos.org별로 CentOS 7을 실행하고 있습니다. Amazon Elastic Block Store(Amazon EBS) 볼륨의 기본 MBR 파티셔닝 체계를 GPT 파티셔닝 체계로 변환하여 MBR 파티션의 2TiB 제한을 우회하려면 어떻게 해야 합니까?

​해결 방법

경고: 인스턴스를 중지하고 시작하기 전에 다음을 이해해야 합니다.

  • 인스턴스를 중지했다가 시작하면 인스턴스 스토어 데이터가 손실됩니다. 사용하는 인스턴스가 인스턴스 스토어 지원 인스턴스이거나 인스턴스에 데이터가 포함된 인스턴스 스토어 볼륨이 있으면 인스턴스 중지 시 데이터가 손실됩니다. 자세한 내용은 인스턴스의 루트 디바이스 유형 확인을 참조하십시오.

  • 인스턴스가 Amazon EC2 Auto Scaling 그룹의 일부인 경우 인스턴스를 중지하면 인스턴스가 종료될 수 있습니다. Amazon EMR, AWS CloudFormation 또는 AWS Elastic Beanstalk를 사용하여 인스턴스를 시작한 경우 인스턴스가 AWS Auto Scaling 그룹의 일부일 수 있습니다. 이 시나리오에서 인스턴스 종료는 Auto Scaling 그룹에 대한 인스턴스 축소 보호 설정에 따라 달라집니다. 인스턴스가 Auto Scaling 그룹의 일부인 경우, 문제 해결 단계를 시작하기 전에 Auto Scaling 그룹에서 일시적으로 인스턴스 제거합니다.

  • 인스턴스를 중지했다가 시작하면 인스턴스의 퍼블릭 IP 주소가 변경됩니다. 외부 트래픽을 인스턴스로 라우팅할 때는 퍼블릭 IP 주소 대신 탄력적 IP 주소를 사용하는 것이 가장 좋습니다. Route 53를 사용하는 경우 퍼블릭 IP가 변경될 때 Route 53 DNS 레코드를 업데이트해야 할 수 있습니다.

참고: 해결 단계를 시작하기 전에 EBS 볼륨의 백업을 생성하는 것이 좋습니다.

1.    Amazon EC2 콘솔을 엽니다.

2.    CentOS 7을 실행하는 AWS Marketplace Amazon Machine Image(AMI)에서 인스턴스를 시작합니다.

3.    첫 번째 인스턴스와 동일한 가용 영역에서 3TiB 루트 볼륨의 동일한 CentOS AMI를 사용하여 두 번째 인스턴스를 시작합니다.

참고: CentOS 7 인스턴스가 이미 있는 경우 새 CentOS 7 인스턴스를 시작할 필요가 없습니다. CentOS 7의 경우, 루트 볼륨을 수정하여 크기를 2TiB 이상으로 확장합니다.

4.    3TiB 루트 볼륨이 있는인스턴스를 중지하고 2단계에서 생성한 인스턴스를 중지합니다.

참고: CentOS 7은 AWS Marketplace AMI에서 제공되므로 AWS Marketplace 코드를 사용하여 볼륨을 연결하기 전에 인스턴스를 중지해야 합니다. 인스턴스를 중지하지 않으면 다음 오류가 발생합니다.

“볼륨을 연결하는 동안 오류가 발생했습니다. 'i-xxxxxxxxxxxxxxxx' 인스턴스가' 중지됨 '상태가 아니므로 Marketplace 코드와 함께 볼륨 'vol-xxxxxxxxxxxxxxxxx'을 연결할 수 없습니다.“

5.    중지된 인스턴스에서 루트 볼륨(/dev/xvda 또는 /dev/sda1)을 분리한 다음 2단계에서 /dev/sdf로 생성한 인스턴스에 연결합니다.

참고: t2와 같은 Xen 플랫폼 인스턴스 유형을 사용하십시오. t3과 같은 Nitro 플랫폼을 사용하는 경우 장치 이름이 NVMeXn1로 변경됩니다.

6.    2단계에서 시작한 인스턴스를 시작하고 SSH를 사용하여 인스턴스에 연결합니다.

7.    lsblk 명령을 사용하여 /dev/sdf의 루트 파티션을 봅니다. 다음 예제에 표시된 것과 같이 /dev/sdf의 루트 파티션은 단 2TiB입니다.

# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
(snip)
xvdf    202:80    0   3T  0 disk 
└─xvdf1 202:81    0   2T  0 part 
(snip)

참고: /dev/xvdf1이 루트 파일 시스템 "/“로 마운트될 수 있습니다. 이 경우 /dev/xvda1이 루트 파일 시스템으로 마운트될 때까지 인스턴스를 몇 번 중지하고 시작합니다.

# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdf    202:80   0   3T  0 disk 
└─xvdf1 202:81   0   2T  0 part 

8.    gdisk 도구를 사용하여 파티션 테이블을 MBR에서 GPT로 변환합니다.

참고: gdisk 도구가 아직 설치되어 있지 않은 경우 sudo yum install gdisk -y 명령을 사용하여 설치할 수 있습니다.

# sudo gdisk /dev/xvdf
GPT fdisk (gdisk) version 1.0.1
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!

9.    프롬프트에 다음 명령을 입력하여 GPT 파티션을 생성합니다. Last sector 프롬프트에서 enter를 입력하여 기본 섹터 번호 2047을 사용합니다.

Command (? for help): n                                                                                                        
Partition number (2-128, default 2): 128                                                                               
First sector (34-6291455966, default = 4294967296) or {+-}size{KMGTP}: 34                     
Last sector (34-2047, default = 2047) or {+-}size{KMGTP}:                                                  
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02                                                     
Changed type of partition to 'BIOS boot partition'

참고: 앞의 예에서 ef02는 BIOS 부팅 파티션 번호입니다.

10.    프롬프트에 다음 명령을 입력하여 루트 파티션을 삭제합니다.

Command (? for help): d                                                                                                         
Partition number (1-128): 1

11.    프롬프트에 다음 명령을 입력하여 루트 파티션을 3TB로 다시 생성합니다. First sector, Last sectorHex code 또는 GUID 프롬프트에서 enter를 입력하여 기본 설정을 사용합니다.

Command (? for help): n                                                                                                         
Partition number (1-128, default 1): 1                                                                                     
First sector (2048-6291455966, default = 2048) or {+-}size{KMGTP}:                                  
Last sector (2048-6291455966, default = 6291455966) or {+-}size{KMGTP}:                       
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):                                                             
Changed type of partition to 'Linux filesystem'

12.    프롬프트에 다음 명령을 입력하여 GPT 파티션 테이블을 저장합니다.

Command (? for help): w                                                                                                        
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y                                                                                          
OK; writing new GUID partition table (GPT) to /dev/xvdf.
The operation has completed successfully.

gdisk 명령을 실행하여 새 파티션 정보를 봅니다.

$ sudo gdisk -l /dev/xvdf
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/xvda: 6291456000 sectors, 2.9 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 35D6B819-1C79-4EC0-920F-4D1191609505
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6291455966
Partitions will be aligned on 8-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048      6291455966   2.9 TiB     8300  Linux filesystem
 128              34            2047   1007.0 KiB  EF02  BIOS boot partition

13.    파일 시스템 확인 및 복구 도구를 사용하여 /dev/xvdf1 디바이스의 파일 시스템이 올바른지 확인합니다.

CentOS 7:

# sudo xfs_repair /dev/xvdf1
Phase 1 - find and verify superblock...
        - reporting progress in intervals of 15 minutes
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - 05:27:07: scanning filesystem freespace - 1025 of 1025 allocation groups done
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - 05:27:07: scanning agi unlinked lists - 1025 of 1025 allocation groups done
        - process known inodes and perform inode discovery...
        - agno = 960
        - agno = 0
        - agno = 240
        - agno = 480

(snip)
        - agno = 238
        - agno = 239
        - 05:27:08: process known inodes and inode discovery - 25856 of 25856 inodes done
        - process newly discovered inodes...
        - 05:27:08: process newly discovered inodes - 1025 of 1025 allocation groups done
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - 05:27:08: setting up duplicate extent list - 1025 of 1025 allocation groups done
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - agno = 4

(snip)
        - agno = 1021
        - agno = 1022
        - agno = 1023
        - agno = 1024
        - 05:27:08: check for inodes claiming duplicate blocks - 25856 of 25856 inodes done
Phase 5 - rebuild AG headers and trees...
        - 05:27:08: rebuild AG headers and trees - 1025 of 1025 allocation groups done
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
        - 05:27:08: verify and correct link counts - 1025 of 1025 allocation groups done
done

CentOS 6:

# sudo e2fsck -f /dev/xvdf1
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/xvdf1: 18734/524288 files (0.2% non-contiguous), 284948/2096896 blocks

14.    xfs_growfs 또는 resize2fs 명령을 실행하여 파일 시스템의 크기를 3TB로 확장하십시오.

참고: 파일 시스템의 크기를 조정하는 데 몇 분 정도 걸릴 수 있습니다.

CentOS 7:

# sudo mount -o nouuid /dev/xvdf1 /mnt

# sudo xfs_growfs /dev/xvdf1
meta-data=/dev/xvdf1             isize=512    agcount=1025, agsize=524224 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=536870656, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 536870656 to 786431739

CentOS 6:

# sudo resize2fs /dev/xvdf1
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/xvdf1 to 786431739 (4k) blocks.

The filesystem on /dev/xvdf1 is now 786431739 blocks long.

15.    디바이스 /dev/xvdf1에 Grub을 설치하고 다음 명령을 사용하여 구성합니다.

참고: S 6에는 Grub 설치가 필요하지 않습니다. CentOS 6을 사용하는 경우 16단계로 건너뜁니다.

CentOS 7:

sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount --bind /dev /mnt/dev
sudo chroot /mnt /bin/bash
grub2-install /dev/xvdf
exit
sudo umount -l /mnt/dev
sudo umount -l /mnt/sys
sudo umount -l /mnt/proc
sudo umount -l /mnt

16.    인스턴스를 중지합니다.

17.    중지된 인스턴스에서 /dev/xvdf 볼륨을 분리합니다.

18.    /dev/xvdf 볼륨을 원래 인스턴스에 /dev/sda1로 다시 연결합니다.

19.    원래 인스턴스를 시작하고 SSH를 사용하여 인스턴스에 연결합니다.

20.    lsblk 명령을 실행하여 원본 인스턴스의 루트 볼륨에 3TiB의 공간이 있는지 확인합니다.

$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   3T  0 disk 
└─xvda1 202:1    0   3T  0 part /

관련 정보

EBS 볼륨의 MBR 파티션에 대한 2TiB 제한을 우회하기 위해 EC2 Ubuntu 인스턴스의 기본 MBR 파티셔닝 체계를 GPT로 변환하려면 어떻게 해야 합니까?

AWS 공식
AWS 공식업데이트됨 4년 전
댓글 없음