6.1. Standard Partitions using parted
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 at a shell prompt (where /dev/sda is the device name for the drive you want to configure).
/dev/sda
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.
| Command | Description |
|---|---|
check
|
Perform a simple check of the file system |
cp
|
Copy file system from one partition to another; from and to are the minor numbers of the partitions
|
help
|
Display list of available commands |
mktable
|
Create a disk label for the partition table |
mkfs
|
Create a file system of type file-system-type
|
mkpart
|
Make a partition without creating a new file system |
mkpartfs
|
Make a partition and create the specified file system |
move
|
Move the partition |
name
|
Name the partition for Mac and PC98 disklabels only |
print
|
Display the partition table |
quit
|
Quit parted
|
rescuestart-mbend-mb
|
Rescue a lost partition from start-mb to end-mb
|
resize
|
Resize the partition from start-mb to end-mb
|
rm
|
Remove the partition |
select
|
Select a different device to configure |
set
|
Set the flag on a partition; state is either on or off
|
toggle [
|
Toggle the state of FLAG on partition NUMBER
|
unit
|
Set the default unit to UNIT
|
parted commands