我在/etc/elasticsearch
的Ubuntu 16.04 LTS虚拟机上有一个现有目录。我还以天蓝色创建了文件共享。当挂载点是新目录时,我能够将文件共享成功挂载到VM。但是,当我尝试将文件共享装载到包含数据的现有目录/etc/elasticsearch
时,现有目录的数据将被文件共享的内容完全覆盖。这导致我丢失了/etc/elasticsearch
中先前存在的数据,而我显然不希望这样做。我希望除了/etc/elasticsearch
中的现有数据之外,还添加文件共享。
这是我尝试过的:
if [ ! -d "/etc/smbcredentials" ]; then
sudo mkdir /etc/smbcredentials
fi
if [ ! -f "/etc/smbcredentials/credentials.cred" ]; then
sudo bash -c 'echo "username=username" >> /etc/smbcredentials/credentials.cred'
sudo bash -c 'echo "password=password" >> /etc/smbcredentials/credentials.cred'
fi
sudo chmod 600 /etc/smbcredentials/credentials.cred
sudo bash -c 'echo "//pathtofileshare/analysis /etc/elasticsearch cifs nofail,vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino" >> /etc/fstab'
sudo mount -t cifs //pathtofileshare/analysis /etc/elasticsearch -o vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino
Link to file share documentation
在此先感谢您的帮助
答案 0 :(得分:1)
我不认为这是一个问题,只是Linux挂载的工作方式
http://man7.org/linux/man-pages/man8/mount.8.html
The previous contents (if any) and owner and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device.