In a web project I used symlinks for shared data to save up space. The structure is one directory including the original data (e.g. css and js) and multiple directory with symlinks to the original data. The problem is when users change settings their data is going to edit, but because they are symlinks the original data gets edited. So I am searching for a way to break the link and save the data in the place of the symlink. How can I achieve this?

Something like: when writing to file if it is symlink remove it, write the data in that path.


I need an OS level approach, because file edit occurrences are out of my control. Also is it possible with hooks?

  • Remove the symlinks and copy the files. Commented Dec 24, 2018 at 7:49
  • If you are on XFS, you might use reflink. Reference: unix.stackexchange.com/questions/393305/…
    – amdyes
    Commented Dec 24, 2018 at 8:01
  • @amdyes I'm not on XFS. can I use system calls and modify it for cp?
    – Ali Sh
    Commented Dec 24, 2018 at 8:54

1 Answer 1


You can use a COW (Copy On Write) file-system, but you wont use symlinks. You would just copy the file. (but it would not copy it, until you edit/write to it).

or use some over-lay file-system, that has this property: look at what fuse file-systems exist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .