使用parted創建分區

今天在網上查找分區方法,發現都是用的fdisk,但自己使用總是出錯,後來請求大神幫忙,發現了一個好用的工具,這裏把具體的使用過程記錄下來。

[root@pc160 ~]# parted /dev/sda
GNU Parted 3.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
錯誤: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
確認/OK/放棄/Cancel? ok                                                   
警告: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 1828479744 blocks) or continue with the current setting? 
修正/Fix/忽略/Ignore? fix                                                 
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  標誌
 1      1049kB  211MB   210MB   fat16        EFI System Partition  啓動
 2      211MB   735MB   524MB   xfs
 3      735MB   64.0GB  63.3GB                                     lvm

(parted) p                                                                
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  標誌
 1      1049kB  211MB   210MB   fat16        EFI System Partition  啓動
 2      211MB   735MB   524MB   xfs
 3      735MB   64.0GB  63.3GB                                     lvm

(parted) n                                                                
分區編號? 4                                                              
錯誤: 分區不存在。
(parted) help                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) mkpart                                                           
分區名稱?  []?                                                           
文件系統類型?  [ext2]?                                                   
起始點?                                                                  
起始點?                                                                  
起始點?                                                                  
起始點? oo                                                               
錯誤: Invalid number.
(parted) free                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print free                                                       
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  標誌
        17.4kB  1049kB  1031kB  Free Space
 1      1049kB  211MB   210MB   fat16        EFI System Partition  啓動
 2      211MB   735MB   524MB   xfs
 3      735MB   64.0GB  63.3GB                                     lvm
        64.0GB  1000GB  936GB   Free Space

(parted) mkpart                                                   
分區名稱?  []?                                                           
文件系統類型?  [ext2]?                                                   
起始點? 64GB
結束點? 1000GB                                                           
(parted) p                                                                
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  標誌
 1      1049kB  211MB   210MB   fat16        EFI System Partition  啓動
 2      211MB   735MB   524MB   xfs
 3      735MB   64.0GB  63.3GB                                     lvm
 4      64.0GB  1000GB  936GB

(parted) help                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted)                                                                  
(parted) quit                                                             
信息: You may need to update /etc/fstab.

[root@pc160 ~]# part
parted     partprobe  partx      
[root@pc160 ~]# partprobe 
[root@pc160 ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

磁盤 /dev/sda:1000.2 GB, 1000204886016 字節,1953525168 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 4096 字節
I/O 大小(最小/最佳):4096 字節 / 4096 字節
磁盤標籤類型:gpt


#         Start          End    Size  Type            Name
 1         2048       411647    200M  EFI System      EFI System Partition
 2       411648      1435647    500M  Microsoft basic 
 3      1435648    125044735     59G  Linux LVM       
 4    125044736   1953523711  871.9G  Microsoft basic 

磁盤 /dev/mapper/rhel-root:38.2 GB, 38176555008 字節,74563584 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 4096 字節
I/O 大小(最小/最佳):4096 字節 / 4096 字節


磁盤 /dev/mapper/rhel-swap:6404 MB, 6404702208 字節,12509184 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 4096 字節
I/O 大小(最小/最佳):4096 字節 / 4096 字節


磁盤 /dev/mapper/rhel-home:18.6 GB, 18639486976 字節,36405248 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 4096 字節
I/O 大小(最小/最佳):4096 字節 / 4096 字節

[root@pc160 ~]# 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章