7

I have a series of directories on Linux and each directory contains lots of files and data. The data in those directories are automatically generated, but multiple users will need to perform more analysis on that data and generate more files, change the structure, etc.

Since these data directories are very large, I don't want several people to make a copy of the original data so I'd like to make a copy of the directory and link to the original from the new one. However, I'd like any changes to be kept only in the new directory, and leave the original read only. I'd prefer not to link only specific files that I define because the data in these directories is so varied.

So I'm wondering if there is a way to create a copy of a directory by linking to the original but keeping any changed files in the new directory only.

4

2 に答える 2

23

これが私が望んでいたことであることがわかりました:

cp -al <origdir> <newdir>

ディレクトリ全体をコピーし、元のファイルへのハードリンクを作成します。元のファイルが削除されても、コピーされたファイルは引き続き存在し、その逆も同様です。これは完全に機能しますが、newdirがまだ存在していないはずです。元のファイルが読み取り専用である限り、元のディレクトリの同一の安全なコピーを作成できます。

于 2012-07-18T20:31:24.480 に答える
2

ただし、人々が変更を書き戻すことができる方法を探しているので、UnionFSはおそらくあなたが探しているものです。読み取り専用の場所と読み書き可能な場所を 1 つに結合する手段を提供します。

Unionfs では、読み取り専用ブランチと読み書き可能ブランチの任意の組み合わせ、およびファンアウト内の任意の場所でのブランチの挿入と削除が可能です。


もともと私はこれをお勧めするつもりでした(私はそれをたくさん使います):

アクセス許可が問題ではないと仮定すると (たとえば、読み取りのみが必要な場合)、それらを所定の位置にバインド マウントすることをお勧めします。

mount -B <original> <new-location>
# or
mount --bind <original> <new-location>

<new-location>フォルダーとして存在する必要があります。

于 2012-07-12T16:11:45.807 に答える