Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

/ 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
1  
Setup a chroot. –  Zoredache Nov 3 '11 at 20:49

2 Answers 2

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

 
discard

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.