Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini memberikan ringkasan tentang sistem file Container-Optimized OS
dan menjelaskan cara memasang dan memformat disk.
Sistem file
Tata letak sistem file image node Container-Optimized OS dioptimalkan untuk
meningkatkan keamanan node. Kapasitas disk booting dibagi menjadi tiga jenis
partisi:
Partisi root, yang dipasang sebagai hanya baca.
Partisi stateful, yang dapat ditulis dan stateful.
Partisi stateless, yang dapat ditulis tetapi kontennya tidak akan dipertahankan
setiap kali ada peristiwa mulai ulang.
Saat menggunakan Container-Optimized OS, perhatikan partisi jika Anda menjalankan
layanan sendiri yang memiliki ekspektasi tertentu tentang tata letak sistem file
di luar penampung.
Sistem file root dipasang sebagai hanya baca untuk melindungi integritas sistem.
Namun, direktori beranda dan /mnt/stateful_partition bersifat persisten dan
dapat ditulis.
Menggunakan sistem file Container-Optimized OS
Berikut adalah daftar jalur dalam sistem file image node
Container-Optimized OS, beserta properti dan penggunaan yang direkomendasikan:
Jalur
Properti
Tujuan
/
hanya baca
dapat dieksekusi
Sistem file root dipasang sebagai hanya baca untuk menjaga integritas. Kernel
memverifikasi integritas sistem file root selama booting, dan akan menolak booting
jika terjadi error.
/home
/var
dapat ditulis
tidak dapat dieksekusi
stateful
Jalur ini dimaksudkan untuk menyimpan data yang akan dipertahankan selama boot disk masih digunakan. File tersebut dipasang dari /mnt/stateful_partition.
/var/lib/google
/var/lib/docker
/var/lib/toolbox
dapat ditulis
dapat dieksekusi
stateful
Jalur ini merupakan direktori kerja untuk paket Compute Engine (misalnya, layanan pengelola akun), Docker, dan Toolbox.
/var/lib/cloud
dapat ditulis
dapat dieksekusi
stateless
tmpfs
Jalur ini adalah direktori kerja paket cloud-init.
/etc
dapat ditulis
dapat dieksekusi
stateless
tmpfs
Biasanya menyimpan konfigurasi Anda (misalnya, layanan systemd yang ditentukan melalui cloud-init). Sebaiknya tangkap status instance yang diinginkan dari instance Anda di cloud-init, karena cloud-init diterapkan saat instance baru dibuat serta saat instance dimulai ulang.
/tmp
dapat ditulis
tidak dapat dieksekusi
stateless
tmpfs
Biasanya digunakan sebagai kapasitas sementara dan tidak boleh digunakan untuk menyimpan
data persisten.
/mnt/disks
dapat ditulis
dapat dieksekusi
stateless
tmpfs
Anda dapat memasang persistent disk di direktori pada /mnt/disks.
Disk dapat dipasang dengan membuat subdirektori di direktori
/mnt/disks. Karena /etc/ stateless di Container-Optimized OS, Anda
tidak dapat menggunakan /etc/fstab untuk melakukan fsck (pemeriksaan konsistensi sistem file) secara otomatis
dan memasang disk saat booting. Namun, Anda dapat mencapai hal yang sama dengan melakukan operasi
tersebut dari bagian bootcmd di
cloud-config.
Contoh berikut memasang disk DEVICE_ID
di direktori /mnt/disks.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[[["\u003cp\u003eContainer-Optimized OS uses a file system layout with read-only root, stateful, and stateless partitions to enhance node security.\u003c/p\u003e\n"],["\u003cp\u003eThe root file system is read-only to protect system integrity, but home directories and \u003ccode\u003e/mnt/stateful_partition\u003c/code\u003e are writable and persistent.\u003c/p\u003e\n"],["\u003cp\u003eSpecific paths like \u003ccode\u003e/var/lib/google\u003c/code\u003e, \u003ccode\u003e/var/lib/docker\u003c/code\u003e, and \u003ccode\u003e/var/lib/toolbox\u003c/code\u003e are designated for working directories of certain services, and are stateful.\u003c/p\u003e\n"],["\u003cp\u003ePersistent disks can be attached and mounted under \u003ccode\u003e/mnt/disks\u003c/code\u003e using \u003ccode\u003ecloud-config\u003c/code\u003e scripts, as the \u003ccode\u003e/etc/fstab\u003c/code\u003e method is not available due to the stateless nature of \u003ccode\u003e/etc/\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can use \u003ccode\u003ecloud-init\u003c/code\u003e to handle configuration and mounting of disks on Container-Optimized OS instances, ensuring that configurations are applied on creation and restarts.\u003c/p\u003e\n"]]],[],null,["# Disks and file system overview\n\nThis page provides an overview of the Container-Optimized OS file system\nand describes how to mount and format disks.\n\nFile system\n-----------\n\nThe Container-Optimized OS node image file system layout is optimized to\nenhance node security. The boot disk space is split into three types of\npartitions:\n\n- **Root partition**, which is mounted as read-only.\n- **Stateful partitions**, which are writable and stateful.\n- **Stateless partitions**, which are writable but the contents do not persist across reboots.\n\nWhen using Container-Optimized OS, be aware of the partitioning if you run\nyour own services that have certain expectations about the file system layout\noutside of containers.\n\nThe root file system is mounted as read-only to protect system integrity.\nHowever, home directories and `/mnt/stateful_partition` are persistent and\nwritable.\n\n### Working with the Container-Optimized OS file system\n\n\nThe following is a list of paths in the Container-Optimized OS node image file\nsystem, along with their properties and recommended usage:\n\nMounting and formatting disks\n-----------------------------\n\nYou can attach a persistent disk or create an instance with Local SSDs when using\nContainer-Optimized OS. Follow the instructions on [Formatting and mounting\na persistent disk](/compute/docs/disks/format-mount-disk-linux#format_linux) or\n[Format and mount a local SSD device](/compute/docs/disks/add-local-ssd#formatandmount)\nfor the appropriate use-case.\n\nThe disks can be mounted by creating a subdirectory under `/mnt/disks`\ndirectory. Since `/etc/` is stateless on Container-Optimized OS, you\ncannot use `/etc/fstab` to automatically fsck (file system consistency check)\nand mount the disks on boot. But you can achieve the same by doing those\noperations from the `bootcmd` section in your\n[`cloud-config`](http://cloudinit.readthedocs.io/en/latest/topics/examples.html).\n\nThe following example mounts the disk \u003cvar translate=\"no\"\u003eDEVICE_ID\u003c/var\u003e\nunder the `/mnt/disks` directory.\n\n1. Create a script file using the following contents:\n\n #cloud-config\n\n bootcmd:\n - fsck.ext4 -tvy /dev/\u003cvar translate=\"no\"\u003eDEVICE_ID\u003c/var\u003e\n - mkdir -p /mnt/disks/\u003cvar translate=\"no\"\u003eMNT_DIR\u003c/var\u003e\n - mount -t ext4 -o ... /dev/\u003cvar translate=\"no\"\u003eDEVICE_ID\u003c/var\u003e /mnt/disks/\u003cvar translate=\"no\"\u003eMNT_DIR\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDEVICE_ID\u003c/var\u003e: the device ID of the disk that you want to format and mount.\n - \u003cvar translate=\"no\"\u003eMNT_DIR\u003c/var\u003e: the directory in which to mount your disk.\n\n Refer to the Linux documentation for a full set of options\n supported by the [`fsck.ext4`](http://man7.org/linux/man-pages/man8/e2fsck.8.html)\n and [`mount`](http://man7.org/linux/man-pages/man8/mount.8.html) commands.\n2. Update the VM metadata to include the script file by using the\n `--metadata-from-file` flag.\n\n To create a VM, use the following command: \n\n gcloud compute instances create \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e \\\n --metadata-from-file user-data=\u003cvar translate=\"no\"\u003eSCRIPT_FILE_NAME\u003c/var\u003e\n\n To update an existing instance, use the following command: \n\n gcloud compute instances add-metadata \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e \\\n --metadata-from-file user-data=\u003cvar translate=\"no\"\u003eSCRIPT_FILE_NAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e: the name of your VM instance.\n - \u003cvar translate=\"no\"\u003eSCRIPT_FILE_NAME\u003c/var\u003e: the name of the metadata script file."]]