12.1. Standard Partitions using parted
Many users need to view the existing partition table, change the size of the partitions, remove partitions, or add partitions from free space or additional hard drives. The utility parted allows users to perform these tasks. This chapter discusses how to use parted to perform file system tasks.
If you want to view the system's disk space usage or monitor the disk space usage, refer to Section 39.3, “File Systems”.
You must have the parted package installed to use the parted utility. To start parted, at a shell prompt as root, type the command parted , where /dev/sda/dev/sda is the device name for the drive you want to configure. The (parted) prompt is displayed. Type help to view a list of available commands.
If you want to create, remove, or resize a partition, the device cannot be in use (partitions cannot be mounted, and swap space cannot be enabled). The partition table should not be modified while in use because the kernel may not properly recognize the changes. Data could be overwritten by writing to the wrong partition because the partition table and partitions mounted do not match. The easiest way to achieve this it to boot your system in rescue mode. Refer to Chapter 5, Basic System Recovery for instructions on booting into 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 12.1, “parted commands” contains a list of commonly used parted commands. The sections that follow explain some of them 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 |
mklabel
|
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
|
Table 12.1. parted commands