Show Table of Contents
Chapter 13. Partitions
For an overview of the advantages and disadvantages to using partitions on block devices, see the following KBase article: https://access.redhat.com/solutions/163853.
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 following command:
Replace /dev/sda with 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.
It is possible to create a new partition on a device that is in use, but this is 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 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:
- 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
umountcommand and turn off all the swap space on the hard drive with the
To see commonly used parted commands, see Table 13.1, “
Do not use the parted utility to create file systems. Use the mkfs tool instead.
| ||Display list of available commands|
| ||Create a disk label for the partition table|
| ||Make a partition without creating a new file system|
| ||Name the partition for Mac and PC98 disklabels only|
| ||Display the partition table|
| ||Quit parted|
| ||Rescue a lost partition from start-mb to end-mb|
| ||Remove the partition|
| ||Select a different device to configure|
| ||Set the flag on a partition; state is either on or off|
| ||Toggle the state of FLAG on partition NUMBER|
| ||Set the default unit to UNIT|
13.1. Viewing the Partition Table
To view the partition table:
- Start parted.
- Use the following 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
Following is the description of the partition table:
- Model: ATA ST3160812AS (scsi): explains the disk type, manufacturer, model number, and interface.
- Disk /dev/sda: 160GB: displays the file path to the block device and the storage capacity.
- Partition Table: msdos: displays the disk label type.
- In the partition table,
Numberis the partition number. For example, the partition with minor number 1 corresponds to
Endvalues are in megabytes. Valid
Typesare metadata, free, primary, extended, or logical. The
File systemis the file system type. The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba.
File systemin the partition table can be any of the following:
File systemof a device shows no value, this means that its file system type is unknown.