Providing /bin and /lib Inside a Chroot Jail – Symlink Guide

chrootsymlink

I need to be able to provide the /bin and /lib directories inside a chroot jail so that programs can dynamically link properly.

Is there a way to accomplish this without making a copy of the /bin and /lib dirs to the chroot jail?

I've tried symlinks, and they don't work from inside chroot jails, and directories can not be hardlinked.

Best Answer

You could use mount to remount the directories you need in your jail:

# mount --bind /bin /chroot/bin
# mount --bind /lib /chroot/lib
# chroot /chroot

For use in /etc/fstab:

/bin /chroot/bin none bind
/lib /chroot/lib none bind

Cheers!

Related Question