이 페이지에서는 Container-Optimized OS 파일 시스템을 간략히 설명하고 디스크를 마운트하고 포맷하는 방법을 설명합니다.
파일 시스템
Container-Optimized OS 노드 이미지 파일 시스템 레이아웃은 노드 보안을 향상시키도록 최적화되어 있습니다. 부팅 디스크 공간은 세 가지 유형의 파티션으로 나뉩니다.
루트 파티션 - 읽기 전용으로 마운트됩니다.
스테이트풀(Stateful) 파티션 - 쓰기 가능하고 스테이트풀(Stateful) 특성을 갖습니다.
스테이트리스(Stateless) 파티션 - 쓰기 가능하지만, 재부팅할 때 콘텐츠가 지속되지 않습니다.
Container-Optimized OS를 사용할 때는 컨테이너 외부의 파일 시스템 레이아웃에 대해 특정 요구 사항이 있는 고유 서비스를 실행할 경우 파티션 나누기에 주의해야 합니다.
루트 파일 시스템은 시스템 무결성을 보호하기 위해 읽기 전용으로 마운트됩니다.
그러나 홈 디렉터리 및 /mnt/stateful_partition은 영구적이며 쓰기가 가능합니다.
컨테이너 최적화 OS 파일 시스템 작업
다음은 Container-Optimized OS 노드 이미지 파일 시스템의 경로 목록과 그 속성 및 권장 용도를 보여줍니다.
경로
속성
목적
/
읽기 전용
실행 가능
루트 파일 시스템이 무결성 유지를 위해 읽기 전용으로 마운트됩니다. 커널이 부팅 중 무결성 루트 파일 시스템을 확인하고, 오류 발생 시 부팅을 거절합니다.
/home
/var
쓰기 가능
실행 불가능
스테이트풀(Stateful)
이러한 경로는 부팅 디스크의 수명 동안 지속되는 데이터를 저장하기 위한 용도로 사용됩니다. /mnt/stateful_partition에서 마운트됩니다.
/var/lib/google
/var/lib/docker
/var/lib/toolbox
쓰기 가능
실행 가능
스테이트풀(Stateful)
이러한 경로는 각각 Compute Engine 패키지(예: 계정 관리자 서비스), Docker, 도구 상자의 작업 디렉터리입니다.
/var/lib/cloud
쓰기 가능
실행 가능
스테이트리스(Stateless)
tmpfs
이 경로는 cloud-init 패키지의 작업 디렉터리입니다.
/etc
쓰기 가능
실행 가능
스테이트리스(Stateless)
tmpfs
일반적으로 구성이 저장됩니다(예: cloud-init를 통해 정의된 systemd 서비스). 인스턴스를 다시 시작할 때는 물론 인스턴스를 새로 생성할 때에도 cloud-init가 적용되므로 cloud-init에서 원하는 인스턴스 상태를 캡처하는 것이 좋습니다.
/tmp
쓰기 가능
실행 불가능
스테이트리스(Stateless)
tmpfs
일반적으로 스크래치 공간으로 사용되며, 영구 데이터 저장을 위해 사용되지 않습니다.
/mnt/disks
쓰기 가능
실행 가능
스테이트리스(Stateless)
tmpfs
/mnt/disks 아래의 디렉터리에 영구 디스크를 마운트할 수 있습니다.
디스크 마운트 및 포맷
Container-Optimized OS를 사용할 경우 영구 디스크를 연결하거나 로컬 SSD로 인스턴스를 만들 수 있습니다. 적절한 사용 사례에 맞게 영구 디스크 포맷 및 마운트 또는 로컬 SSD 기기 포맷 및 마운트의 안내를 따르세요.
/mnt/disks 디렉터리 아래에 하위 디렉터리를 만들어 디스크를 마운트할 수 있습니다. /etc/는 Container-Optimized OS에서 스테이트리스(Stateless)이므로 부팅 시 디스크 fsck(파일 시스템 일관성 검사)를 수행하거나 디스크를 마운트하는 데 /etc/fstab을 사용할 수 없습니다. 그러나 cloud-config의 bootcmd 섹션에서 이러한 작업을 수행하여 동일한 결과를 얻을 수 있습니다.
다음 예시에서는 /mnt/disks 디렉터리 아래에 DEVICE_ID 디스크를 마운트합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 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."]]