nsenter icon indicating copy to clipboard operation
nsenter copied to clipboard

nsenter: cannot open /proc/1/ns/cgroup: No such file or directory

Open fabianbaier opened this issue 5 years ago • 5 comments

Hi,

I am getting nsenter: cannot open /proc/1/ns/cgroup: No such file or directory when following your steps.

Any idea why?

fabianbaier avatar Sep 17 '19 21:09 fabianbaier

wsl?

wangdehu avatar Mar 26 '20 16:03 wangdehu

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?

lweingart avatar Dec 02 '20 16:12 lweingart

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.

ewoutvonk avatar Dec 03 '20 16:12 ewoutvonk

wsl --shutdown
wsl

Fixed the problem for me.

bobbbay avatar May 26 '21 14:05 bobbbay

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.

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?

5l1v3r1 avatar Aug 10 '21 18:08 5l1v3r1