8.4 parted:磁盘分区工具
生活随笔
收集整理的這篇文章主要介紹了
8.4 parted:磁盘分区工具
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
parted
對(duì)于小于2TB的磁盤可以用fdisk和parted命令進(jìn)行分區(qū),這種情況一般采用flisk命令,但對(duì)于大于2TB的磁盤則只能用parted分區(qū),且需要將磁盤轉(zhuǎn)換為GPT格式。 parted [選項(xiàng)] [設(shè)備名] -l?? ?顯示所有磁盤分區(qū)的信息 -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 #<==檢查磁盤分區(qū),TYPE分為min/opt兩個(gè)選擇,N為磁盤分區(qū)號(hào)。 check NUMBER #<==簡(jiǎn)單檢查文件系統(tǒng)。 cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER #<==將文件系統(tǒng)復(fù)制到另一個(gè)分區(qū)。 help [COMMAND] #<=查看幫助,簡(jiǎn)寫h,還可以類似于help check 查看其他指令幫助。 mklabel,mktable LABEL-TYPE #<==創(chuàng)建分區(qū)表* mkfs NUMBER FS-TYPE #<==創(chuàng)建文件系統(tǒng)。 mkpart PART-TYPE [FS-TYPE] START END #<==創(chuàng)建分區(qū)*。 mkpartfs PART-TYPE FS-TYPE START END #<==創(chuàng)建帶有文件系統(tǒng)的分區(qū)*。 move NUMBER START END #<==移動(dòng)分區(qū)。 name NUMBER NAME #<==為分區(qū)命名 print [devices|free|list,all|NUMBER] #<==顯示分區(qū)表信息,簡(jiǎn)寫p*。 partitions, or a particular partition quit #<==退出程序。 rescue START END #<==挽救臨近“起始點(diǎn)”、”終止點(diǎn)”的 失的分區(qū)。 resize NUMBER START END #<==重設(shè)分區(qū)大小。 rm NUMBER #<==刪除編號(hào) NUMBER的分區(qū)*。 select DEVICE #<==選擇要編輯的設(shè)備。 set NUMBER FLAG STATE #<==改變分區(qū)的標(biāo)志。 toggle [NUMBER [FLAG]] #<==設(shè)置分區(qū)標(biāo)志。 unit UNIT #<==設(shè)置默認(rèn)單位。 version #<==顯示版本號(hào)。 (parted)顯示分區(qū)情況的例子
[root@cs6 ~]# parted -l #<==顯示所有磁盤分區(qū)的信息。 Model: VMware, VMware Virtual S (scsi) #<=磁盤型號(hào),這里采用VMware虛擬化演示。 Disk /dev/sda: 32.2GB #<==磁盤大小。 Sector size (logical/physical): 512B/512B #<==扇區(qū)大小,為msdos,這是適合disk分區(qū)的類型。Partition Table: msdos #<==分區(qū)表類型。 Number Start End Size Type File system 標(biāo)志 1 1049kB 525MB 524MB primary ext4 啟動(dòng) 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 標(biāo)志 1 32.3kB 115MB 115MB primary ext4 2 115MB 1069MB 954MB extended 5 115MB 543MB 428MB logical 6 543MB 1069MB 526MB logical 上述內(nèi)容每列說明具體如下: Number:分區(qū)編號(hào)。 Start:分區(qū)開始位置。 End:分區(qū)結(jié)束位置。 Size:分區(qū)大小。 Type:分區(qū)類型。 primary:為主分區(qū)。 File system:文件系統(tǒng),例如ext4、swap等。 Flags:標(biāo)志位,boot為啟動(dòng)分區(qū)。在虛擬機(jī)(VMware Workstation Pro)中模擬2TB以上的磁盤分區(qū)
步驟1:在虛擬機(jī)中添加一塊1GB的硬盤,如圖8-2所示。 步驟2:交互式分區(qū)。 [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 #<-第一個(gè)邏輯分區(qū)已創(chuàng)建完畢。 (parted) quit [root@cs6 ~]# ls /dev/sdb* #<==查看己分的分區(qū),parted分區(qū)是即時(shí)生效的,沒有保存的步驟。 /dev/sdb /dev/sdb1 /dev/sdb2 后續(xù)格式化分區(qū)、分區(qū)掛載、開機(jī)自動(dòng)掛載等步驟和fdisk分區(qū)實(shí)踐的范例8-2完全相同,讀者可前往參考。非交互式分區(qū)(批量分區(qū))案例
步驟1:先刪除前面分的區(qū)。 [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:非交互創(chuàng)建分區(qū)命令。 [root@cs6 ~]# parted /dev/sdb mklabel gpt Yes #<=非交互創(chuàng)建分區(qū)的實(shí)質(zhì)上就是將在交互窗口執(zhí)行的命令作為參數(shù)。 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 #<==查看分區(qū)結(jié)果。 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總結(jié)
以上是生活随笔為你收集整理的8.4 parted:磁盘分区工具的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 9.1 ps:查看进程
- 下一篇: 8.2-3 partprobe、tune