Use parted
:
parted device resize minor start end
Resizes the partition with number minor from device device. The partition will start start from the beginning of the disk, and end end from the beginning of the disk. resize
never changes the minor number. Extended partitions can be resized, so long as the new extended partition completely contains all logical partitions.
Note that parted
does not require a file system to be "defragged" (parted
can safely move data around if necessary).
Supported file systems:
- ext2, ext3 - restriction: the new start must be the same as the old start.
- fat16, fat32
- linux-swap
- reiserfs (if libreiserfs is installed)
Example:
sudo parted -i /dev/sda resize 3 200 850
Resize partition 3 from /dev/sda
, so that it begins 200 megabytes and ends 850 megabytes from the beginning of the disk. -i
(--interactive
) prompt for your intervention, where necessary.
Source: Parted User's Manual.
See also man parted
for more info.