nsenter
nsenter copied to clipboard
nsenter: cannot open /proc/1/ns/cgroup: No such file or directory
Hi,
I am getting nsenter: cannot open /proc/1/ns/cgroup: No such file or directory
when following your steps.
Any idea why?
wsl?
Yes, same issue with WSL. My WSL Kali doesn't start anymore, with this error: nsenter: cannot open /proc/20/ns/time: No such file or directory
Any idea as to why?
I had a similar issue, I need the nsenter solution so I can inspect blockdevices on the k8s node.
Trying this on a recent kubernetes version on EKS, error message:
nsenter: cannot open /proc/1/ns/time: No such file or directory
Not exactly sure why it happens, but probably related to time namespaces not being available in the host kernel (https://man7.org/linux/man-pages/man1/nsenter.1.html).
So the script runs this command: "/nsenter", "--all", "--target=1", "--", "su", "-"
This is actually shorthand for: "/nsenter", "-m", "-u", "-i", "-n", "-p", "-C", "-U", "-T", "-r", "-w", "--target=1", "--", "su", "-"
The error above is caused the -T
option, remove it if your kernel apparently does not support time namespaces (https://www.man7.org/linux/man-pages/man7/time_namespaces.7.html); not needed in my case anyway.
In my case, this triggered the next error:
nsenter: reassociate to namespace 'ns/user' failed: Invalid argument
This error is caused by -U
(https://www.man7.org/linux/man-pages/man7/user_namespaces.7.html). Remove the option to get rid of the error and get a shell on the k8s node (at least in my case).
The -U
is also probably not needed, as we're running a privileged pod, and nsenter drops to UID 0 and GID 0 by default (if I read the manpage correctly), and I'm able to run fdisk -l
and lsblk
as needed.
Edit: for the original issue (nsenter: cannot open /proc/1/ns/cgroup: No such file or directory
), you would need to drop the option -C
, probably because your host kernel does not support cgroup namespaces. I read somewhere that the default kernel on CentOS might not have it built in by default.
wsl --shutdown
wsl
Fixed the problem for me.
I had a similar issue, I need the nsenter solution so I can inspect blockdevices on the k8s node.
Trying this on a recent kubernetes version on EKS, error message:
nsenter: cannot open /proc/1/ns/time: No such file or directory
Not exactly sure why it happens, but probably related to time namespaces not being available in the host kernel (https://man7.org/linux/man-pages/man1/nsenter.1.html).
So the script runs this command:
"/nsenter", "--all", "--target=1", "--", "su", "-"
This is actually shorthand for:
"/nsenter", "-m", "-u", "-i", "-n", "-p", "-C", "-U", "-T", "-r", "-w", "--target=1", "--", "su", "-"
The error above is caused the
-T
option, remove it if your kernel apparently does not support time namespaces (https://www.man7.org/linux/man-pages/man7/time_namespaces.7.html); not needed in my case anyway.In my case, this triggered the next error:
nsenter: reassociate to namespace 'ns/user' failed: Invalid argument
This error is caused by
-U
(https://www.man7.org/linux/man-pages/man7/user_namespaces.7.html). Remove the option to get rid of the error and get a shell on the k8s node (at least in my case).The
-U
is also probably not needed, as we're running a privileged pod, and nsenter drops to UID 0 and GID 0 by default (if I read the manpage correctly), and I'm able to runfdisk -l
andlsblk
as needed.Edit: for the original issue (
nsenter: cannot open /proc/1/ns/cgroup: No such file or directory
), you would need to drop the option-C
, probably because your host kernel does not support cgroup namespaces. I read somewhere that the default kernel on CentOS might not have it built in by default.
so i have the same issue "nsenter: cannot open /proc/30/ns/time: No such file or directory" . I do not want to reinstall kali wsl image. So how can we fix it without reinstalling?