Chapter 13. Partitions
partedallows users to:
- View the existing partition table
- Change the size of existing partitions
- Add partitions from free space or additional hard drives
By default, the
partedpackage is included when installing Red Hat Enterprise Linux. To start
parted, log in as root and type the command
parted /dev/sdaat a shell prompt (where
/dev/sdais the device name for the drive you want to configure).
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 which is in use—while possible—is not recommended.
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
umountcommand and turn off all the swap space on the hard drive with the
Table 13.1, “
partedcommands” contains a list of commonly used
partedcommands. The sections that follow explain some of these commands and arguments in more detail.
| ||Perform a simple check of the file system|
| ||Copy file system from one partition to another; from and to are the minor numbers of the partitions|
| ||Display list of available commands|
| ||Create a disk label for the partition table|
| ||Create a file system of type file-system-type|
| ||Make a partition without creating a new file system|
| ||Make a partition and create the specified file system|
| ||Move the partition|
| ||Name the partition for Mac and PC98 disklabels only|
| ||Display the partition table|
| || Quit |
| ||Rescue a lost partition from start-mb to end-mb|
| ||Resize the 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
parted, use the command
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
Endvalues are in megabytes. Valid
Typeare metadata, free, primary, extended, or logical. The
Filesystemis the file system type, which can be any of the following:
Filesystemof 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.