8.4 parted:磁盘分区工具
生活随笔
收集整理的這篇文章主要介紹了
8.4 parted:磁盘分区工具
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
parted
對于小于2TB的磁盤可以用fdisk和parted命令進行分區,這種情況一般采用flisk命令,但對于大于2TB的磁盤則只能用parted分區,且需要將磁盤轉換為GPT格式。 parted [選項] [設備名] -l?? ?顯示所有磁盤分區的信息 -h?? ?查看幫助 [root@cs6 ~]# parted GNU Parted 2.1 使用 /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) h align-check TYPE N #<==檢查磁盤分區,TYPE分為min/opt兩個選擇,N為磁盤分區號。 check NUMBER #<==簡單檢查文件系統。 cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER #<==將文件系統復制到另一個分區。 help [COMMAND] #<=查看幫助,簡寫h,還可以類似于help check 查看其他指令幫助。 mklabel,mktable LABEL-TYPE #<==創建分區表* mkfs NUMBER FS-TYPE #<==創建文件系統。 mkpart PART-TYPE [FS-TYPE] START END #<==創建分區*。 mkpartfs PART-TYPE FS-TYPE START END #<==創建帶有文件系統的分區*。 move NUMBER START END #<==移動分區。 name NUMBER NAME #<==為分區命名 print [devices|free|list,all|NUMBER] #<==顯示分區表信息,簡寫p*。 partitions, or a particular partition quit #<==退出程序。 rescue START END #<==挽救臨近“起始點”、”終止點”的 失的分區。 resize NUMBER START END #<==重設分區大小。 rm NUMBER #<==刪除編號 NUMBER的分區*。 select DEVICE #<==選擇要編輯的設備。 set NUMBER FLAG STATE #<==改變分區的標志。 toggle [NUMBER [FLAG]] #<==設置分區標志。 unit UNIT #<==設置默認單位。 version #<==顯示版本號。 (parted)顯示分區情況的例子
[root@cs6 ~]# parted -l #<==顯示所有磁盤分區的信息。 Model: VMware, VMware Virtual S (scsi) #<=磁盤型號,這里采用VMware虛擬化演示。 Disk /dev/sda: 32.2GB #<==磁盤大小。 Sector size (logical/physical): 512B/512B #<==扇區大小,為msdos,這是適合disk分區的類型。Partition Table: msdos #<==分區表類型。 Number Start End Size Type File system 標志 1 1049kB 525MB 524MB primary ext4 啟動 2 525MB 32.2GB 31.7GB primary lvm Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system 標志 1 32.3kB 115MB 115MB primary ext4 2 115MB 1069MB 954MB extended 5 115MB 543MB 428MB logical 6 543MB 1069MB 526MB logical 上述內容每列說明具體如下: Number:分區編號。 Start:分區開始位置。 End:分區結束位置。 Size:分區大小。 Type:分區類型。 primary:為主分區。 File system:文件系統,例如ext4、swap等。 Flags:標志位,boot為啟動分區。在虛擬機(VMware Workstation Pro)中模擬2TB以上的磁盤分區
步驟1:在虛擬機中添加一塊1GB的硬盤,如圖8-2所示。 步驟2:交互式分區。 [root@cs6 ~]# parted /dev/sdb GNU Parted 2.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt Warning: Partition(s) on /dev/sdb are being used. Ignore/Cancel? Ignore 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 Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. (parted) mkpart primary 0 500 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 500MB 500MB primary (parted) mkpart logical 501 1000 Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 500MB 500MB primary 2 501MB 1000MB 499MB logical #<-第一個邏輯分區已創建完畢。 (parted) quit [root@cs6 ~]# ls /dev/sdb* #<==查看己分的分區,parted分區是即時生效的,沒有保存的步驟。 /dev/sdb /dev/sdb1 /dev/sdb2 后續格式化分區、分區掛載、開機自動掛載等步驟和fdisk分區實踐的范例8-2完全相同,讀者可前往參考。非交互式分區(批量分區)案例
步驟1:先刪除前面分的區。 [root@cs6 ~]# parted /dev/sdb GNU Parted 2.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 500MB 500MB primary 2 501MB 1000MB 499MB logical (parted) rm 1 (parted) rm 2 (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags (parted) quit Information: You may need to update /etc/fstab. [root@cs6 ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb 步驟2:非交互創建分區命令。 [root@cs6 ~]# parted /dev/sdb mklabel gpt Yes #<=非交互創建分區的實質上就是將在交互窗口執行的命令作為參數。 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? Information: You may need to update /etc/fstab. [root@cs6 ~]# parted /dev/sdb mkpart primary 0 500 Warning: The resulting partition is not properly aligned for best performance. Information: You may need to update /etc/fstab. [root@cs6 ~]# parted /dev/sdb mkpart primary 500 1000 Information: You may need to update /etc/fstab. [root@cs6 ~]# parted /dev/sdb p #<==查看分區結果。 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 500MB 500MB primary 2 500MB 1000MB 500MB primary總結
以上是生活随笔為你收集整理的8.4 parted:磁盘分区工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 9.1 ps:查看进程
- 下一篇: 8.2-3 partprobe、tune