Not a severe issue because it can be fixed with a reboot, but I'm curious to know whether there's a way to restore files (probably not all, but as many as possible) in /proc, /sys, /dev/pts and /dev.

I deleted them partially when removing a chroot directory with those directories mounted with

mount -t proc proc [path/to/chroot]/proc
mount -t sysfs sys [path/to/chroot]/sys
mount --bind /dev/[path/to/chroot]/dev
mount -t devpts /dev/path [path/to/chroot]/dev/pts

on Ubuntu 16.10 amd64. The removal failed for some files (I didn't record the error message) because removal of files was refused which I can understand. I guess that solutions will apply to all Debian-based systems.

After quitting the chroot I'm seeing things like

$ ls -bash: /dev/null: Keine Berechtigung
bash: _upvars: `-a2': invalid number specifier
-bash: /dev/null: Keine Berechtigung
bash: _upvars: `-a0': invalid number specifier

during autocompletion with Tab on ls (after exporting LANGUAGE=en).

1 Answer 1


You can't actually delete most files from /proc or /sys. They are interfaces to the kernel, not things stored on a disk, and most kernel interfaces are whatever the kernel wants to provide and cannot be influenced by userland.

Beware that exceptions are possible — it's unusual, but possible for a driver to assign a meaning to the removal of a file from a kernel filesystem. This is infamously the case of evivarfs, which is typically mounted under /sys/firmware/efi/efivars on systems that have UEFI. Removing files there can brick your computer by removing its boot configuration. And systemd used to mount it read-write

To restore the in-kernel filesystems themselves, you just remount them. In fact, rm -rf /proc /sys wouldn't have removed them, because most of these files simply can't be removed, and the mount points can't be removed as long as something is mounted on them. But if you've somehow gotten into a state where /proc and /sys no longer exist, you can re-create the directories and mount them.

mkdir /proc /sys
mount -t proc proc /proc
mount -t sys sysfs /sys

Of course you'll need a root shell. You may still be able to log in as root without /proc and /sys, but probably not without /dev.

As for /dev, it's normally populated by udev. You can tell udev to re-populate it.

mkdir /dev
mount -t devtmpfs -o mode=0755 udev /dev
mount -t devpts devpts /dev/pts
udevadm trigger
  • 1
    Good explanation, thank you. I made it a bit more clear that the removal was only partial, i.e. the rm command never got to delete any of the mounted roots /proc, /sys, etc. I added -o remount to you mount commands, but that didn't help (I added an example what doesn't work). After the commands I'm getting sudo: no tty present and no askpass program specified, so I guess a reboot is inevitable. Commented Feb 13, 2017 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .