Enlarging partitions
Instructions adapted for centron on extending a partitioned volume:
Checking the partitioning
If you are not sure whether your volume is partitioned, you can check this using lsblk --fs:
sudo lsblk --fs /dev/disk/by-id/use_your_volume_identifier
The FSTYPE column lists a file system such as ext4 for unpartitioned volumes and a variant such as sda1 for partitioned volumes.
Extending a partitioned volume
To extend a partitioned volume, once you have increased the size of the volume itself, you must extend the last partition in order to utilise the new storage space. This involves rewriting the partition table and extending the file system of the last partition.
Rewriting the partition table
We recommend using gdisk to rewrite partition tables. First, unmount all the partitions. This is the same process as unmounting an unpartitioned volume, repeated for each of the partitions on the volume.
Change to a writable directory and start gdisk with the volume identifier:
cd ~
sudo gdisk /dev/disk/by-id/use_your_volume_identifier
To ensure safety, use the b command to back up the current partition and enter a filename for the backup when prompted.
Extending the last partition
To make use of the new free space on the volume, extend the last partition into the free space by deleting the existing partition and recreating it.
Use p to display the current partition table, and make a note of the values for Number, Start (sector), Code and Name of the last partition. Use these to check that the values are correct when creating the new partition.
Use d to remove the partition. Use n to create a new partition. The suggested values are usually correct, but please check them against the values of the deleted partition. At the ‘Last sector’ prompt, accept the default value to extend the partition to the end of the hard disk.
Extending the file system of the last partition
Next, you need to extend the file system on the last partition to make use of the additional available disk space.
First, unmount the hard drive:
sudo umount /mnt/use_your_mount_point
The procedure for extending the file system of the last partition depends on the type of file system.
Use lsblk --fs to check the file systems on your partitions. Extend ext4 partitions and check them for inconsistencies using e2fsck before extending them with resize2fs:
sudo e2fsck -f /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1
sudo resize2fs /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1
Once the file system has been checked and expanded, you can mount the new file system and utilise the additional storage space within the volume. Use df -h -x tmpfs -x devtmpfs to check the available storage information.