[Linux 기초] 20. 디스크 관리 - parted 파티션 관리
카테고리: LINUX
태그: linux
01. parted
fdisk 와 같이 리눅스 환경에서 디스크 또는 LUN의 파티션을 생성, 삭제, 관리하기 위해 사용되는 명령으로 fdisk와는 달리 GPT와 MBR 방식의 파티션 테이블을 사용할 수 있으며 2TB 이상의 대용량 디스크 또는 LUN에 대해 파티션 생성 및 관리가 가능합니다.
■ 명령 형식
$ parted [옵션] [ device [command [option]]]
| 옵션 | 설명 |
|---|---|
| -l | 디스크들의 파티션 정보를 보여준다. |
| 하부 명령 | 설명 |
|---|---|
| mklabel VALUE | 새로운 파티션 테이블 생성 (값은 gpt, msdos 등이 있음) |
| mkpart | 파티션 생성(순서 : mkpart part-type fs-type start end) |
| rm | 파티션 삭제 |
| resize | 파티션 크기 조정 |
| 파티션 테이블 출력 | |
| unit VALUE | 사용할 단위를 정의 (값은 MB, GB, TB 가 있음) |
■ 예제
-
파티션 정보 및 파티션 테이블 저장 방식을 확인 (msdos는 MBR이다.)
$ parted /dev/sdb print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 5370MB 5369MB primary ext4 2 5370MB 21.5GB 16.1GB primary $ parted /dev/sdc print Error: /dev/sdc: unrecognised disk label Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags: -
gpt 방식의 파티션 테이블을 사용
$ parted /dev/sdc mklabel gpt Information: You may need to update /etc/fstab. $ parted /dev/sdc print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags -
파티션을 분할 1
$ parted /dev/sdc unit GB mkpart 1st ext4 0 3 Information: You may need to update /etc/fstab. $ parted /dev/sdc print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 3000MB 2999MB 1st $ lsblk /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 0 20G 0 disk └─sdc1 8:33 0 2.8G 0 part -
파티션 삭제
$ parted /dev/sdc rm 1 Information: You may need to update /etc/fstab. $ parted /dev/sdc print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags $ lsblk /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 0 20G 0 disk -
파티션 분할 2
$ parted /dev/sdc unit GB mkpart 1st ext4 0 50% Information: You may need to update /etc/fstab. $ parted /dev/sdc print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 10.7GB 10.7GB 1st $ parted /dev/sdc unit GB mkpart 2nd ext4 10.7 100% Information: You may need to update /etc/fstab. $ parted /dev/sdc print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 10.7GB 10.7GB 1st 2 10.7GB 21.5GB 10.7GB 2nd $ lsblk /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 0 20G 0 disk ├─sdc1 8:33 0 10G 0 part └─sdc2 8:34 0 10G 0 part -
parted 명령 안에서 상호 대화형 모드로 파티션을 분할
$ parted /dev/sdc GNU Parted 3.5 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) (parted) unit GB (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags (parted) mklabel gpt Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Y (parted) mkpart 1th ext4 0 20 (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 0.00GB 20.0GB 20.0GB ext4 1th (parted) q Information: You may need to update /etc/fstab. $ lsblk /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 0 20G 0 disk └─sdc1 8:33 0 18.6G 0 part
댓글 남기기