parted

From WebHostingNeeds.com
Jump to: navigation, search

GNU Parted

GNU Parted manipulates partition tables. This is useful for creating space for new operating systems, reorganizing disk usage, copying data on hard disks and disk imaging. The package contains a library, libparted, as well as well as a command-line frontend, parted, which can also be used in scripts.

Installing parted on CentOS

yum install parted


List All Partition

parted -l

Same as fdisk -l

Print Partition Table

# parted /dev/sdb print
Model: ATA ST3000DM001-9YN1 (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name              Flags
 1      20.5kB  3001GB  3001GB  ext4         Linux filesystem

#


Print Free Space

# parted /dev/sdb print free
Model: ATA ST3000DM001-9YN1 (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name              Flags
        17.4kB  20.5kB  3072B   Free Space
 1      20.5kB  3001GB  3001GB  ext4         Linux filesystem

#


Create Partition Table

[[email protected] ~]# parted /dev/sdb print
Error: /dev/sdb: unrecognised disk label
[[email protected] ~]# parted /dev/sdb mktable gpt
Information: You may need to update /etc/fstab.

[[email protected] ~]# parted /dev/sdb print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

[[email protected] ~]#


Create Partition

[[email protected] ~]# parted /dev/sdb mkpart
Partition name?  []? boby
File system type?  [ext2]?
Start? 1MB
End? 1000MB
Information: You may need to update /etc/fstab.

[[email protected] ~]#


Format A Partition

[[email protected] ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
135728 inodes, 541952 blocks
27097 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=557842432
17 block groups
32768 blocks per group, 32768 fragments per group
7984 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[email protected] ~]#

Deleting A Partition

[[email protected] ~]# parted /dev/sdb rm 1
Information: You may need to update /etc/fstab.

[[email protected] ~]# parted /dev/sdb print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

[[email protected] ~]#




fdisk