본문 바로가기

리눅스-기초명령어/스토리지

gdisk

gdisk

fdisk와 같은 유틸리티로 fdisk는 MBR타입, gdisk는 GPT타입으로 파티션에 사용된다.  fdisk가 2TB 미만의 Disk 파티션닝을 한다면 2TB이상 대용량에서 gdisk 또는 parted로 구성한다.

 

1. 파티션 나누기

gdisk로 nvme0n2 파티션 생성

[root@rocky1 ~]# gdisk /dev/nvme0n2
GPT fdisk (gdisk) version 1.0.7

Partition table scan:
  MBR: not present

#마스터부트레코드 부팅지원파티션,
  파티션을15개까지밖에지원안됨
  BSD: not present
  APM: not present
  GPT: not present

#최대 128개의 파티션을 지원함 (한파티션의 용량제한이없음)

Creating new GPT entries in memory.

Command (? for help):

 

커맨드 확인

Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu

 

n : 파티션 추가

Command (? for help): n
Partition number (1-128, default 1): 

First sector (34-419430366, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-419430366, default = 419430366) or {+-}size{KMGTP}: 
#호환성을 위해 2048 까지 섹터를 비운다
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 

#8300  일반 파일시스템
#8200  스왑 파티션
#8e00  LVM 파티션 (Logical Volume Manager) 논리볼륨
Changed type of partition to 'Linux filesystem'

 

파티션 확인

Command (? for help): p
Disk /dev/nvme0n2: 419430400 sectors, 200.0 GiB
Model: VMware Virtual NVMe Disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): AD51646C-845E-44DD-ABA6-7464D5FB2513
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 419430366
Partitions will be aligned on 2048-sector boundaries
Total free space is 4061 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048        20971520   10.0 GiB    8300  Linux filesystem

 

최종 확인

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): 

 

파티션 재 인식

[root@rocky1 /]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

 

2. 파티션 타입 변경

gdisk를 이용한 파티션 타입 변경

 

gdisk

[root@rocky1 mnt]# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.7

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

Found valid GPT with protective MBR; using GPT.

Command (? for help): ?

 

t옵션

Command (? for help): t
Partition number (1-4): 2

#2번 파티션 선택
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8200

#타입 변경
Changed type of partition to 'Linux swap'

 

확인

Command (? for help): p
Disk /dev/sda: 419430400 sectors, 200.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 206B39E7-711A-48A4-B61B-5AD9A49175AC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 419430366
Partitions will be aligned on 2048-sector boundaries
Total free space is 329444187 sectors (157.1 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048        62914559   30.0 GiB    8300 
   2        62914560        83866079   10.0 GiB    8200

                                       #8300에서 8200으로 변경 
  3        83886080        90000000   2.9 GiB     8300  test
  4        90001408        90009600   4.0 MiB     8300  



3. 파티션 이름 변경

gdisk c옵션 사용

Command (? for help): c
Partition number (1-4): 2
Enter name: swap 1
#2번 파티션 이름 swap 1로 변경


Command (? for help): c
Partition number (1-4): 3
Enter name: swap 2

#3번 파티션 이름 swap 2로 변경

 

확인

Command (? for help): p
Disk /dev/sda: 419430400 sectors, 200.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 206B39E7-711A-48A4-B61B-5AD9A49175AC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 419430366
Partitions will be aligned on 2048-sector boundaries
Total free space is 329444187 sectors (157.1 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048        62914559   30.0 GiB    8300 
  2        62914560        83866079   10.0 GiB    8200  swap 1
  3        83886080        90000000   2.9 GiB     8200  swap 2
  4        90001408        90009600   4.0 MiB     8300  

 

변경된 파티션 저장

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/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

 

'리눅스-기초명령어 > 스토리지' 카테고리의 다른 글

mkfs  (0) 2023.09.01
parted  (0) 2023.09.01
blkid, lsblk  (0) 2023.09.01
파일시스템  (1) 2023.09.01
스토리지  (0) 2023.09.01