Linux磁盘分区和逻辑卷详解(7)

  从中可看出与上面 fdisk -l 命令返回的差不多的信息。总共有4个设备:/dev/sda和/dev/sdb为物理设备,/dev/mapper/cl-swap和/dev/mapper/cl-root为逻辑卷创建的设备。可以看到/dev/sdb还没有分区,并且还看到上面有一个错误信息 错误: /dev/sdb: unrecognised disk label 。这是由于该磁盘设备没有设置上标签(label)所以会有错误,只需要设置了标签就可以了。

  这里我们使用 parted /dev/sdb 命令开始分区:

[root@localnat201 ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

  输入help选项,查看帮助信息:

[root@localnat201 ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(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)

  也可以在"help"选项后面加上具体的命令,可以查看具体命令的帮助信息;接下来使用 mklabel gpt 或者 mktable gpt 命令格式化分区类型和设置标签:

[root@localnat201 ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(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) mklabel gpt                                                     
(parted)

  此处可选择modos(mbr)和gpt类型,如果修改的分区标签类型,则分区所有数据将会丢失;接下来可输入 print 选项,打印分区信息:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12795.html