1834925 Members
2397 Online
110071 Solutions
New Discussion

can't ln file

 
peterchu
Super Advisor

can't ln file

I use HP UX 11 system ,

when I run "ln abc.txt /edp/bak" where /edp/bak is a directory , then it pop the error "ln: different file system" , I also check with /etc/fstab , both two directory ( /home and /edp are vxfs ) , could suggest what is wrong ? thx

#pwd
/home/user1
#ln abc.SPS /edp/bak
ln: different file system
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: can't ln file

I don't think hard links can span filesystems.

Try a symbolic link instead.

# ln -s abc.SPS /edp/bak/acp.SPS
Sudeesh
Respected Contributor

Re: can't ln file

Hard links can't span filesystems. Because hard links share inodes with each other, they must exist in the same file system. Inodes are part of a file system, defined when a file system is created. This is not true of symbolic links, which can refer to a file anywhere on a system since they only store the pathname to the referenced file.

Create soft link using ln -s.


Sudeesh

The most predictable thing in life is its unpredictability
Naveej.K.A
Honored Contributor

Re: can't ln file

Hi,

Apart from hardlink not able to span filesystems, a hard link can not be created for a directory as well.

Create a soft link with the -s option as Patrick have suggested.

Regards,
--Naveej
practice makes a man perfect!!!
Suraj Singh_1
Trusted Contributor

Re: can't ln file

Hi,

Your problem is that
i) You are trying to link a file to a directory, and
ii) the directory you are trying to link is on a filesystem other than the one where you are trying to create the file.

For both these situations you need to create a symbolic link, instead of Hard-link.

Your command should look like "ln -s abc.txt /edp/bak"

To know more about hard links and synbolic links, you can read the man pages of ln, as well as you may search the web.

Regards
What we cannot speak about we must pass over in silence.
Bill Hassell
Honored Contributor

Re: can't ln file

When you create a link, (hardlink or symbolic link) the destination or target must be a non-existant name. Since /edb/bak is a directory, the link will command will fail. If you specify /edp/bak/abc.link, then you'll get the error message:

ln: different file system

Now changing to a symbolic link:

# ln -s abc.SPS /edp/bak/abc.link

will work but not produce what you want. The reason is that abc.SPS is a simple filename and the link stores exactly that string--no more. So if you are not in the correct directory, the file cannot be found.

All symbolic links should have a fullpath for the source as in:

# ln -s /mydir/mysubdir/abc.SPS /edp/bak/abc.link


Bill Hassell, sysadmin