Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

/ is the highest directory in Linux. Is there a way to fake that to something else say /opt/rpmbuild/BUILDROOT?

Here's my problem space. I am trying to re-package a COTS into RPM format. The COTS came in a form of binary and I need to install that first before packaging it into RPM. The install is installing it into /opt/app directory, and I want it to install it into /opt/rpmbuild/BUILDROOT/opt/app but I couldn't force that to happen.

share|improve this question
Setup a chroot. – Zoredache Nov 3 '11 at 20:49
up vote 5 down vote accepted

chroot /opt/rpmbuild/BUILDROOT can do this, but it requires that you have a working OS installed within the chroot directory.

Instead of using chroot, a simpler option would be to create a symlink from /opt/app to /opt/rpmbuild/BUILDROOT/opt/app:

mkdir -p /opt/rpmbuild/BUILDROOT/opt/app
ln -s /opt/rpmbuild/BUILDROOT/opt/app /opt/app

Then the installation will think it's working in /opt/app, but will in fact go into /opt/rpmbuild/BUILDROOT/opt/app.

share|improve this answer
Symlinks will not work if they refer a file/folder outside the root jail. Actually they will be relative to jail's root folder. You can use hardlinks or, better, bind mounts. – Mircea Vutcovici Nov 3 '11 at 21:06
Thank you for your suggestion. The key is chroot but like you said you need to have a working OS installed within the chroot directory. – Chun Tat David Chu Nov 3 '11 at 21:19
@MirceaVutcovici: I think I wasn't clear. I meant instead of chroot, not with it. Edited to clarify. – Andrew Schulman Nov 3 '11 at 23:19

Have a look into man chroot, this should help you.

share|improve this answer
Thank you for your suggestion. I totally forgot about the chroot command. – Chun Tat David Chu Nov 3 '11 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.