Chapter 6. Managing Disk Storage

The utility parted allows users to:

  • View the existing partition table

  • Change the size of existing partitions

  • Add partitions from free space or additional hard drives

If you want to view the system's disk space usage or monitor the disk space usage, refer to Section 37.3, “File Systems”.

By default, the parted package is included when installing Red Hat Enterprise Linux. To start parted, log in as root and type the command parted /dev/sda at a shell prompt (where /dev/sda is the device name for the drive you want to configure).

A device containing a partition must not be in use if said partition is to be removed or resized. Similarly, when creating a new partition on a device, said device must not be in use.

For a device to not be in use, none of the partitions on the device can be mounted, and any swap space on the device must not be enabled.

As well, the partition table should not be modified while it is in use because the kernel may not properly recognize the changes. If the partition table does not match the actual state of the mounted partitions, information could be written to the wrong partition, resulting in lost and overwritten data.

The easiest way to achieve this it to boot your system in rescue mode. When prompted to mount the file system, select Skip.

Alternately, if the drive does not contain any partitions in use (system processes that use or lock the file system from being unmounted), you can unmount them with the umount command and turn off all the swap space on the hard drive with the swapoff command.

Table 6.1, “parted commands” contains a list of commonly used parted commands. The sections that follow explain some of these commands and arguments in more detail.

After starting parted, use the command print to view the partition table. A table similar to the following appears:

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 /dev/sda1. The Start and 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:

  • ext2

  • ext3

  • fat16

  • fat32

  • hfs

  • jfs

  • linux-swap

  • ntfs

  • reiserfs

  • hp-ufs

  • sun-ufs

  • xfs

If a 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.

Warning

Do not attempt to create a partition on a device that is in use.

Before creating a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).

Start parted, where /dev/sda is the device on which to create the partition:

parted /dev/sda

View the current partition table to determine if there is enough free space:

print

If there is not enough free space, you can resize an existing partition. Refer to Section 6.1.4, “Resizing a Partition” for details.