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.
π‘ Quick Answer:
oc debug noderuns in a temporary container with its own mount namespace. Anymountcommand 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:#fffThe 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
| Method | Persists? | 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.targetThis 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/nfsThis 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 namespaceCommon 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/fstabon 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 debugonly for read-only diagnostics β checking logs, listing mounts, testing connectivity - Never rely on
oc debugfor state changes β anything written or mounted is ephemeral - Use
nsenter -t 1 -monly 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 -mcan 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

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses β