With the parted
utility, you can:
View the existing partition table.
Change the size of existing partitions.
Add partitions from free space or additional hard drives.
The parted package is installed by default on Red Hat Enterprise Linux 7. To start parted, log in as root and enter the
parted /dev/sda command at a shell prompt, where /dev/sda is the device name for the drive to configure.
Manipulating Partitions on Devices in Use
For a device to not be in use, none of the partitions on the device can be mounted, and no swap space on the device can be enabled.
If you want to remove or resize a partition, the device on which that partition resides must not be in use.
Creating a new partition on a device that is in use is possible, but not recommended.
Modifying the Partition Table
Modifying the partition table while another partition on the same disk is in use is generally not recommended because the kernel is not be able to reread the partition table. As a consequence, changes are not applied to a running system. In the described situation, reboot the system, or use the following command to make the system register new or modified partitions:
partx --update --nr partition-number disk
The easiest way to modify disks that are currently in use is to boot the system in rescue mode if the partitions on the disk are impossible to unmount, for example in the case of a system disk. When prompted to mount the file system, select
If the drive does not contain any partitions in use, that is there are no system processes that use or lock the file system from being unmounted, you can unmount the partitions with the
umount command and turn off all the swap space on the hard drive with the
Table 13.1, “
contains a list of commonly used parted
commands. The following sections explain some of these commands and arguments in more detail.
Do not use the parted utility to create file systems. Use the mkfs tool instead.
| Command || Description |
| Display list of available commands |
| Create a disk label for the partition table |
mkpart part-type [fs-type] start-mb end-mb
| Make a partition without creating a new file system |
name minor-num name
| Name the partition for Mac and PC98 disklabels only |
| Display the partition table |
| Quit parted |
rescue start-mb end-mb
| Rescue a lost partition from start-mb to end-mb |
| Remove the partition |
| Select a different device to configure |
set minor-num flag state
| Set the flag on a partition; state is either on or off |
toggle [NUMBER [FLAG]
| Toggle the state of FLAG on partition NUMBER |
| Set the default unit to UNIT |
13.1. Viewing the Partition Table
After starting parted, use the
print command to view the partition table. A table similar to the following one appears:
Example 13.1. Partition Table
Model: ATA ST3160812AS (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 107MB 107MB primary ext3 boot
2 107MB 105GB 105GB primary ext3
3 105GB 107GB 2147MB primary linux-swap
4 107GB 160GB 52.9GB extended root
5 107GB 133GB 26.2GB logical ext3
6 133GB 133GB 107MB logical ext3
7 133GB 160GB 26.6GB logical lvm
The first line contains the disk type, manufacturer, model number and interface, and the second line displays the disk label type. The remaining output below the fourth line shows the partition table.
In the partition table, the Minor number is the partition
number. For example, the partition with minor number 1 corresponds to
End values are in megabytes. Valid
Type are metadata, free, primary, extended, or logical. The
Filesystem is the file system type, which can be any of the following:
Filesystem of a device shows no value, this means that its file system type is unknown.
The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba.
To select a different device without having to restart
parted, use the
select command followed by the device name (for example,
/dev/sda). Doing so allows you to view or configure the partition table of a device.