13.5. fdisk를 사용하여 파티션 크기 조정
fdisk 유틸리티를 사용하면 GPT, MBR, Sun, SGI 및 BSD 파티션 테이블을 만들고 조작할 수 있습니다. GPG(GUID 파티션 테이블)가 있는 디스크의 경우 parted 유틸리티를 사용하는 것이 좋습니다.절차 GPT 지원이 실험 단계에 있기 때문입니다.
파티션 크기를 조정하기 전에 파일 시스템에 저장된 데이터를 백업하고, metadata를 사용하여 파티션 크기를 변경하는 유일한 방법은 파티션을 삭제하고 다시 생성하는 것입니다.
중요
크기 조정 중인 파티션은 특정 디스크의 마지막 파티션이어야 합니다.
Red Hat은 LVM 파티션 확장 및 크기 조정만 지원합니다.
절차 13.4. 파티션 크기 조정
다음 절차는 참조용으로만 제공됩니다.
fdisk 를 사용하여 파티션의 크기를 조정하려면 다음을 수행합니다.
- 장치를 마운트 해제합니다.
# umount /dev/vda - fdisk disk_name 을 실행합니다. 예를 들어 다음과 같습니다.
# fdisk /dev/vda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): - 삭제할 파티션의 행 번호를 확인하려면
p옵션을 사용합니다.Command (m for help): p Disk /dev/vda: 16.1 GB, 16106127360 bytes, 31457280 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: 0x0006d09a Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 31457279 15215616 8e Linux LVM - 파티션을 삭제하려면 d 옵션을 사용합니다. 둘 이상의 파티션을 사용할 수 있는 경우 fdisk 에서 삭제할 파티션 수를 입력하라는 메시지를 표시합니다.
Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 is deleted n옵션을 사용하여 파티션을 생성하고 프롬프트를 따릅니다. 향후 크기 조정을 위한 충분한 공간을 허용합니다. fdisk 기본 동작(Enter키를 누름)은 장치의 모든 공간을 사용하는 것입니다. 파티션의 끝을 섹터별로 지정하거나 + <size> < suffix> (예: +500M 또는 +10G)을 사용하여 사람이 읽을 수 있는크기를 지정할 수 있습니다.모든 여유 공간을 사용하지 않으려면 fdisk 에서 파티션의 끝을 물리 섹터에 맞추기 때문에 사람이 읽을 수 있는 크기 사양을 사용하는 것이 좋습니다. 정확한 수( 섹터)를 제공하여 크기를 지정하는 경우, fdisk 는 파티션의 끝을 정렬하지 않습니다.Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): *Enter* Using default response p Partition number (2-4, default 2): *Enter* First sector (1026048-31457279, default 1026048): *Enter* Using default value 1026048 Last sector, +sectors or +size{K,M,G} (1026048-31457279, default 31457279): +500M Partition 2 of type Linux and of size 500 MiB is set- 파티션 유형을 LVM으로 설정합니다.
Command (m for help): t Partition number (1,2, default 2): *Enter* Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' - 변경 사항이 올바른지 확인하는 경우 w 옵션으로 변경 사항을 작성하십시오. 오류로 인해 선택한 파티션에 불안정할 수 있습니다.
- 장치에서 e2fsck 를 실행하여 일관성을 확인합니다.
# e2fsck /dev/vda 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 ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks - 장치를 마운트합니다.
# mount /dev/vda
자세한 내용은 fdisk(8) 매뉴얼 페이지를 참조하십시오.