[root@localhost ~]# parted 硬盤設備文件名
#進入交互模式
[root@localhost ~]# parted /dev/sdb
#打算繼續(xù)劃分/dev/sdb硬盤
GNU Parted 2.1
使用/dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) <--parted 的等待輸入交互命令的位置,輸入 help,可以看到在交互模式下支持的所有命令
| parted交互命令 | 說 明 |
|---|---|
| check NUMBER | 做一次簡單的文件系統(tǒng)檢測 |
| cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER | 復制文件系統(tǒng)到另一個分區(qū) |
| help [COMMAND] | 顯示所有的命令幫助 |
| mklabel,mktable LABEL-TYPE | 創(chuàng)建新的磁盤卷標(分區(qū)表) |
| mkfs NUMBER FS-TYPE | 在分區(qū)上建立文件系統(tǒng) |
| mkpart PART-TYPE [FS-TYPE] START END | 創(chuàng)建一個分區(qū) |
| mkpartfs PART-TYPE FS-TYPE START END | 創(chuàng)建分區(qū),并建立文件系統(tǒng) |
| move NUMBER START END | 移動分區(qū) |
| name NUMBER NAME | 給分區(qū)命名 |
| print [devices|free|list,all|NUMBER] | 顯示分區(qū)表、活動設備、空閑空間、所有分區(qū) |
| quit | 退出 |
| rescue START END | 修復丟失的分區(qū) |
| resize NUMBER START END | 修改分區(qū)大小 |
| rm NUMBER | 刪除分區(qū) |
| select DEVICE | 選擇需要編輯的設備 |
| set NUMBER FLAG STATE | 改變分區(qū)標記 |
| toggle [NUMBER [FLAG]] | 切換分區(qū)表的狀態(tài) |
| unit UNIT | 設置默認的單位 |
| Version | 顯示版本 |
(parted) print
#進入print指令
Model: VMware, VMware Virtual S (scsi)
#硬盤參數(shù),是虛擬機
Disk/dev/sdb: 21.5GB
#硬盤大小
Sector size (logical/physical): 512B/512B
#扇區(qū)大小
Partition Table: msdos
#分區(qū)表類型,是MBR分區(qū)表
Number Start End Size Type File system 標志
1 32.3kB 5379MB 5379MB primary
2 5379MB 21.5GB 16.1GB extended
5 5379MB 7534MB 2155MB logical ext4
6 7534MB 9689MB 2155MB logical ext4
#看到了我們使用fdisk命令創(chuàng)建的分區(qū),其中1分區(qū)沒被格式化;2分區(qū)是擴展分區(qū),不能被格式化
(partcd) mklabel gpt
#修改分區(qū)表命令
警告:正在使用/dev/sdb上的分區(qū)。由于/dev/sdb分區(qū)已經掛載,所以有警告。注意,如果強制修改,那么原有分區(qū)及數(shù)據(jù)會消失
忽略/Ignore/放棄/Cancel? ignore
#輸入ignore忽略報錯
警告: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
#輸入 yes
警告:WARNING: the kernel failed to re-read the partition table on /dev/sdb (設 備或資源忙).As a result, it may not reflect all of your changes until after reboot.
#下次重啟后才能生效
(parted) print
#查看一下分區(qū)表
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
#分區(qū)表已經變成 GPT
Number Start End Size File system Name 標志
#所有的分區(qū)都消失了
注意,一定要把 /etc/fstab 文件和原有分區(qū)中的內容刪除才能重啟,否則會報錯。
(parted)mkpart
#輸入創(chuàng)建分區(qū)命令,后面不要參數(shù),全部靠交互
指定
分區(qū)名稱? []?disk1
#分區(qū)名稱,這里命名為disk 1
文件系統(tǒng)系統(tǒng)? [ext2]?
#文件系統(tǒng)類型,直接回車,使用默認文件系統(tǒng)ext2
起始點? 1MB
#分區(qū)從1MB開始
結束點?5GB分區(qū)到5GB結束
#分區(qū)完成
(parted) print
#查看一下
Model: VMware, VMware Virtual S (scsi)
Disk/dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B Partition Table: gpt
Number Start End Size Rle system Name 標志
1 1049kB 5000MB 4999MB disk1
#分區(qū)1已經出現(xiàn)
(parted) mkfs
#格式化命令(很奇怪,也是mkfs,但是這只是parted的交互命令)
WARNING: you are attempting to use parted to operate on (mkfs) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
警告:The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue?
是/Yes/否/No? yes
#警告你格式化丟失,沒關系,已經丟失過了
分區(qū)編號? 1
文件系統(tǒng)類型 [ext2]?
#指定文件系統(tǒng)類型,寫別的也沒用,直接回車
(parted) print #格式化完成,查看一下
Model: VMware, VMware Virtual S (scsi)
Disk/dev/sdb: 21,5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name標志
1 1049kB 5000MB 4999MB ext2 diski
#擁有了文件系統(tǒng)
(parted) resize
分區(qū)編號? 1
#指定要修改的分區(qū)編號
起始點? [1049kB]? 1MB
#分區(qū)起始位置
結束點? [5000MB]? 6GB
分區(qū)結束位置
(parted) print
#查看一下
Model: VMware, VMware Virtual S (scsi)
Disk/dev/sdb: 21,5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name標志
1 1049kB 6000MB 5999MB ext2 diski
#分區(qū)大小改變
命令如下:
(parted) rm
#刪除分區(qū)命令
分區(qū)編號? 1
#指定分區(qū)編號
(parted) print
#查看一下
Model: VMware, VMware Virtual S (scsi)
Disk/dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name 標志 #分區(qū)消失
新聞熱點
疑難解答
圖片精選