Linux磁盤管理-分區(qū)工具parted

一、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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容