Linux下分区命令parted使用要点
主要是如何查看,创建分区表,创建删除分区
1 显示当前分区表
$ sudo parted /dev/sda
GNU Parted 3.3
使用 /dev/sda
欢迎使用 GNU Parted!输入 'help' 来查看命令列表。
(parted)
(parted) print
型号:Seagate USB 3.0 Cable (scsi)
磁盘 /dev/sda: 1000GB
扇区大小 (逻辑/物理):512B/512B
分区表:gpt
磁盘标志:
编号 起始点 结束点 大小 文件系统 名称 标志
1 10.5MB 1000GB 1000GB ext4 SEAGATE-1t
(parted)
(parted) quit
2 创建磁盘分区表
mklabel 【label-type】
Create a new disklabel (partition table) of label-type. label-type should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos",
"pc98", or "sun".
即:创建指定类型的磁盘(分区表)标签,如:""gpt", msdos", "mac", "loop", "aix", "amiga", "bsd", "dvh", "pc98", "sun"
都这年代了,选gpt吧,这样才能拥抱新科技
3 创建分区
mkpart [【part-type】 【name】 【fs-type】] 【start】 【end】
Create a new partition. part-type may be specified only with msdos and dvh partition tables, it should be one of "primary", "logical", or "extended". name is required for GPT partition tables and fs-type is optional. fs-type can be one of "btrfs", "ext2", "ext3", "ext4", "fat16","fat32", "hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", "udf", or "xfs".
即:创建分区。
如果磁盘分区表为‘msdos’或‘dvh’时,【part-type】才需要指定("primary"、"logical"、"extended");
如果磁盘分区表为‘GPT’时,必须指定【name】;
【fs-type】是可选项,可以是以下之一:"btrfs", "xfs", "ext2", "ext3", "ext4", "fat16","fat32", "ntfs", "hfs", "hfs+", "linux-swap", "reiserfs", "udf"
【start】 :一般不从 0 开始,比如从 1 开始(1代表1MB)
【end】:可以是指定位置:80G,也可以是百分数:80%,结束点减去开始点就等于磁盘分区的大小
4 分区命名(一般用不上啦)
name 【partition】 【name】
Set the name of partition to name. This option works only on Mac, PC98, and GPT disklabels. The name can be placed in double quotes, if necessary.
And depending on the shell may need to also be wrapped in single quotes so that the shell doesn't strip off the double quotes.
即:设置分区名称,这个选项仅对磁盘分区表为Mac、PC98、GPT有效,如有必要,名称可以用双引号引起来,根据shell的不同,可能还需要用单引号括起来,这样shell就不会去掉双引号。
5 删除分区
rm 分区编号
6 最后
爱你