parted 命令
2016-08-05 by dongnan
举个栗子
使用 centos 7
新版本 parted
命令更改磁盘分区的类型。
# 输入命令
parted /dev/xvda
# parted版本
(parted) version
GNU Parted 3.1
Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
#...省略
更改分区类型
子命令 t
用于更改分区类型
(parted) t
Partition number? 5 # 选择第5个分区
Flag to Invert? lvm # 类型为LVM
验证分区类型
Xen Virtual Block Device
表明是xenserver
虚拟机磁盘。
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary xfs boot
2 525MB 10.7GB 10.2GB primary lvm
3 10.7GB 53.7GB 42.9GB extended lba
5 10.7GB 53.7GB 42.9GB logical lvm
可以看到,第5个分区的类型为 lvm
标志。
帮助
在 parted
命令界面中输入 help
。
(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 t
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
NUMBER is the partition number used by Linux. On MS-DOS disk labels,
the primary partitions number from 1 to 4, logical partitions from 5 onwards.
FLAG is one of:
boot, root, swap, hidden, raid, lvm, lba, hp-service, palo, prep, msftres, bios_grub, atvrecv, diag, legacy_boot