how to grow /dev/sda in google compute engine?

923 views
Skip to first unread message

Martin Armunanto

unread,
Feb 14, 2014, 11:03:39 PM2/14/14
to gce-dis...@googlegroups.com

I am new in gce and try to grow my /dev/sda disk. As my data would break the persistent disk's limit, I want to grow it.

how can I do that? I have added 200Gb disk to my instance, then make file system on it. this is fdisk -lu result:

Disk /dev/sda: 10.7 GB, 10737418240 bytes
4 heads, 32 sectors/track, 163840 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0004a990

Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    20969472    10483712+  83  Linux

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
86 heads, 25 sectors/track, 195083 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x70f99a87

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   419430399   209714176   83  Linux

But when I am running df -h, the result is:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             9.9G  998M  8.4G  11% /
tmpfs                 851M     0  851M   0% /dev/shm

what should I do? Please help.. thanks..

David McWherter

unread,
Feb 15, 2014, 4:27:38 AM2/15/14
to Martin Armunanto, bigcluster-image-team, gce-dis...@googlegroups.com
I don't think you can just grow /dev/sda. You have two different disk
drives attached, effectively. You could use something like lvm to
make them appear as one logical, bigger volume. Or you can mount
/dev/sdb somewhere into your filesystem tree.

You could grow /dev/sda by copying it into another persistent disk,
then using a tool like image_bundle, make a custom image, then make a
bigger PD out of it, and resize the filesystem after booting off of
that PD.

-david
> --
> © 2013 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
>
> Email preferences: You received this email because you signed up for the
> Google Compute Engine Discussion Google Group
> (gce-dis...@googlegroups.com) to participate in discussions with other
> members of the Google Compute Engine community and the Google Compute Engine
> Team.
> ---
> You received this message because you are subscribed to the Google Groups
> "gce-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gce-discussio...@googlegroups.com.
> To post to this group, send email to gce-dis...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gce-discussion/5ae3caaa-f3d6-4d73-b311-43cc9f58adc8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Martin Armunanto

unread,
Feb 15, 2014, 6:43:57 AM2/15/14
to gce-dis...@googlegroups.com, Martin Armunanto, bigcluster-image-team
If I just add persistent disks to an instance, would my data storage limit increased?
I mean could I just add disks to grow my "hosting capacity"? So I don't need to grow /dev/sda volume?
The reason I use small disk space is not to waste unused resources.
Is that good idea?
thanks

Tito Valentin

unread,
Feb 15, 2014, 11:54:14 AM2/15/14
to gce-dis...@googlegroups.com, Martin Armunanto, bigcluster-image-team
Hi Martin,

There are various ways to grow your persistent disk and several things to keep in mind:
  • Every image you use that is provided by GCE (currently 3 images), is configured to 10GB of space. With that said, you have two options when creating a persistent disk:
    • Create a new persistent boot disk with more than 10GB
    • Create a custom Linux image
    • Snapshots
Creating a persistent boot disk with more than 10GB has the following effect:
  • You use the --size_gb option. If you leave this option out during the creation process of your persistent boot disk, it defaults to 10GB, which is the size of the image
  • When you specify more than 10GB for your persistent disk, the first time you boot into the OS and run df -h you will not see more than 10GB so once the OS is up, if you run fdisk for that device, you'll see the size you gave the device/disk but the OS still shows 10GB. This is because you have to remember that the image provided by GCE was built this way. So, you'll have to recreate the partition table and save the changes and then resize the disk using the resize2fs command
  • Once you recreate the partition table and reboot, you'll have to resize, then running df -h will now show that the OS sees the entire disk space you requested
Creating a custom Linux image and adding LVM support for your system is another approach:
  • You can use software like Virtualbox to setup a Linux image using any flavor of Linux you want. When installing your Linux machine, set it up exactly as you would like including setting up the partitions as desired, preferably with LVM
  • Once you have the OS setup like you want it, you'll have to go through GCE documentation to add required settings/parameters that will allow your image to function in GCE.
  • You'll then bundle your image using GCE image bundle software that GCE provides to you (it's explained on their documentation)
  • Finally, you'll upload your image as required by GCE using the proper image format names/conventions. You can upload an image up to 100GB in size but I would keep it smaller if I were you. I usually keep mine at 60GB
  • If and when you boot this image, you'll have a system that is 60GB in size so you won't have to specify --size_gb when creating a disk because it'll default to the image size. You'll also have an LVM filesystem that you can grow by creating another persistent disk
You can also grow your existing disk with snapshots:
  • Take a snapshot of your persistent disk
  • Create a new persistent disk of larger size based on your needs by using the --size_gb option but tell it to create the disk using a snapshot as a source.
  • When creating the new persistent disk from a snapshot, you not only get to specify the new size of the disk but then the data of your snapshot is also intact
The information I provided is not a detailed step-by-step guide. However, it is an overview of how to accomplish what you are looking for. You'll have to check the GCE documentation for step-by-step instructions on how to follow the main bullets I provided. I hope this information helps you. I have been using GCE for only 5 days now and have been mostly just testing on different ways to accomplish the same thing you are trying to accomplish

Good luck and welcome to GCE; I know I will enjoy it :D

Martin Armunanto

unread,
Feb 17, 2014, 4:02:58 AM2/17/14
to gce-dis...@googlegroups.com, Martin Armunanto, bigcluster-image-team
Thank you David & Tito. I'll try that.
Reply all
Reply to author
Forward
0 new messages