Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite erhalten Sie eine Übersicht über das Dateisystem von Container-Optimized OS. Außerdem wird beschrieben, wie Sie Laufwerke bereitstellen und formatieren.
Dateisystem
Das Dateisystemlayout für das Container-Optimized OS-Knoten-Image wurde optimiert, um die Knotensicherheit zu verbessern. Der Boot-Speicherplatz ist in drei Arten von Partitionen aufgeteilt:
Die Root-Partition, die schreibgeschützt bereitgestellt wird.
Zustandsorientierte Partitionen, die bearbeitbar und zustandsorientiert sind.
Zustandslose Partitionen, die zwar bearbeitbar sind, deren Inhalte jedoch bei einem Neustart nicht erhalten bleiben.
Wenn Sie Container-Optimized OS nutzen, beachten Sie die Partitionierung, falls Sie eigene Services ausführen, die bestimmte "Erwartungen" an das Dateisystemlayout außerhalb von Containern haben.
Das Root-Dateisystem wird zur Wahrung der Systemintegrität schreibgeschützt zur Verfügung gestellt. Die Basisverzeichnisse und /mnt/stateful_partition sind jedoch persistent und beschreibbar.
Mit dem Container-Optimized OS-Dateisystem arbeiten
Im Folgenden finden Sie eine Liste der Pfade im Dateisystem des Container-Optimized OS-Knoten-Images sowie deren Attribute und empfohlene Verwendung:
Pfad
Eigenschaften
Zweck
/
Schreibgeschützt
Ausführbar
Das Root-Dateisystem wird zur Wahrung der Integrität schreibgeschützt zur Verfügung gestellt. Der Kernel überprüft die Integrität des Root-Dateisystems beim Starten und verweigert den Start, wenn Fehler vorliegen.
/home /var
Bearbeitbar
Nicht ausführbar
Zustandsorientiert
Diese Pfade dienen zum Speichern von Daten, die für die Lebensdauer des Startdatenträgers bestehen bleiben. Sie werden über /mnt/stateful_partition bereitgestellt.
/var/lib/google /var/lib/docker /var/lib/toolbox
Bearbeitbar
Ausführbar
Zustandsorientiert
Diese Pfade gehören zu Arbeitsverzeichnissen für Compute Engine-Pakete (z. B. den Account-Manager-Dienst), Docker bzw. Toolbox.
/var/lib/cloud
Bearbeitbar
Ausführbar
Zustandslos
tmpfs
Dieser Pfad ist das Arbeitsverzeichnis des Pakets cloud-init.
/etc
Bearbeitbar
Ausführbar
Zustandslos
tmpfs
Enthält normalerweise Ihre Konfiguration. Beispiel: über cloud-init definierte Services vom Typ systemd. Es empfiehlt sich, den gewünschten Status Ihrer Instanzen in cloud-init zu erfassen, da cloud-init zur Anwendung kommt, wenn eine Instanz neu erstellt und wenn eine Instanz neu gestartet wird.
/tmp
Bearbeitbar
Nicht ausführbar
Zustandslos
tmpfs
Wird normalerweise als temporärer Speicherbereich verwendet und sollte nicht zum Speichern von nichtflüchtigen Daten verwendet werden.
/mnt/disks
Bearbeitbar
Ausführbar
Zustandslos
tmpfs
Sie können nichtflüchtige Speicher in Verzeichnissen unter /mnt/disks bereitstellen.
Zum Bereitstellen der Laufwerke erstellen Sie ein Unterverzeichnis unter dem Verzeichnis /mnt/disks. Da /etc/ unter dem Container-Optimized OS zustandslos ist, können Sie /etc/fstab nicht verwenden, um die Laufwerke beim Booten automatisch mithilfe von fsck (Dateisystemkonsistenzprüfung) zu überprüfen und bereitzustellen. Um dies dennoch zu tun führen Sie diese Vorgänge vom Abschnitt bootcmd Ihrer cloud-configher aus.
Im folgenden Beispiel wird das Laufwerk DEVICE_ID unter dem Verzeichnis /mnt/disks bereitgestellt.
Erstellen Sie eine Scriptdatei mit folgendem Inhalt:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-19 (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."]]