Create file with content:
Check it content:
Create blank file, it will be mount point, it content can be any (we need only inode, right):
This file instantly blank:
echo "my important data" > /tmp/shadow
Check it content:
cat /tmp/shadow
my important data
Create blank file, it will be mount point, it content can be any (we need only inode, right):
rm -f /tmp/shadowcopy
touch /tmp/shadowcopy
This file instantly blank:
cat /tmp/shadowcopy|wc -l
0
Mount file /tmp/shadow to /tmp/shadowcopy:
mount --bind /tmp/shadow /tmp/shadowcopy
Welcome, all forks fine:
cat /tmp/shadow
my important data
cat /tmp/shadowcopy
my important data
You can add line into source file:
echo "new line" >> /tmp/shadow
And this line can be found in both files (source and mounted):
cat /tmp/shadow
my important data
new line
cat /tmp/shadowcopyIf you add any content to destination file, it will show in source. This mechanic looks like hard links.
my important data
new line
At finish you MUST unmount destination file:
umount /tmp/shadowcopy
каков use case ?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteНапример, для подмены файлов поверх read only fs.
Delete