This page provides an overview of the Container-Optimized OS file system and describes how to mount and format disks.
The Container-Optimized OS node image file system layout is optimized to enhance node security. The boot disk space is split into three types of partitions:
- Root partition, which is mounted as read-only.
- Stateful partitions, which are writable and stateful.
- Stateless partitions, which are writable but the contents do not persist across reboots.
When using Container-Optimized OS, be aware of the partitioning if you run your own services that have certain expectations about the file system layout outside of containers.
The root file system is mounted as read-only to protect system integrity.
However, home directories and
/mnt/stateful_partition are persistent and
Working with the Container-Optimized OS file system
The following is a list of paths in the Container-Optimized OS node image file system, along with their properties and recommended usage:
||The root filesystem is mounted as read-only to maintain integrity. The kernel verifies integrity root filesystem during boot up, and refuses to boot in case of errors.|
||These paths are meant for storing data that persists for the lifetime of
the boot disk. They are mounted from
||These paths are working directories for Compute Engine packages (for example, the accounts manager service), Docker, and Toolbox respectively.|
||This path is the working directory of the
||Typically holds your configuration (for example,
||Typically used as a scratch space and should not be used to store persistent data.|
||You can mount persistent disks at directories under
Mounting and formatting disks
You can attach a persistent disk or create an instance with Local SSDs when using Container-Optimized OS. Follow the instructions on Formatting and mounting a persistent disk or Format and mount a local SSD device for the appropriate use-case.
The disks can be mounted by creating a subdirectory under
/etc/ is stateless on Container-Optimized OS, you
/etc/fstab to automatically fsck (file system consistency check)
and mount the disks on boot. But you can achieve the same by doing those
operations from the
bootcmd section in your
The following example mounts the disk
Create a script file using the following contents:
#cloud-config bootcmd: - fsck.ext4 -tvy /dev/DEVICE_ID - mkdir -p /mnt/disks/MNT_DIR - mount -t ext4 -O ... /dev/DEVICE_ID /mnt/disks/MNT_DIR
Replace the following:
DEVICE_ID: the device ID of the disk that you want to format and mount.
MNT_DIR: the directory in which to mount your disk.
Update the VM metadata to include the script file by using the
To create a VM, use the following command:
gcloud compute instances create INSTANCE_NAME \ --metadata-from-file user-data=SCRIPT_FILE_NAME
To update an existing instance, use the following command:
gcloud compute instances add-metadata INSTANCE_NAME \ --metadata-from-file user-data=SCRIPT_FILE_NAME
Replace the following:
INSTANCE_NAME: the name of your VM instance.
SCRIPT_FILE_NAME: the name of the metadata script file.