... automatic disk resizing during boot time... All Compute Engine Ubuntu images will automatically resize the root partition to use the entire disk, up to a 2 TB limit. Even if the disk is larger than 2 TB, the operating system only recognizes up to 2 TB.

According to Google's Persistent Disk documentation, Ubuntu should auto-resize, but when I tried to upload 20GB data (contains small files):

"No space left on device"

I'm using gcloud:

gcloud compute copy-files ...

to upload the files.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       9.9G  9.8G     0 100% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           371M  536K  370M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G     0  1.9G   0% /run/shm
none            100M     0  100M   0% /run/user

Command (m for help): p
Disk /dev/sda: 10 GiB, 10737418240 bytes, 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
Disklabel type: dos
Disk identifier: 0x000ea22e

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1  *     2048 20971519 20969472  10G 83 Linux
  • 1
    You should try asking this on Server Fault. Still, to me, sounds like what you quoted should be taken to mean "will partition the whole disk upon creation." – Matt Apr 16 '15 at 12:33
  • can I move it somehow to Server Fault? – makkasi Apr 16 '15 at 12:37
  • You have to request/vote for it to be moved. It's in the flag option, and I'm trying to initiate the process myself, but I can't seem to select Server Fault as the correct site. – Matt Apr 16 '15 at 12:40
  • OK, I marked it to be moved – makkasi Apr 16 '15 at 12:46

As you pointed out:

All Compute Engine Ubuntu images will automatically resize the root partition to use the entire disk

Then, as per your output, you have a 10GB disk and a 10GB partition so it's not possible to resize that partition.

If you want to have a larger root disk, you'll need to create disk with the desired space. You can do it with the Cloud SDK with the following steps:

1- Create a snapshot of your instance:

gcloud compute disks snapshot DISK_NAME --snapshot-names SNAPSHOT_NAME --zone ZONE --project PROJECT_ID

2- Create a disk based on that snapshot:

gcloud compute disks create NAME --source-snapshot SOURCE_SNAPSHOT --size SIZE --zone ZONE --project PROJECT_ID

After that the disk is automatically partitioned with enough space for the root filesystem

3- Create an instance with that disk:

gcloud compute instances create NAME --disk "name=DISK_NAME" "boot=yes" --zone ZONE --project PROJECT_ID

Since Ubuntu supports automatic resizing, once it boots it should resize the partition and you should have the desired GB.

Alternatively, if you are still able to SSH into the instance, you can attach a new disk to the instance following these steps:

4- Create a new disk: gcloud compute disks create NAME --size SIZE --zone ZONE --project PROJECT_ID

5- Attach the new disk: gcloud compute instances attach-disk INSTANCE_NAME --disk NEW_DISK_NAME --zone ZONE --project PROJECT_ID

6- SSH into the instance: gcloud compute ssh INSTANCE_NAME --zone ZONE --project PROJECT_ID

7- Format the new disk.

8- Transfer files from the root disk to the new one to free up space and upload the other files to the new disk.

  • thank you. What I did is to create new disc and after from the instance options page to attach it. Then this disc should be formated and mounted from the ubuntu terminal. I used this command to do this : sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/disk/by-id/scsi-0Google_PersistentDisk_disk-1 /var/www (Is it possible to create snapshot from these two discs and to make only one?) – makkasi Apr 17 '15 at 6:24
  • 1
    I have updated my answer to take into account your solution. Regarding your other question, unfortunately, you need to make a snapshot for each disk. – Adrián Apr 17 '15 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.