Common command Accumulation

Source: Internet
Author: User

20141016

Partition the disk with parted

Fdisk cannot be used to manage disks larger than 2 TB. You need to use parted for partitioning.

For GPT disks, fdisk-l does not display disk partition information.

[[Email protected]/] # fdisk-l

Warning: GPT (guid Partition Table) detected on '/dev/sda '! The util fdisk doesn' t support GPT. Use GNU parted.

Disk/dev/SDA: 11999.1 GB, 11999064883200 bytes

255 heads, 63 sectors/track, 1458803 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes

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

I/O size (minimum/optimal): 512 bytes/512 bytes

Disk identifier: 0x00000000

Device boot start end blocks ID system

/Dev/sda1 1 267350 2147483647 + EE GPT

You can use parted to view detailed partition information.

[[Email protected]/] # parted/dev/SDA

GNU parted2.1

Using/dev/SDA

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

(Parted) P

Model: Dell Perc release 10 (SCSI)

Disk/dev/SDA: 12.0 TB

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

Partition Table: GPT


Number start end size file system name flags

1 1049kb 211 MB 210 MB ext4 boot

2 211 MB 108 GB 107 GB ext4

3 108 GB 142 GB 34.4 GB Linux-swap (V1)


Use parted to partition a large disk. Next we will create a 5 TB disk.

[[Email protected]/] # parted/dev/SDA

(Parted) mkpart

Partition name? []? Backup <-- partition name

File System type? [Ext2]? Ext4 <-- partition format

Start? 142 GB <-- starting position

End? 5262 GB <-- end position

Warning: warning: the kernel failed to re-read the partition table on/dev/SDA (device or resource busy ). as a result, it may not reflect all of your changes until after reboot.

(Parted) P

Model: Dell Perc release 10 (SCSI)

Disk/dev/SDA: 12.0 TB

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

Partition Table: GPT


Number start end size file system name flags

1 1049kb 211 MB 210 MB ext4 boot

2 211 MB 108 GB 107 GB ext4

3 108 GB 142 GB 34.4 GB Linux-swap (V1)

4 142 GB 5262 GB 5120 GB backup

(Parted) q


After partitioning, the system needs to identify the changes to the disk partition table.

Traditional partprobe commands are not very useful. The system will prompt that the disk is in use and the partition table cannot be reloaded.

[[Email protected]/] # partprobe

Warning: warning: the kernel failed to re-read the partition table on/dev/SDA (device or resource busy ). as a result, it may not reflect all of your changes until after reboot.

At this time, the system cannot detect the sda4 partition.

[[Email protected]/] # ls/dev/SDA *

SDA sda1 sda2 sda3

In this case, you can use the partx-a command to reload the partition table.

[[Email protected]/] # partx-A/dev/SDA

Blkpg: device or resource busy

Error adding partition 1

Blkpg: device or resource busy

Error adding partition 2

Blkpg: device or resource busy

Error adding partition 3

View the new sda4 partition again.

[[Email protected]/] # ls/dev/SDA *

/Dev/SDA/dev/sda1/dev/sda2/dev/sda3/dev/sda4

After partitioning, you also need to format the disk.

[[Email protected]/] # mkfs. ext4/dev/sda4


To delete a partition, you can use RM number to delete the specified partition.

[[Email protected]/] # parted

GNU parted2.1

Using/dev/SDA

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

(Parted) P

Model: Dell Perc release 10 (SCSI)

Disk/dev/SDA: 12.0 TB

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

Partition Table: GPT


Number start end size file system name flags

1 1049kb 211 MB 210 MB ext4 boot

2 211 MB 108 GB 107 GB ext4

3 108 GB 142 GB 34.4 GB Linux-swap (V1)

4 142 GB 5142 GB 5000 GB ext4 primary


(Parted) Rm 4

Warning: warning: the kernel failed to re-read the partition table on/dev/SDA (device or resource busy ). as a result, it may not reflect all of your changes until after reboot.

(Parted) P

Model: Dell Perc release 10 (SCSI)

Disk/dev/SDA: 12.0 TB

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

Partition Table: GPT


Number start end size file system name flags

1 1049kb 211 MB 210 MB ext4 boot

2 211 MB 108 GB 107 GB ext4

3 108 GB 142 GB 34.4 GB Linux-swap (V1)


(Parted) quit

Information: you may need to update/etc/fstab.

After deletion, you need to update the partition table so that the system knows that the partition has been deleted.

[[Email protected]/] # partx-d -- nr 4/dev/SDA

[[Email protected]/] # ls/dev/SDA *

/Dev/SDA/dev/sda1/dev/sda2/dev/sda3


This article from the "kid unknown" blog, please be sure to keep this source http://linuxroad.blog.51cto.com/765922/1565191

Common command Accumulation

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.