Debian/Ubuntu Tips and Tricks


Debian/Ubuntu Tips and Tricks

How-To: Mounting /dev in a chroot environment

Posted by chantra on May 8th, 2010

When working in a chrooted environment, there is a few special file systems that needs to be mounted so all programs behave properly.

For instance, grub will need to access your disk devices....

While most special file systems might be mounted with:

# mount fstype -t fstype /tmp/chroot/mountpoint

Where fstype will be sysfs, proc, /dev is not following this rule.

In order to mirror /dev, you will need to actually bind /tmp/chroot/dev to your host system's /dev .

This can be done through the following command:

# mount --bind /dev /tmp/chroot/dev

Or to make it shorter:

# mount -B /dev /tmp/chroot/dev

Now, /tmp/chroot/dev will be populated with the same content than the host's /dev which will allow you to do a grub-update and much more within the chroot.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>