Skip to content

Mount Namespace Isolation for Storage Management #10

Description

@klogg

Problem / Motivation

Currently, aos-unit processes directly access storage paths on the host filesystem, leading to several issues:

  1. Tight coupling to host filesystem: Storage layout changes require script updates throughout codebase
  2. Difficult overlay management: Integration with overlay storage (issue Support per-node writable overlay disks on top of a base image #1) and TPM state (issue Add optional TPM 2.0 emulation for QEMU nodes (swtpm + QEMU tpm-tis) #5) requires careful path coordination
  3. Future multi-instance complexity: Supporting multiple instances (issue Support multiple aos-unit instances on one host #3) will require extensive path logic

Proposed Solution

Use Linux Mount Namespaces to provide a uniform filesystem view for aos-unit processes, decoupling scripts from the physical storage layout.

Key Benefits for Single Instance

  1. Uniform paths: All scripts use same paths regardless of actual storage location
  2. Path isolation: Processes cannot accidentally access directories outside their designated storage
  3. Clean abstraction: Physical storage location hidden from application layer
  4. Easier overlay integration: Overlays (issue Support per-node writable overlay disks on top of a base image #1) and TPM state (issue Add optional TPM 2.0 emulation for QEMU nodes (swtpm + QEMU tpm-tis) #5) use predictable paths
  5. Future-proof: Enables multiple instance support (issue Support multiple aos-unit instances on one host #3) without script changes

Storage Layout

Host Filesystem

/var/lib/aos-unit/
├── aos-vm-main-amd64.qcow2          # Base images at root (backward compatible)
├── aos-vm-secondary-amd64.qcow2
├── aos-vm-custom-amd64.qcow2
│
└── overlays/
    └── default/                     # Default instance storage
        └── <all the stored data>

/var/log/aos-unit/
└── default/                          # Default instance logs
    └── <all the logs>

/run/aos-unit/
└── default/                          # Default instance runtime
    └── <all the runtime files>

Inside Mount Namespace

/var/lib/aos-unit/
├── aos-vm-main-amd64.qcow2          # Same as host (naturally visible)
├── aos-vm-secondary-amd64.qcow2
│
└── overlays/                         # Bind mounted from default/overlays/
    └── <all the stored data>

/var/log/aos-unit/                   # Bind mounted from default/
└── <all the logs>

/run/aos-unit/                       # Bind mounted from default/
└── <all the runtime files>

Acceptance Criteria

Functional Requirements

  • Mount namespace created on aos-unit startup
  • Bind mounts correctly map instance directories to uniform paths
  • Base images accessible at /var/lib/aos-unit/*.qcow2 inside namespace
  • Overlay storage works with mount namespace
  • TPM state stored in correct location
  • Logs written to correct location

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions