Skip to main content

Grow Linux Filesystem

Problem

I need to make a disk bigger

Solution

Resize the disk:

$ gcloud compute disks list | grep home
home                           us-central1-f  zone            500      pd-ssd       READY
home-ssh-keys                  us-central1-f  zone            400      pd-standard  READY
$ gcloud compute disks resize home --size 750 --zone us-central1-f

This command increases disk size. This change is not reversible.
[lots of noise]

$ gcloud compute disks list | grep home
home                           us-central1-f  zone            750      pd-ssd       READY
home-ssh-keys                  us-central1-f  zone            400      pd-standard  READY

On the system mounting the filesystem, resize the partition (if applicable -- this isn't necessary if the entire disk is mounted ie is not partitioned):

# growpart /dev/sda 1

Resize the filesystem:

# resize2fs /home2
resize2fs 1.45.6 (20-Mar-2020)
open: Is a directory while opening /home2
[root@fs-06 sbin]# resize2fs /dev/sdb
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/sdb is mounted on /home2; on-line resizing required
old_desc_blocks = 32, new_desc_blocks = 47
The filesystem on /dev/sdb is now 196608000 (4k) blocks long.

#

xfs users will prefer to use xfs_growfs instead of resize2fs.