Hi there! I'm Maneshwar. Right now, I’m building LiveAPI, a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.
When your VM’s root disk is running out of space — say you're on 20GB and need to go to 40GB — here’s the exact procedure to scale the disk without breaking anything. This example uses an Ubuntu VM named phpbb-new
.
Step 1: Resize the Disk from Google Cloud Console
- Go to Google Cloud Console.
- Navigate to Compute Engine → VM instances.
- Click your instance (e.g.
phpbb-new
). - Scroll to the "Boot disk and local disks" section.
- Click the boot disk name.
- Click EDIT at the top.
- Change Size (GB) → from
20
→ to40
. - Hit SAVE.
Note: Disk size updates immediately in GCP, but the OS inside the VM still sees the old size. You’ll need to fix that next.
Step 2: SSH into the VM
From the instance details page, hit SSH.
Confirm you’re in with:
root@phpbb-new:~#
Step 3: Check the Current Disk Usage
Run:
df -h
You’ll likely see:
Filesystem Size Used Avail Use% Mounted on
/dev/root 19G 16G 3.1G 84% /
Then run:
sudo fdisk -l
Check that it detects the new disk size:
Disk /dev/sda: 40 GiB
...
GPT PMBR size mismatch (old size vs new size)
Step 4: Fix the GPT Partition Table
Let’s correct the partition table to reflect the new size.
sudo fdisk /dev/sda
At the Command (m for help):
prompt, just type:
w
This writes the updated partition layout and exits. Ignore any "device busy" warnings — it's fine in GCP.
Step 5: Expand the Partition
Run:
sudo growpart /dev/sda 1
This resizes partition 1 (/dev/sda1
), which maps to /
.
Expected output:
CHANGED: partition=1 ... new: size=83883903
Step 6: Resize the Filesystem
Tell ext4 to use the new space:
sudo resize2fs /dev/sda1
This might take a few seconds. When it’s done, your root filesystem now uses the full disk.
Step 7: Verify It Worked
Final check:
df -h
You should now see:
Filesystem Size Used Avail Use% Mounted on
/dev/root 39G 16G 22G 43% /
Mission accomplished.
Recap: Quick Command List
# SSH into VM
df -h
sudo fdisk -l
# Fix GPT table
sudo fdisk /dev/sda
# then just type: w
# Resize partition
sudo growpart /dev/sda 1
# Resize filesystem
sudo resize2fs /dev/sda1
# Verify
df -h
Pro Tips
- Works only for disks using GPT (which is default in GCP).
- If your root disk is XFS instead of ext4, use
xfs_growfs /
instead ofresize2fs
. - For automated workflows, you can script this and run via cloud-init or startup scripts.
Done. Disk doubled. No reboot. No downtime.
LiveAPI helps you get all your backend APIs documented in a few minutes.
With LiveAPI, you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.
If you're tired of updating Swagger manually or syncing Postman collections, give it a shot.
Top comments (1)
Honestly, there's gotta be a simpler way than all these manual steps! What about just using Google Cloud's auto-resize feature or setting up disk monitoring with alerts?
Sometimes the "simple" solution is just avoiding the problem entirely.what's your opinion in this!!