Search code examples
google-compute-enginedisk-partitioninggoogle-container-os

How to increase root disk partition using ContainerOs within Google Cloud?


After resizing the disk, root partition did not take more space that is available.

When running

fdisk -l

on remote VM result is :

The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 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: gpt
Disk identifier: XXXXXX-XXXXX-XXX-XXX-XXXX

Device       Start      End  Sectors  Size Type
/dev/sda1  8704000 67108830 58404831 27.9G Microsoft basic data
/dev/sda2    20480    53247    32768   16M ChromeOS kernel
/dev/sda3  4509696  8703999  4194304    2G ChromeOS root fs
/dev/sda4    53248    86015    32768   16M ChromeOS kernel
/dev/sda5   315392  4509695  4194304    2G ChromeOS root fs
/dev/sda6    16448    16448        1  512B ChromeOS kernel
/dev/sda7    16449    16449        1  512B ChromeOS root fs
/dev/sda8    86016   118783    32768   16M Microsoft basic data
/dev/sda9    16450    16450        1  512B ChromeOS reserved
/dev/sda10   16451    16451        1  512B ChromeOS reserved
/dev/sda11      64    16447    16384    8M BIOS boot
/dev/sda12  249856   315391    65536   32M EFI System

I saw lot of answers saying that I should use growpart command, but this command is not available and it seems that in containerOS you cannot install anything. I tried anyway yum, apt, apt-get, rpm without success.

I digged in Google Documentation, but did not find anything related with ContainerOS

The only workaround I found is to restart the VM, but is there any alternative that does not involve a restart ?


Solution

  • After resizing the disk, root partition did not take more space that is available.

    I believe you are doing an online resizing of the disk, right? If so, you can reboot your Container-Optimized OS (COS) machine after the resize. After reboot, the filesystem will be automatically resized to fix your disk. What's happening behind the scene, is that everytime COS boot up, resize-stateful-partition.service will handle this logic for you.

    If you cannot easily reboot the COS VM, you could try run sudo /usr/share/cloud/resize-stateful, which should also work.