GCP: Resize/Repair Compute engine root partition is full (100%) issues on the fly.

Preetam Mahapatra
3 min readJun 26, 2021

Sometimes as part of infrastructure management, we faced issues like root partition is full(100%). Which leads to inaccessibility of the VM via SSH or cloud shell. Or We need to resize the VM root partition due to some need. Thanks to Google cloud, we no need to stop the VM and can able t resize or expand our disk size. We can repair or resize a disk without stopping the VM using below steps.

Recommendation(To avoid disk overutilized):
1) Proper alert configuration setup using Stackdriver monitoring or any other tool
2) Housekeeping of log file and other unnecessary files

Solutions for below-listed issues:
1) If root partition is full(100%)
2) Need to resize disk without stopping the VM

Step 0.1: Check disks available and space details

$ df -h

df -h to check the disk available

Line starting with /dev/sda1 (marked yellow) is the one we are looking for. As we can see /dev/sda1 is used 100%.

If you see the use rate is over 80%, that’s probably a dangerous sign.

Step 0.2: Check partition

Check for the partition details

sudo lsblk

Step 0.3: Resize the disk on the Compute engine page
Now we need to resize the disk under
Compute engine > Disk

Inside compute engine details page

Go to the disk attached to this VM and click on the edit

Resize the disk to the needed size and click on save.

Step 0.3: If root partition is completely full 100% follow below step or skip to Step 0.4

Mount a temp folder
sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp

Step 0.4: Grow the partition

sudo growpart /dev/sda1

Step 0.4: Resize file system

lsblk to verify partition has expanded
sudo resize2fs /dev/sda1

Final Step:
Run df -h to verify your resized disk

If followed Step 0.3 use below command to delete the temp mount
sudo umount /tmp

Enjoy all done !!

--

--

Preetam Mahapatra

Google cloud certified | Software engineer | Mobile Application Developer | Tech Enthusiast | Entrepreneur | Travel | Explore | IN