상세 컨텐츠

본문 제목

4.로컬 스토리지 설정 - fdisk로 파티션 생성, 삭제, 확인

엔지니어일기/RHCSA준비

by jaws99 2022. 10. 20. 23:20

본문

반응형

fdisk로 파티션 생성

$ fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

# n 옵션으로 새로운 파티션 추가
Command (m for help): n
Partition number (1-128, default 1):
First sector (34-62914526, default 2048):
# +10K +10G +100M 등 표현 가능
Last sector, +sectors or +size{K,M,G,T,P} (2048-62914526, default 62914526): +10G

Created a new partition 1 of type 'Linux filesystem' and of size 10 GiB.

# p 옵션으로 partition table 확인
Command (m for help): p
Disk /dev/sdb: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disklabel type: gpt
Disk identifier: F7C0AE6A-557D-452F-B65C-6104A14B9AE6

Device     Start      End  Sectors Size Type
/dev/sdb1   2048 20973567 20971520  10G Linux filesystem

# n 옵션으로 두 번째 파티션 추가
Command (m for help): n
Partition number (2-128, default 2):
First sector (20973568-62914526, default 20973568):
Last sector, +sectors or +size{K,M,G,T,P} (20973568-62914526, default 62914526): +15G

Created a new partition 2 of type 'Linux filesystem' and of size 15 GiB.

# w 옵션으로 저장
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

# block device의 리스트를 확인.
$ lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
...
sdb                               8:16   0   30G  0 disk
├─sdb1                            8:17   0   10G  0 part
└─sdb2                            8:18   0   15G  0 part

 

 

파티션 삭제 및 리스트 확인.

$ fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdb: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disklabel type: gpt
Disk identifier: F7C0AE6A-557D-452F-B65C-6104A14B9AE6

Device        Start      End  Sectors Size Type
/dev/sdb1      2048 20973567 20971520  10G Linux filesystem
/dev/sdb2  20973568 52430847 31457280  15G Linux filesystem

# d 옵션으로 파티션 삭제
Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): p
Disk /dev/sdb: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disklabel type: gpt
Disk identifier: F7C0AE6A-557D-452F-B65C-6104A14B9AE6

Device     Start      End  Sectors Size Type
/dev/sdb1   2048 20973567 20971520  10G Linux filesystem

# w 옵션으로 저장
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

# block device의 리스트를 확인.
$ lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
...
sdb                               8:16   0   30G  0 disk
└─sdb1                            8:17   0   10G  0 part
반응형

관련글 더보기