Is there anybody who knows that how to install package using yum on different directory but not in root(/) directory ?

Whenever I'm using "yum install package-name" command by default it is installing package in root(/) directory but i want to install package in different directory.

Even rpm -ivh -r /path/path package.rpm doesn't work for me. I'm getting error: open of docker-engine.rpm failed: No such file or directory

Thank you.


Yum does not appear to support that capability. See this Red Hat solution.

Yum has an --installroot option but that is intended for chroot installs and would basically create a whole new environment where dependencies must be resolved.

As for rpm, it has --relocate OLDPATH=NEWPATH and --prefix NEWPATH which will allow you to change the install path for rpms marked as relocatable which will not apply to all packages. In general, it is not considered a good idea.

Alternatively, you could obtain the source code for the rpm and rebuild it yourself with the desired path.

I see a docker error from your post which may change everything I've just said.

  • Thanks. My root (/) directory is no more supporting package installation cause of not enough disk space in root directory. I'm getting error like At least 100MB more space needed on the / filesystem. – DRules Nov 16 '16 at 1:16
  • 3
    It sounds like you may be better off investigating space issues and freeing up your disk. – MikeA Nov 16 '16 at 16:26
  • That said, I think the question is still valid for users who have other reasons for needing to install in non-root areas. For example, I found this because I need to provide different users of the system with different versions of tools, and I can't yet shift all of them over to using containers (though that is my plan). – Dan Sep 12 '19 at 14:40

In theory it might be possible to use the --installroot option to install the package in a different place. I don't think it is a good idea. The package installs files in various locations in the filesystem. So even if it is technically possible it would be a nightmare to make it work properly.

On top of that I think your issue is a different one, as already proposed try to check how to extend your root filesystem or free up some space.

  • +1. The OP doesn't need to install packages in other locations, he needs to free up some space in the root filesystem. – dr01 Jul 10 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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