Skip navigation

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.

dreambox:/# passwd
Changing password for root.
New Password:
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
dreambox:/#

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.

9 Comments

  1. This isn’t quite correct, at least for my distro (ubuntu). the command at step 2 is:

    mount -o bind /dev /location/of/mountpoint/dev

  2. Thanks toolman for pointing out the syntax error. It is a typo mistake. “bind” should be preceded with two hyphens as shown below:

    # mount –bind /dev /mnt/newroot/dev

  3. In some system mount command does not accept “–bind” option, it accepts “-o bind” instead.

  4. Thanks for this bind option in rescue system.

    In openSuse 10.2 the “-o bind” option works.

    Rescue:~ # mount -o rw /dev/rootpartion /mnt/newroot
    Rescue:~ # mount -o bind /dev /mnt/newroot/dev

    Then

    Rescue:~ # chroot /mnt/newroot

    Then one can change root password etc.

    Rescue:/ # passwd root

  5. Thank You – if got the same problem, and you help me!!!!!

    it works fine

  6. Well it works, many thanks

  7. Thanks a lot, works great!!

  8. excellent information — exactly what I was looking for, thanks!

  9. good webstie


One Trackback/Pingback

  1. […] the passwd command. But this time I have to resolve the /dev/urandom problem, as stated above, by binding it to /mnt. Hopefully, it will fix things. Here I […]

Leave a reply to gap Cancel reply