Paul Rooney
Paul Rooney

Reputation: 21619

Creating a symbolic link for use by another Linux instance

I am using linux to develop an embedded application. I have a HOST linux distro (fedora) and a TARGET linux distro (not sure what it is but it doesnt matter).

The TARGET file system is a folder in the HOST file system. So for example the TARGET boots via nfs from /home/paul/target/rootfs on the HOST filesystem, inside which is the usual linux file structure.

I am adding a daemon program to the TARGET. I am cross compiling it on the HOST and using a make target (make install) to copy files into the TARGET file system and set up the daemon to run. I copy

It is the later of these that is giving me problems. In order to auto start on boot I need to create symlinks in the TARGET fs at /etc/rc.d/rc0.d through to rc6.d, which point to my start up script /etc/rc.d/init/d/mdns.

The problem is I need to create these symlinks on the HOST machine but for use by the TARGET. So they cannot point to the full path as seen by the HOST machine, they need to point to the path as seen when the TARGET runs.

So for example

I need to create a symlink in /home/paul/target/rootfs/etc/rc0.d but the symlink needs to be called K16mdns and point to /etc/init.d/mdns not /home/paul/target/rootfs/etc/init.d/mdns

How can I use the ln command to do this? I need to specify 3 things to ln (besides the -s flag):- The links file name, the target of the link and the directory to create the link in. I dont see this combination in the ln man page.

It always seems to end up either mucking up the /etc/rc.d directories on the HOST or creating symlinks in the TARGET fs using paths only relevant to the HOST which obviously fail (The TARGET doesnt have the path /home/paul/target/rootfs/etc/init.d/mdns).

When I create the symlinks manually on the TARGETs command line it all works great but clearly this isnt a practical solution.

Thank you in advance.

Upvotes: 3

Views: 3196

Answers (1)

Stephane Rouberol
Stephane Rouberol

Reputation: 4384

You should use relative paths when symlinking, e.g.

cd /home/paul/target/rootfs/etc/init.d
ln -s mndns ../rc0.d/K16mdns

Upvotes: 7

Related Questions