πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Troubleshooting intermediate ⏱ 10 minutes K8s 1.28+

OpenShift oc debug Mount Limitation

Why NFS and filesystem mounts via oc debug node disappear after the debug pod exits. Understand the container namespace isolation and use MachineConfig instead.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: oc debug node runs in a temporary container with its own mount namespace. Any mount command executes inside the container β€” not on the host kernel. When the debug pod exits, all mounts vanish. Use MachineConfig systemd mount units for persistent mounts.

The Problem

You run oc debug node with chroot /host and execute a mount -t nfs command. It appears to succeed (no error). But when you check:

oc debug node/worker-1 -- chroot /host sh -c "mount | grep nfs"
# (empty β€” nothing mounted!)

The mount is gone. You try again, same result. Pods using hostPath to the mount point see empty directories. Fio benchmarks return zero IOPS. What’s happening?

The Solution

Why It Fails

graph TD
    subgraph "oc debug node/worker-1"
        A["Debug pod starts"] --> B["chroot /host"]
        B --> C["mount -t nfs 192.168.10.50:/share /mnt/nfs"]
        C --> D["Mount executes in<br>CONTAINER mount namespace"]
        D --> E["Appears successful<br>(no error output)"]
        E --> F["Debug pod exits"]
        F --> G["Container destroyed<br>Mount namespace gone ❌"]
    end
    
    subgraph "Host Kernel"
        H["Host mount namespace<br>UNCHANGED"]
        I["No NFS mount ever<br>reached the host"]
    end
    
    G -.->|"Mount was never<br>in host namespace"| H
    
    style G fill:#ef4444,color:#fff
    style I fill:#ef4444,color:#fff

The key insight: Even with chroot /host, the mount syscall is executed inside the container’s mount namespace, not the host’s. Linux mount namespaces provide isolation β€” the container can see the host filesystem via chroot, but new mounts are local to the container.

What chroot /host Actually Does

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Host Kernel               β”‚
β”‚  Mount Namespace: host (PID 1)      β”‚
β”‚  - /dev/sda1 on /                   β”‚
β”‚  - NFS? NO β€” never mounted here     β”‚
β”‚                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚     Debug Pod Container       β”‚  β”‚
β”‚  β”‚  Mount Namespace: container   β”‚  β”‚
β”‚  β”‚                               β”‚  β”‚
β”‚  β”‚  chroot /host β†’ sees host FS  β”‚  β”‚
β”‚  β”‚  mount -t nfs β†’ mounts HERE   β”‚  β”‚
β”‚  β”‚  (in container namespace)     β”‚  β”‚
β”‚  β”‚                               β”‚  β”‚
β”‚  β”‚  Pod exits β†’ namespace gone   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

chroot changes the root directory β€” it does not change the mount namespace. The mount syscall is still trapped in the container’s namespace.

What DOES Work

MethodPersists?Production-safe?Reboot-safe?
oc debug + mount❌ No❌❌
nsenter -t 1 -m -- mount⚠️ Until reboot❌❌
Privileged DaemonSet⚠️ While running⚠️❌
MachineConfig systemd mountβœ… Yesβœ…βœ…

The Correct Solution: MachineConfig

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  name: 99-worker-nfs-mount
  labels:
    machineconfiguration.openshift.io/role: worker
spec:
  config:
    ignition:
      version: 3.2.0
    systemd:
      units:
        - name: mnt-nfsdata.mount
          enabled: true
          contents: |
            [Unit]
            Description=Mount NFS Share
            After=network-online.target
            Wants=network-online.target

            [Mount]
            What=192.168.10.50:/exports/shared
            Where=/mnt/nfsdata
            Type=nfs
            Options=rw,hard,nointr

            [Install]
            WantedBy=multi-user.target

This creates a systemd mount unit that runs in the host mount namespace at boot time β€” the mount persists across reboots and is visible to all pods.

What About nsenter?

nsenter -a -t 1 can enter the host’s mount namespace:

oc debug node/worker-1 -- nsenter -t 1 -m -- mount -t nfs 192.168.10.50:/share /mnt/nfs

This does mount in the host namespace. However:

  • ❌ Doesn’t survive node reboot
  • ❌ Not tracked by MachineConfig (drift)
  • ❌ No systemd management (no auto-remount on failure)
  • ❌ Not supported by Red Hat

Use it for one-time debugging only, never for production mounts.

Diagnostic: Prove the Mount Namespace Issue

# 1. Mount inside oc debug
oc debug node/worker-1 -- chroot /host sh -c \
  "mount -t tmpfs test-tmpfs /tmp/test-mount && mount | grep test-mount"
# Output: test-tmpfs on /tmp/test-mount type tmpfs (rw,...)
# Looks like it worked!

# 2. Check from ANOTHER debug session
oc debug node/worker-1 -- chroot /host sh -c "mount | grep test-mount"
# Output: (empty)
# The mount was only in the first container's namespace

Common Issues

”But the mount command didn’t show an error!”

Correct β€” mount succeeded. It mounted the filesystem in the container’s mount namespace. There’s no error because technically it worked. It just didn’t mount where you expected (the host).

”It worked once and then stopped”

You may have been checking in the same debug session where you mounted. The moment that session ended, the mount disappeared.

”I added it to /etc/fstab via oc debug”

Writing to /etc/fstab via chroot /host does modify the host file. But:

  • The mount still won’t happen until reboot
  • MachineConfig may overwrite /etc/fstab on next render
  • Systemd mount units are the proper way on RHCOS

Best Practices

  • Use MachineConfig for any persistent host changes β€” mounts, kernel params, systemd units
  • Use oc debug only for read-only diagnostics β€” checking logs, listing mounts, testing connectivity
  • Never rely on oc debug for state changes β€” anything written or mounted is ephemeral
  • Use nsenter -t 1 -m only for emergency one-time debugging β€” not production
  • Document the limitation for your team β€” this catches even experienced engineers

Key Takeaways

  • oc debug node + chroot /host + mount = mount in container namespace, not host
  • Mounts vanish when the debug pod exits β€” by design, not a bug
  • MachineConfig with systemd mount units is the only supported persistent mount method
  • nsenter -t 1 -m can reach the host namespace but doesn’t survive reboots
  • This affects ALL mount types: NFS, tmpfs, bind mounts, etc.
  • Red Hat considers this expected behavior β€” it’s a security feature, not a limitation
#openshift #oc-debug #mount #troubleshooting #namespace #machineconfig
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens