Resizing volumes
This assumes a volume/label type of GPT. The instructions assume there is available space on the disk i.e. you've already made the disk bigger in the storage device.
All the following should be done with the volume dismounted.
If the filesystem is being grown to greater than 16TB it needs to be converted to EXT4 or BTRFS first. If the conversion is necessary you must check the fstab entry correctly specifies the new filesystem used.
This page assumes EXT filesystems. See BTRFS for instructions on use of that filesystem.
See also page on Using lvm.
GPT method (increasing volume size)
Run parted on your device as root or with sudo:
parted /dev/sdX
Inside parted change display unit to sectors:
unit s
Print current partition table and note the start sector for your partition:
p
Delete your partition (this won't delete the data or filesystem!):
rm <number>
Recreate the partition with the starting sector from above:
mkpart primary <start> <end>
(if you want a partition that fills the available disk, it's the number of maximum sectors shown when you print the table except -1)
Exit parted:
quit
Check the filesystem:
e2fsck -f /dev/sdXX
Resize filesystem:
sudo resize2fs /dev/sdXX
GPT method (decreasing)
Use
df -h
to determine available free space.
Then umount the volume.
umount /dev/sdXX
And check the filesystem is healthy.
e2fsck -f -C 0 /dev/sdXX
If you get errors from above, remount the volume and start again (it may effect reported size).
Next resize the volume as required, noting that if you request it is made smaller than the available space it will abort, but if you make it very close to making the remaining volume full, it can take a long time to complete, especially if the space being recovered was previously used i.e. you've deleted lot of files.
resize2fs /dev/sdXX x000G
Mount the volume to check the reported size and then unmount it again.
Start parted
parted /dev/sdX
Delete your partition (this won't delete the data or filesystem!):
rm <number>
Recreate the partition with the starting sector from above:
mkpart primary <start> <end>
(if you want a partition that fills the available disk, it's the number of maximum sectors shown when you print the table except -1)
Exit parted:
quit
If you get an error when mounting it and dmesg has an error about geometry, run parted again and choose an "End" larger than previously. Once it mounts successfully, unmount it and run e2fsck again as above.