Chapter 13. Partitions
Note
			For an overview of the advantages and disadvantages to using partitions on block devices, see the following KBase article: https://access.redhat.com/solutions/163853.
		
		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 following command:
	
parted /dev/sda
# parted /dev/sda
		Replace /dev/sda with 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.
	
		It is possible to create a new partition on a device that is in use, but this is 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 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: 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
	
partx --update --nr partition-number disk
# partx --update --nr partition-number disk
		The easiest way to modify disks that are currently in use is:
	
- 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.
	
		To see commonly used parted commands, see Table 13.1, “
parted Commands”.
	Important
			Do not use the parted utility to create file systems. Use the mkfs tool instead.
		
| 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 Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
			To view the partition table:
		
- Start parted.
 - Use the following command to view the partition table:
(parted) print
(parted) printCopy to Clipboard Copied! Toggle word wrap Toggle overflow  
			A table similar to the following one appears:
		
Example 13.1. Partition Table
			Following is the description of the partition table:
		
- Model: ATA ST3160812AS (scsi): explains the disk type, manufacturer, model number, and interface.
 - Disk /dev/sda: 160GB: displays the file path to the block device and the storage capacity.
 - Partition Table: msdos: displays the disk label type.
 - In the partition table,
Numberis the partition number. For example, the partition with minor number 1 corresponds to/dev/sda1. TheStartandEndvalues are in megabytes. ValidTypesare metadata, free, primary, extended, or logical. TheFile systemis the file system type. The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba. 
			The 
File system in the partition table can be any of the following:
		- ext2
 - ext3
 - fat16
 - fat32
 - hfs
 - jfs
 - linux-swap
 - ntfs
 - reiserfs
 - hp-ufs
 - sun-ufs
 - xfs
 
			If a 
File system of a device shows no value, this means that its file system type is unknown.
		Note
				To select a different device without having to restart 
parted, use the following command and replace /dev/sda with the device you want to select:
			(parted) select /dev/sda
(parted) select /dev/sda
				It allows you to view or configure the partition table of a device.