Parted partitioning tool to use

A, parted and uses described

  • Summarized for use:

parted for disks (RAID or disk) and partition management, compared with fdisk partition tool, support more than 2TB disk partitions and allows to adjust the size of the partition.
 
  • GNU manual describes:

a hard disk or partition is parted partition resizing tool. You can use it to create, remove, adjust, move and copy ext2, ext3, linux-swap, FAT, FAT32 and reiserfs partition; can also create, adjust, and move Apple HFS partition systems; can detect jfs, ntfs, ufs and xfs partition. The tool is used to create space for the new operating system installed, reallocate disk usage, and are often used when copying data to new hard disk.
 

Two, parted using the methods and procedures

1, to partition the disk
(1) command line
# parted /dev/sdb mklabel gpt mkpart 1 ext3 1 5T
 
(2) interactive command mode
command
Explanation
# parted /dev/sdb
On / dev / sdb or partition management operations

GNU   Parted 1.8.1

Use of / dev / sdb

Welcome   to GNU Parted! Type 'help' to view a list of commands.

The system returns value

(parted)    mklabel   gpt

The definition of partition table format
(Gpt and commonly used msdos partition table format, 2TB Above msdos disk is not supported, the selected disk is larger than 2TB partition table format gpt)

(parted)    mkpart   p1

Create the first partition named p1
(P1 only the first partition name, other names can also be used, such as part1)
File system type?  [ext2]?  ext3
The definition of partition format
(Ext4 not supported, like the sub-partition ext4 format, by format mkfs.ext4 formatted ext4)
Start?  1
Definition of the starting position of the partition
(Support Unit K, M, G, T)
End?   5T
Define the termination of the partition
(Support Unit K, M, G, T)
(parted)    print
View the current regional situation

Model:   ATA VBOX HARDDISK (scsi)

Disk   /dev/sda: 21.5GB

Sector   size (logical/physical): 512B/512B

Partition   Table: msdos

 

Number  Start     End   Size  File system  Name  Flags

1        32.3kB  5TB   5TB      ext3       p1      

The system returns value
 
2, delete the partition
command
Explanation
# parted /dev/sdb
On / dev / sdb or partition management operations
(parted)    rm
rm command to delete
(Must ensure that the partition is not mounted before deleting)
Partition number? 1
Delete the first partition
(parted)    print
View the current regional situation

Model:   ATA VBOX HARDDISK (scsi)

Disk   /dev/sda: 21.5GB

Sector   size (logical/physical): 512B/512B

Partition   Table: msdos

 

Number  Start     End   Size  File system  Name  Flags

The system returns value
 
3, indicating that several TB formatted disk

In a few TB of disk format, the time will be very long, formatted disk 6T time in about a half hour. (Hard disk, according to the actual situation may be)

 

 

 

Three, partd partitioned instance

fdisk工具虽然很好用,但对于大于2T以上的硬盘分区特别慢,可能一部分容量识别不了,也不支持非交互模式。
用parted就非常方便了,对大硬盘支持很好,也可以实现脚本分区。

默认一般都安装过了,没有的话install it!

yum install parted

parted有个不提示用户参数选项,就是通过这个选项来实现非交互

       -s, --script
              never prompts for user intervention

下面我们通过一个一块硬盘来说明它的具体操作:

第一个主分区3G
剩余分区都给扩展分区
第一个逻辑卷分区2G
第二个逻辑源用剩余空间

 

第一个主分区3G

parted -s /dev/sdb mklabel msdos
parted -s /dev/sdb mkpart primary 0 3G

剩余空间给扩展分区

parted -s /dev/sdb mkpart entended 3 100%

在扩展分区上创建第一个逻辑分区

parted -s /dev/sdb mkpart logic 3G 5G

创建第二个逻辑分区

parted -s /dev/sdb mkpart logic 5G 100%            #100%代表使用剩余的所有空间

查看分区大小

parted -s /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  标志
 1      512B    3000MB  3000MB  primary
 2      3001MB  8590MB  5589MB  extended               lba
 5      5000MB  8590MB  3590MB  logical

删除分区

parted -s /dev/sdb rm 5          #rm后面跟的事分区的编号,print出的Number
parted -s /dev/sdb print
Number  Start   End     Size    Type      File system  标志
 1      512B    3000MB  3000MB  primary
 2      3001MB  8590MB  5589MB  extended               lba

对/dev/sdc分一个主分区,类型为swap

parted -s /dev/sdc mklabel msdos
parted -s /dev/sdc -- mkpartfs primary linux-swap 0 -1         #从使用所有空间

 

Guess you like

Origin www.cnblogs.com/klb561/p/11329252.html