一、parted命令格式
用法格式:parted [選項] [設(shè)備] [指令]
parted命令分為交互模式和非交互模式,如果沒有輸入執(zhí)行,則進入交互模式。
parted操作即刻生效,注意謹慎操作。
1.參數(shù)
| 參數(shù) | 作用 |
|---|---|
| -h | 顯示幫助信息 |
| -l | 列出系統(tǒng)所有磁盤的分區(qū)情況 |
| -s | 腳本模式,關(guān)閉交互模式 |
| -v | 查看版本 |
2.指令
| 常用指令 | 作用 |
|---|---|
| mklabel或mktable | 創(chuàng)建分區(qū)表 |
| mkpart | 創(chuàng)建分區(qū) |
| resizepart | 調(diào)整分區(qū)大小 |
| rm | 刪除分區(qū) |
| rescue | 恢復丟失的分區(qū) |
| name | 給指定的分區(qū)命名 |
| p | 打印分區(qū)信息 |
| q | 退出程序 |
| h | 幫助信息 |
二、非交互模式的使用
1.創(chuàng)建GPT分區(qū)表
[root@work1 ~]# parted /dev/sdb mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
Information: You may need to update /etc/fstab.
[root@work1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
2.創(chuàng)建磁盤分區(qū)
[root@work1 ~]# parted /dev/sdb mkpart test01 0% 100MB
Information: You may need to update /etc/fstab.
[root@work1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 99.6MB 98.6MB xfs test01
3.調(diào)整磁盤分區(qū)大小
[root@work1 ~]# parted /dev/sdb resizepart 1 200MB
Information: You may need to update /etc/fstab.
[root@work1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 200MB 199MB xfs test01
4.命名磁盤分區(qū)名稱
[root@work1 ~]# parted /dev/sdb name 1 test02
[root@work1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 200MB 199MB xfs test02
5.刪除磁盤分區(qū)
[root@work1 ~]# parted /dev/sdb rm 1
Information: You may need to update /etc/fstab.
[root@work1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags