LinuxCommandLibrary

resizepart

Resize a partition

SYNOPSIS

resizepart partition_number end

PARAMETERS

partition_number
    The number of the partition to resize. Partitions are typically numbered sequentially, starting from 1.

end
    The new end location of the partition. This can be specified in various units such as megabytes (MB), gigabytes (GB), terabytes (TB), or as a percentage of the disk size. Using percentages can be risky and should be done with caution.

DESCRIPTION

The resizepart command within the parted utility allows you to change the size of an existing partition on a disk. This is useful for expanding or shrinking partitions to better utilize disk space or to accommodate changing storage needs. It is a powerful tool, but improper usage can lead to data loss, so extreme caution is advised. The command takes the partition number and the new end location as arguments. It is crucial to back up important data before attempting to resize partitions. Resizepart can be used to change the size of a partition without affecting the data it contains (within limits), but file system resizing or moving may be necessary afterwards to actually take advantage of the altered partition size.
Resizepart can also corrupt the file system if the new size is too small.

CAVEATS

Data loss is possible if the partition is shrunk too much or if there are errors during the resizing process. It is strongly recommended to back up all important data before using resizepart. File system resizing may also be necessary after using resizepart.

UNITS

The end parameter accepts various units, including MB, GB, TB, cylinders, and percentages. The appropriate unit should be specified to avoid unexpected results. Without unit specified parted will threat argument as MB. Parted is going to calculate the size as close as possible but the result might be different.

FILE SYSTEM CONSIDERATIONS

Resizing a partition only changes the partition table. The file system within the partition also needs to be resized to utilize the new space. Tools like resize2fs (for ext2/3/4), xfs_growfs (for XFS), or the appropriate tools for other file systems, should be used after resizepart to resize the file system.

SEE ALSO

parted(8), mkpart(8), rm(1)

Copied to clipboard