Can you run a program in one Linux partition from another Linux partition?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can you run a program in one Linux partition from another Linux partition?
OK, I'm probably crazy for even asking, but I will in case there is some small chance this is possible: if I have say Linux Distro1 installed on a partition, and Linux Distro2 installed on another partition, is it possible to run a program on Distro2 that is intalled in Distro1?
It seems like it might be conceivable if I somehow set up the environmental variables correctly so that the program, when it looks for directories for instance, it goes to /mnt/distro1/ as the root directory instead of / in distro2. But that may just be the tip of the iceberg. Yes, maybe it's a ludicrous idea, but I ask because otherwise I have to download and install ALL the same programs, libraries, etc in Distro2 as I have in Distro1. Would be great if I could somehow share them!
if I have say Linux Distro1 installed on a partition, and Linux Distro2 installed on another partition, is it possible to run a program on Distro2 that is intalled in Distro1?
Yes, it is possible. Mount the second partition and give the full pathname to the program you want to execute.
Yes, it is possible. Mount the second partition and give the full pathname to the program you want to execute.
---------------------
Steve Stites
Thanks, Steve, but when I run the command in Distro2 with full path to the Distro1 mounted partition, Distro2 complains I don't have the necessary libraries installed (which are installed in Distro1). Is there a way to make the command run totally in Distro1's environment, i.e. so it finds the necessary libraries?
Look up the CHROOT command. That should accomplish what you are looking for
You would CHROOT (CHange ROOT) into the other distro, effectively 'moving' into that filesystem as the root filesystem, and then run the command or application you want to use.
Sasha
Last edited by GrapefruiTgirl; 05-10-2008 at 08:44 PM.
Reason: typo
But as an example, for clarity, I once (OK, more than once ) borked my Slackware install a little bit (let's call it distro2 in this context) by screwing up my shared libraries, but I had another working Linux installed on a different partition (Distro1).
I wanted to use Distro2's Midnight Commander to fix some stuff on Distro2, but Distro2's mc wouldn't run. Not much *would* run at the time. But, I could mount stuff, and I could chroot; so I mounted the Distro1 partition, chrooted into it, and ran the Midnight Commander of Distro1, which I then used to navigate around and fix stuff in Distro2.
When all done, I exited the chroot, rebooted Distro2, and.. Happiness reigned
Sasha
Also, an idea (untested, so try at own risk): couldn't one add the [library?] path of the second distro, to the beginning of the [library?] path of the first distro (and maybe run ldconfig?), and then simply run the desired application using an /absolute/path/to/it, as suggested earlier? Not sure if this would work, just an idea...
Last edited by GrapefruiTgirl; 05-10-2008 at 09:43 PM.
Look up the CHROOT command. That should accomplish what you are looking for
You would CHROOT (CHange ROOT) into the other distro, effectively 'moving' into that filesystem as the root filesystem, and then run the command or application you want to use.
Sasha
Thanks for the idea, but it doesn't quite work, at least not for the programs I tried. For instance, one program returned:
Code:
Error: Unable to initialize gtk, is DISPLAY set properly?
And yet $DISPLAY was :0.0, which is what it is when I run it OK in my other distro. Could part of the problem be that distro1 is set up primarily for Gnome, while I'm using KDE in distro2?
Another program, Amarok, returned:
Code:
: cannot connect to X server :0.0
And Audacity returned:
Code:
Gtk-WARNING **: cannot open display: :0.0
So it looks like my problem at the moment is getting the display set correctly, but there could be more problems.
Maybe a long shot, but you could try telling it to run on another display. The default display is 0:0 when running a normal single instance of X. By following a command with -- :1 you can tell the program to start on display 0:1. This may however, if it works, start the application on another screen that is not part of your running desktop session, making interaction with it rather difficult.. If the application is something you want to use to do a task, then quit (like in my Midnight Commander example), it may be OK; but for something Like Amarok, which I presume you will want to interact with and have running in the background, this probably isn't a useful solution.
As an example (which works for sure) so you can get the idea, open a console window and type startx -- :1
and the display should switch to a new X session and start up a new instance of X. When done, just exit or log out as usual, and you will be returned to your original session (or hit CTRL-ALT-F7 to switch back while leaving the new session running).
Note that I am uncertain whether this will help with the GTK errors, but in the case of the error Amarok returned to you, it *might* work.. Maybe chrooting, then running the application with the "-- :1" switch will provide interesting results. Again, I haven't tried it, but there's nothing to lose..
Ultimately, as someone mentioned earlier (and which I agree with) the obvious solution is to simply install the apps you want, into the distro you want them to run in. There are certain tools and commands that I ALWAYS want to have access to, so they are always the first things I install into a new installation if they are not already present.
Another workaround, which is again much more trouble than it's worth, would be to compile a static version of the application (as opposed to one that uses shared libraries) thereby including the usually external parts (like GTK) into the app itself. I *guess* this would solve the GTK problem. Again, I haven't tried this either (I generally build with shared libs) but if you do, let us know what you learn.
PS - Part of the problem could indeed be the difference between Gnome and KDE. A Gnome install uses GTK, while KDE is build against Qt. This doesn't mean that you can't install GTK on the KDE system, or install Qt on the Gnome system if it is not present, but just that by default, the respective packages may not be present. But, I was hoping that by chrooting, the application would be able to use the graphical toolkit of the distro you chrooted into; maybe the stuff I mentioned about editing the library path would solve this issue, but really, for what its worth, I wouldn't bother. Too much hassle, and possibly introducing the chance of very weird shared library problems.
SVA
Last edited by GrapefruiTgirl; 05-11-2008 at 09:18 PM.
Reason: more info, ideas.. Maybe a typo somewhere..
Thanks Sasha, for the additional ideas, but I think it is getting a little too messy/complex at this point to keep fiddling with. I think I'll just have to resign myself to installing all the same apps that I want. I appreciate your help though.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.