# How to Expand Partitions After Resizing a Volume Volumes are network-attached block storage. You can use them with Droplets or Kubernetes clusters, move or resize them, and create snapshots at any time. If you manually partitioned your volume when you created it, increasing its size also requires rewriting the partition table to expand the last partition, and then growing the filesystem on that partition to use the newly available space. Volumes are unpartitioned by default. If you automatically formatted and mounted your volume or used the [**Config instructions** under the **More** dropdown menu in the DigitalOcean Control Panel](https://cloud.digitalocean.com/volumes), your volume remains unpartitioned. In that case, follow the steps to [resize an unpartitioned volume](https://docs.digitalocean.com/products/volumes/how-to/increase-size/index.html.md). If you’re not sure whether your volume is partitioned, run the `lsblk --fs` command: ```shell sudo lsblk --fs /dev/disk/by-id/use_your_volume_identifier ``` If the filesystem appears directly on the disk (for example, `sda ext4`), the volume is unpartitioned. If you see entries such as `sda1`, `sda2`, and so on, the volume is partitioned. For example, the following output shows an unpartitioned volume because the `ext4` filesystem appears directly on `sda`: ``` NAME FSTYPE LABEL UUID MOUNTPOINT sda ext4 18efad39-6b7c-44d3-ba21-b0778911c4ed /mnt/volume-nyc1-01 ``` After you [resize the volume itself](https://docs.digitalocean.com/products/volumes/how-to/increase-size/index.html.md), expand the last partition to use the new space by first [rewriting the partition table](#rewrite), and then [expanding the filesystem on the last partition](#expand-filesystem). ## Rewrite the Partition Table We recommend using `gdisk` to rewrite GPT partition tables. It supports partition table backups, correctly relocates GPT metadata after resizing, and works with partitions of any size. First, [unmount all partitions on the volume](https://docs.digitalocean.com/products/volumes/how-to/mount-unmount/index.html.md#unmount). Then, change to a writable directory, and then start `gdisk` with the volume identifier: ```shell cd ~ sudo gdisk /dev/disk/by-id/use_your_volume_identifier ``` Then, create a backup of the current partition table using the `b` command: ```text b Enter backup filename to save: partition_table.bak ``` Enter a filename for your current partition table’s backup file. Then, use the `x` command to access the expert menu: ```text x ``` Then, move the backup GPT data structures to the end of the disk with the `e` command: ```text e Relocating backup data structures to the end of the disk ``` The `e` command is only available in the expert menu. After relocating the GPT metadata, return to the main menu using the `m` command, so you can safely run regular commands such as `p`, `d`, `n`, and `w` to modify and write the partition table. ```text m Command (? for help): ``` ### Expand the Last Partition First, display the current partition table by running the `p` command: ```text p ``` The `p` command displays disk details and the current partition table: ```text ... Partition table holds up to 128 entries First usable sector is 34, last usable sector is 419430366 Partitions will be aligned on 2048-sector boundaries Total free space is 209719229 sectors (100.0 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 209713151 100.0 GiB 8300 primary ``` Confirm that free space is available at the end of the disk, then note the values for only the last partition in the table. You reuse these values when recreating the partition so that only the ending sector changes. The partition table lists the existing partitions. In this example, there is one partition: - **Number** identifies the partition number (`1`). - **Start (sector)** shows where the partition begins (`2048`). - **End (sector)** shows where it currently ends. - **Size** shows the current partition size (`100.0 GiB`). - **Code** indicates the partition type (`8300`, which represents a Linux filesystem). - **Name** shows the GPT partition name (`primary`). You must reuse these values when recreating the partition so that only its ending sector changes while its starting position and type remain the same. Then, delete the last partition using the `d` command: ```text d ``` Then, create a new partition using the `n` command: ```text n ``` Accept the default partition number and default starting sector. For the `Last sector`, accept the default value to extend the partition to the end of the disk. ```text Partition number (1-128, default 1): First sector (34-419430366, default = 2048) or {+-}size{KMGTP}: Last sector (2048-419430366, default = 419430366) or {+-}size{KMGTP}: ... ``` If necessary, restore the original partition name using the `c` command: ```text c ``` Then, verify the updated partition table using the `p` command: ```text p ``` ### Write the Changes Write the new partition table using the `w` command: ```text w ``` `gdisk` performs final checks and warns that writing the updated GPT data overwrites the existing partition table. Confirm by entering `Y`: ```text Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): ``` `gdisk` writes the updated GPT table and exits: ```text OK; writing new GUID partition table (GPT) to /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01. The operation has completed successfully. ``` At this point, the last partition spans the full size of the resized volume. ## Expand the Filesystem of the Last Partition To expand the partitioned filesystem to use the additional space, first unmount the partition: ```shell sudo umount /mnt/use_your_mount_point ``` Then, identify the filesystem type using the `lsblk --fs` command: ```shell sudo lsblk --fs ``` If the `FSTYPE` column shows a filesystem on a partition such as `sda1` or `sda2`, the volume is partitioned. For example, the following output shows a partitioned volume because the filesystems (`ext4` and `xfs`) appear on `sda1` and `sda2`, not directly on `sda`: ```text NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ext4 37858ba9-c2f3-4afe-9013-83111111e862 └─sda2 xfs 5d141215-7473-4100-a0e2-e69d23d89ec5 ... ``` If your filesystem is unpartitioned and appears directly on the disk (for example, `sda ext4`), follow the steps to [resize an unpartitioned volume](https://docs.digitalocean.com/products/volumes/how-to/increase-size/index.html.md). ## Expand Ext4 partitions First, check the filesystem using the `e2fsck` command: ```shell sudo e2fsck -f /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 ``` `e2fsck` runs several consistency checks in multiple passes. The final line summarizes the filesystem state and reports the number of files and blocks in use. If no errors are reported, the filesystem is clean and ready to be resized: ```text e2fsck 1.42.13 (17-May-2015) Pass 1: Checking inodes, blocks, and sizes ... Pass 5: Checking group summary information /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1: 13/6553600 files (0.0% non-contiguous), 459351/26213888 blocks ``` Then, expand the filesystem using the `resize2fs` command: ```shell sudo resize2fs /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 ``` `resize2fs` reports the new size of the filesystem in 4 KB blocks. The final line confirms that the filesystem has successfully expanded to fill the partition: ```text resize2fs 1.42.13 (17-May-2015) Resizing the filesystem on /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 to 52428539 (4k) blocks. The filesystem on /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 is now 52428539 (4k) blocks long. ``` ## Expand XFS partitions First, check the filesystem with the `xfs_repair` command: ```shell sudo xfs_repair /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 ``` `xfs_repair` runs through several verification phases. The final `done` message indicates that the filesystem check completed successfully and no blocking inconsistencies remain before expanding the filesystem: ```text Phase 1 - find and verify superblock... Phase 2 - using internal log ... Phase 7 - verify and correct link counts... done ``` Then, mount the partition using the `mount` command as XFS must be mounted to grow: ```shell sudo mount -a ``` Then, expand the filesystem using the `xfs_growfs` command: ```shell sudo xfs_growfs /mnt/volume-nyc1-01-part1 ``` `xfs_growfs` reports the change in data blocks. The increase in block count confirms that the filesystem has successfully expanded to use the additional space available in the partition: ```text ... data blocks changed from 26213888 to 52428539 ``` After expanding the filesystem, mount the partition again if needed. To verify the available space, run the `df -h -x tmpfs -x devtmpfs` command: ```shell df -h -x tmpfs -x devtmpfs ``` This command displays disk usage information and excludes temporary filesystems, allowing you to confirm that the partition reflects the newly expanded size.