Linux under partition command parted detailed

Source: Internet
Author: User

Partitioning tools are commonly used to divide the Fdisk command, but now the disk is getting cheaper, and disk space is getting bigger. The Fdisk tool has a size limit on partitions, which can only partition disks that are less than 2T. Now the disk space is far more than 2T, there are two ways to solve this problem: one is implemented through volume management, and the other is through the parted tool to achieve partition of the 2T disk operation.

The GPT format disk is equivalent to the original MBR disk in the original reserved 4 partition table 4*16 bytes, leaving only the first 16 bytes, similar to the extended partition, the real partition table after 512 bytes, GPT Partitioning method does not have four primary partition limit , up to 128 primary partitions can be reached.


Usage: parted [options] ... [Device [command [parameters] ...] ...]
Apply the command with "parameters" to "Device". If the command is not given, it runs in interactive mode.


Help options:
-H,--help displays this help message
-L,--list lists all of the set partition information
-I,--interactive prompts the user when necessary
-S,--script never prompt the user
-V,--version display version


Operation Command:
Check MINOR #对文件系统进行一个简单的检查
CP [From-device] From-minor To-minor #将文件系统复制到另一个分区
Help [command] #打印通用求助信息, or information about the command
Mklabel label type #创建新的磁盘标签 (partition table)
MKFS MINOR File System type #在 MINOR Create a file system of type "file system type"
Mkpart partition Type [file system type] Start point termination point #创建一个分区
MKPARTFS partition type file system type start point termination point #创建一个带有文件系统的分区
Move MINOR start point end point #移动编号为 MINOR partition
Name MINOR name #将编号为 MINOR partition named "Names"
Print [MINOR] #打印分区表, or partition
Quit #退出程序
Rescue the missing partition of the start point #挽救临近 start point, end point
Resize MINOR start point end point #改变位于编号为 the size of the file system in the MINOR partition
RM MINOR #删除编号为 MINOR Partition
Select Device #选择要编辑的设备
Flag for SET MINOR flag State #改变编号为 MINOR partition


1, parted tools detailed:
1.1 How to enter parted (enter the parted command at the command line)
[Email protected] ~]# parted
GNU Parted 2.1 #Parted的软件版本号
Using/DEV/SDA
Welcome to GNU parted! Type ' help ' to view a list of commands. #欢迎信息
(parted) Select/dev/sdb
Using/dev/sdb
(parted)

Like Fdisk, first select the hard disk to partition, here is/DEV/SDB:
[Email protected] ~]# Parted/dev/sdb
GNU Parted 2.1
Using/dev/sdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted)


1.2 How to get the parted tool Help: (Just enter the helper)
[Email protected] ~]# parted
(parted) Help

[Email protected] ~]# parted--help


1.3 Exit the Parted tool (just enter quit)
[Email protected] ~]# parted
(parted) quit


2. Start operating the disk with the parted tool
2.1 Viewing individual disk status

[Email protected] ~]# Parted/dev/sdb
(parted) P #查看磁盘分区状态
Error:/dev/sdb:unrecognised disk label #由于没有打上磁盘标签, so the performance information cannot be listed

(parted) Mklabel #创建磁盘标签
What is the new disk label type? GPT #输入磁盘标签类型 GPT Msods (MBR)
(parted) P #再次查看磁盘分区状态
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:107gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flag


2.2 View all disk status
[Email protected] ~]# parted-l/dev/sdb


2.3 Creating partitions with the parted tool
(parted) Mkpart #创建分区
Partition name? []? Data1 #分区名称
File system type? [Ext2]? Ext4 #文件系统类型
Starting point? 1 #指定起始位置
End point? 10G #指定结束位置
(parted) P #查看磁盘分区状态
Model:vmware, VMware Virtual S (SCSI) #显示磁盘类型为SCSI
DISK/DEV/SDB:107GB #磁盘大小
Sector size (logical/physical): 512b/512b #扇区大小
Partition table:gpt #分区类型为GPT

Number Start End Size File system Name Flag
1 1049kB 10.0GB 9999MB data1

(parted) Q #退出
Info: Need to Update/etc/fstab.

2.4 Single-disk multi-partition with parted tool
(parted) Mkpart
Partition name? []? Data2
File system type? [Ext2]? Ext4
Starting point? 10G
End point? 20G
(parted) Mkpart
Partition name? []? Data3
File system type? [Ext2]? Ext4
Starting point? 20G
End point? 30G
(parted) P #查看到下面共有三个分区
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:107gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flag
1 1049kB 10.0GB 9999MB data1
2 10.0GB 20.0GB 9999MB data2
3 20.0GB 30.0GB 10.0GB data3


2.5 Deleting a partition with the parted tool
(parted) RM 3 #删除分区3
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:107gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flag
1 1049kB 10.0GB 9999MB data1
2 10.0GB 20.0GB 9999MB data2

[Email protected] ~]# ls-l/dev/sdb*
BRW-RW----1 root disk 8, 16 March 14:54/dev/sdb
BRW-RW----1 root disk 8, 17 March 14:54/DEV/SDB1
BRW-RW----1 root disk 8, 18 March 14:54/DEV/SDB2


2.6 Creating a file system by using the parted tool to format partitions
(parted) Mkfs 1 ext2 #格式化的类型为ext2分区号为1
Is/yes/no/no? Y #再次确认是否格式化
Partition number? 1 #输入分区号
File system type? [Ext2]? #输入文件系统类型 (ext[34] and other types using the MKFS command)
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:107gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flag
1 1049kB 10.0GB 9999MB ext2 data1

Comments:
[Email protected] ~]# MKFS.EXT4/DEV/SDB1


Mount the file system you just formatted
[Email protected] ~]# mkdir/data1
[Email protected] ~]# mount/dev/sdb1/data1
[email protected] ~]# Mount | Tail-1
/DEV/SDB1 on/data1 type ext2 (rw)
[[email protected] ~]# mkdir/data1/dir{1..10}
[Email protected] ~]# ls/data1/
Dir1 dir10 dir2 dir3 dir4 dir5 dir6 dir7 dir8 dir9 lost+found


2.7 Deleting and recovering partitions
[Email protected] ~]# UMOUNT/DEV/SDB1
[Email protected] ~]# Parted/dev/sdb
GNU Parted 2.1
Using/dev/sdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted) RM 1
(parted) Rescue #恢复分区
Starting point? 1
End point? 10G
Info: A ext2 Primary partition is found at 1049kB-10.0GB. Want to add it
To the partition table?
is/yes//no/give up/cancel? Yes
(parted) quit
Info: Need to Update/etc/fstab.

[Email protected] ~]# mount/dev/sdb1/data1
[Email protected] ~]# ls/data1/
Dir1 dir10 dir2 dir3 dir4 dir5 dir6 dir7 dir8 dir9 lost+found


2.8 Validate and maintain file systems and partitions with parted tools
[Email protected] ~]# Parted/dev/sdb
GNU Parted 2.1
Using/dev/sdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted) Check 1 #验证文件系统的完整性

Linux under partition command parted detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.