搭建好 samba 之后,每次开机都要手动把 nas 文件夹手动挂载到本地,找一个自动挂载的方法。
创建密码文件
1 2
| sudo mkdir /etc/samba/credentials sudo vim /etc/samba/credentials/self
|
内容如下
1 2
| username=root password=123456789
|
编写挂载文件
假设要挂载的位置是/home/bubao/Samba/self
,那么则创建一个文件名为home-bubao-Samba-self.mount
,编辑home-bubao-Samba-self.mount
1 2 3 4 5 6 7 8 9 10 11 12 13
| [Unit] Description=Mount nas.Self at boot
[Mount] What=//10.0.0.3/self where=/home/bubao/Samba/self Options=x-systemd.automount,credentials=/etc/samba/credentials/self,iocharset=utf8,uid=1000,gid=1000,sec=ntlmssp,rw Type=cifs TimeoutSec=30 ForceUnmount=true
[Install] WantedBy=multi-user.target
|
启动
1 2
| sudo systemctl enable home-bubao-Samba-self.mount sudo systemctl start home-bubao-Samba-self.mount
|