Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

How to Resize Disk of a VM Instance in Google Cloud

by Cloudbooklet
4 years ago
in Google Cloud, Compute Engine
How To Resize Disk Of A Vm Instance In Google Cloud
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

How to Resize Disk of a VM Instance in Google Cloud. In this guide you are going to learn how to resize the disk space of your Compute Engine instance on the fly without any downtime.

ADVERTISEMENT

Table of Contents

  1. Prerequisites
  2. Step 1: Check Disk Size
  3. Step 2: Check Partition
  4. Step 3: Increase Disk Size
  5. Step 4: Grow Partition
  6. Step 5: Resize File System
  7. Step 6: Verify the Setup
  8. Conclusion

You can also attach and mount new additional disk to your instance instead of resizing your disk.

Prerequisites

  1. SSH access to your VM Instance.
  2. Backup your disk by creating a snapshot of your disk. You can also setup automatic snapshot schedules.
  3. Basic SSH terminal skills to execute commands.

Important: You can only enlarge the size of the existing disk, you cannot shrink your disk to lower size.

Step 1: Check Disk Size

Before resizing your disk size you can check your available disk space so you will get an idea about the available space in your disk. It is recommended to increase the size if your used space is more than 80%.

ADVERTISEMENT

Execute the following command to check the disk space.

You might also like

How To Install Git On Ubuntu 20.04

How to Install Git on Linux

3 months ago
Vector Image

DataStax Enhances Astra DB on Google Cloud with Vector Search Capability

3 months ago
df -h

You will get an output similar to the one below.

Output
Filesystem      Size  Used Avail Use% Mounted on
udev            286M     0  286M   0% /dev
tmpfs            60M  2.4M   57M   4% /run
/dev/sda1       9.8G  1.1G  8.2G  12% /
tmpfs           297M     0  297M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           297M     0  297M   0% /sys/fs/cgroup

Here /dev/sda1 is the one which shows the available and used space of your disk. I tested this on a new fresh disk with 10GB space.

ADVERTISEMENT

Step 2: Check Partition

Now you need to check the partitions available on the your disk.

lsblk

This command shows the available partitions. You will get an output similar to this.

ADVERTISEMENT
Output
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda      8:0    0  10G  0 disk 
└─sda1   8:1    0  10G  0 part /

In this case we having only one partition.

As you can see, sda is the DEVICE_ID and 1 is the partition number.

ADVERTISEMENT

Step 3: Increase Disk Size

Go to your Google Cloud Console and navigate to Compute >> VM Instances.

Click the name of the instance where you want to add a disk.

ADVERTISEMENT

Scroll down to Boot disk and click on the disk name.

Now you will be taken to the Disk Management page.

Click Edit on the top.

Here you can specify the size of you need.

Click Save in the bottom to apply the changes.

Resize Disk

Step 4: Grow Partition

Now you need to resize the partition using the growpart command with your device id and partition number.

sudo growpart /dev/sda 1

You will get something similar.

Output
CHANGED: partition=1 start=4096 old: size=20967424 end=20971520 new: size=1048571871,end=1048575967

Step 5: Resize File System

The last step is to resize the filesystem with the resize2fs command.

sudo resize2fs /dev/sda1

The output will be like this.

Output
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 63
The filesystem on /dev/sda1 is now 131071483 (4k) blocks long.

Step 6: Verify the Setup

Now you can verify the disk space using the df command. Your disk space must have rezised to the additional space you added.

df -h
Output
Filesystem      Size  Used Avail Use% Mounted on
udev            286M     0  286M   0% /dev
tmpfs            60M  2.4M   57M   4% /run
/dev/sda1       493G  1.2G  471G   1% /
tmpfs           297M     0  297M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           297M     0  297M   0% /sys/fs/cgroup

Get your Professional Google Cloud Architect certificate with this easy to learn course now.

Conclusion

Now you have learned how to resize your VM Instance without restarting and without downtime.

Tags: Compute EngineGoogle Cloud Platform
Share4Tweet3SendShare
Cloudbooklet

Cloudbooklet

Comments 13

  1. Avatar Of Avínava Basu Avínava Basu says:
    2 years ago

    You are the Boss!

    Reply
  2. Avatar Of Brian Brian says:
    2 years ago

    Worked as explained. Thanks for the instructions.

    Reply
  3. Avatar Of Poulami Raha Poulami Raha says:
    3 years ago

    If I do all these steps to increase the size, does it mean it will remove all the existing data from the boot disk??

    Reply
    • Avatar Of Cloudbooklet Cloudbooklet says:
      3 years ago

      No, it wont remove the existing data. Your data will be there as it is.

      Reply
  4. Avatar Of Rayne Flores Rayne Flores says:
    3 years ago

    Like a Charm

    Reply
Next

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

How To Setup Ssh Keys On Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

4 months ago
Draggan Ai Editing Tool Install And Use Draggan Photo Editor

DragGAN AI Editing Tool Install and Use DragGAN Photo Editor

4 months ago
Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

7 months ago
How To Install Or Upgrade Php 8.2 On Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

9 months ago

Follow Us

Trending Articles

Tiktok

5 Best TikTok Private Account Viewer in 2023

September 18, 2023

Top 10 Advantages of a Cloud VPS Server

Best 10 AI Comic Generator: Create Comic book in Seconds

AI Annotation Jobs: Everything You Need to Know

How to Block YouTube Ads on Android TV in 2023 (6 Easy Methods)

Create a Professional Website with Wix AI Website Builder

Popular Articles

Ai Youtube Thumbnail Maker

7 Best AI YouTube Thumbnail Maker for Better Video Engagement

September 2, 2023

OpenAI Introduces ChatGPT Enterprise for Businesses

8 Best AI GIF Generators of 2023

How to Use Hulu Bug Tracker to Improve Your Streaming Experience

How to Use ChatGPT to Translate Your Website or Blog

Winston AI: How to Check AI Plagiarism for Better SEO

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.