As a a traditional UNIX system, Linux systems also followed the static device nodes in /dev directory. During the installation process, /dev directory is filled with most commonly used device files. But modern linux system is not so. While booting the system, the the device nodes are created for the available (only) hardware devices. This makes the /dev not cluttered too much with mostly unused nodes.
But this behaviour results in absence of /dev/<nodes> in chroot-ed environment. This will result in failure of many commands based on /dev/<nodes>. The following is an example of such failure in a chroot-ed environment. In this example, a user tries to change root passwd of chroot-ed system.
Changing password for root.
Bad password: too simple
Reenter New Password:
Cannot open /dev/urandom for reading: No such file or directory
Cannot create salt for blowfish crypt
Error: Password NOT changed.
passwd: Authentication token manipulation error
Here is how to solve this issue:
1. Mount new root partition in a directory. (e.g.): # mount /dev/hda2 /mnt/newroot
2. Bind the current /dev with would-be root. (e.g.): # mount –bind /dev /mnt/newroot/dev
3. changing the root file system. (e.g.): # chroot /mnt/newroot /bin/bash
That is it. This will be useful during rescue process of a system.