LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to link to different install location (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-link-to-different-install-location-4175574368/)

islammanjurul 03-08-2016 08:59 PM

How to link to different install location
 
1 Attachment(s)
Hi

I want to install some application, but not on default install location, rather to another. See the attached screenshot. Look how pgsql is linked to /home/pgsql from its default /var/lib/pgsql so whenever I go to /var/lib/pgsql it points or take me to /home/pgsql.

Actually I want to install two new application, grafana and Influxdb. Instead of them installing on default location, I have added a new storage drive, mounted and created partition like /mnt/influx
So instead of them installing at default /var/lib/Influxdb I want them to be here /mnt/influx/Influxdb , so that whenever I go to /var/lib/Influxdb it will take me to /mnt/influx/Influxdb and same for grafana too to /mnt/influx/grafana . the attached screenshot I have collected, so I don't know how it was done (pointing the pgsql location to somewhere else).

I found it is done using ln command, but not sure how to and what exact parameters to use.

suicidaleggroll 03-09-2016 01:53 PM

You have two options. You can actually install it to the intended location, or you can install it to the default location and then move it and symlink it back.

Installing to the intended location is usually only possible with codes you build from source, you can pass the installation directory to the configure script.
Installing to the default location and then moving it is easy and works with anything, but it does result in slightly more "clutter" (symlinks hanging around pointing to the actual location).
Code:

# install program
mv /path/to/dir /path/to/new/dir
ln -s /path/to/new/dir /path/to/dir


islammanjurul 03-09-2016 05:12 PM

I'll check and report back to you, however one question, does symlinking cause the application not to work properly? Like if I install postgreSQL or Nginx on a different location and also the data moved there?

suicidaleggroll 03-09-2016 05:22 PM

It should behave as if it's still in the normal spot. The program still thinks it's running from the default location while the symlink transparently redirects all I/O to the actual location. Unless the program goes out of the way to check if its directory is actually a symlink (which I can't think of any reason why it would) it should be none the wiser.

BW-userx 03-09-2016 07:36 PM

The system or at least mine does, even links itself to other directories

Code:

%userx@voided 07:33:54 ~ >>$ cd /
 %userx@voided 07:34:04 / >>$ ls -la
total 60
drwxr-xr-x  17 root root  4096 Mar  7 06:13 .
drwxr-xr-x  17 root root  4096 Mar  7 06:13 ..
lrwxrwxrwx  1 root root    7 Mar  1 13:30 bin -> usr/bin
drwxr-xr-x  3 root root  4096 Mar  9 05:32 boot
drwxr-xr-x  19 root root  3460 Mar  9 06:29 dev
drwxr-xr-x  64 root root  4096 Mar  9 07:08 etc
drwxr-xr-x  5 root root  4096 Mar  1 13:04 home
lrwxrwxrwx  1 root root    7 Mar  1 13:30 lib -> usr/lib
lrwxrwxrwx  1 root root    9 Jun 15  2015 lib32 -> usr/lib32
lrwxrwxrwx  1 root root    7 Jun 15  2015 lib64 -> usr/lib
drwx------  2 root root 16384 Jun 15  2015 lost+found
drwxr-xr-x  3 root root  4096 Mar  1 15:24 media
drwxr-xr-x  2 root root  4096 Mar  1 13:04 mnt
drwxr-xr-x  7 root root  4096 Mar  8 22:44 opt
dr-xr-xr-x 199 root root    0 Mar  8 23:17 proc
drwxr-x---  17 root root  4096 Mar  9 05:23 root
drwxr-xr-x  21 root root  660 Mar  9 07:17 run
lrwxrwxrwx  1 root root    8 Mar  1 13:30 sbin -> usr/sbin
dr-xr-xr-x  13 root root    0 Mar  8 23:17 sys
drwxrwxrwt  7 root root  240 Mar  9 07:33 tmp
drwxr-xr-x  11 root root  4096 Mar  2 12:57 usr
drwxr-xr-x  12 root root  4096 Mar  6 03:00 var
 %userx@voided 07:34:08 / >>$

when ever I install something that needs boot up start I link it in /var/service and it works -- I've had installs from source that installed into other directories link it -- it works

this is simply what links are designed for

John VV 03-09-2016 08:02 PM

it depends a bit on WHAT it is

i build a lot of programs in a second tree
the OS is / and /usr
i install my software to
/DATA/SUSE/

if i am installing programs to /usr or /DATA/SUSE/
i add the install location to the "prefix" in configure

Code:

./configure --prefix=/DATA/SUSE
these locations ARE ALSO in the $PATH and $LD_LIBRARY_PAT and $PKG_CONFIG_PATH


All times are GMT -5. The time now is 10:31 PM.