# Linux – restore /dev after rming it

devgentoolinuxrmudev

during a gentoo install from the livedvd, there's one step to create a dev dir to be used later in the chroot of the target for the instalation

it's done like that

mount --rbind /dev /mnt/gentoo/dev


in the middle of the installation i decided to start over… so i just did

rm -fr /mnt/gentoo/*


thinking nothing of it ("will just unpack the stage3 tar ball again") i deleted most of the device files from my actual /dev since the ones in the chroot would be just binded to the real devices.

now, the easy solution is: reboot. i know that if I reboot they will be there again. But this is a livedvd with no persistence. So if I reboot i will lose ~1h of preparation with firmwares and whatnot,

for now i will reboot. But i'd like to learn how to restore a /dev if a case like this does happen again (and because now i need to know even if i will never use it again)

update:
just remembered about LFS. reading the linux from scratch docs, i think the simplest fix is to call

 /etc/init.d/udev restart


most of the files seems to be there now.

2014 update: Latest udev versions do not create device nodes at all, and rely on the kernel's devtmpfs to do so. The old answer will therefore stop working if your distribution has a very recent udev. With devtmpfs, the only automated method might be a reboot.

/dev is managed by udev on most Linux distros, so

udevadm trigger


should help.

Restarting udev completely will also work, but it's not necessary, and the command highly depends on distro used.

NOTE: you have to create a few items manually before that command works. /dev/{zero,null}