Show Table of Contents
Chapter 13. Partitions
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 swapoff
command.
Table 13.1, “
parted
Commands” contains a list of commonly used parted commands. The following sections explain some of these commands and arguments in more detail.
Important
Do not use the parted utility to create file systems. Use the mkfs tool instead.
Table 13.1. parted
Commands
Command | Description |
---|---|
help | Display list of available commands |
mklabel label | 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 |
print | Display the partition table |
quit | Quit parted |
rescue start-mb end-mb | Rescue a lost partition from start-mb to end-mb |
rm minor-num | Remove the partition |
select device | 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 |
unit UNIT | 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 /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.
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.