一、掛載 smb
Step 1: Install the CIFS Utils pkg
`sudo apt-get install cifs-utils`
Step 2: Create a mount point
sudo mkdir /mnt/<local_share>
Step 3: Mount the volume
sudo mount -t cifs -o username=<your NAS username> //<vpsa_ip_address>/<export_share> /mnt/<local_share>
二、取消掛載 smb
sudo umount /mnt/<local_share>
三、解決類似umount target is busy掛載盤卸載不掉問題
但是取消掛載報錯:
問題原因:
該報錯通常是由於待卸載磁盤正在使用,導致無法直接卸載。需要將當前使用數據盤的進程殺掉,才能卸載。
解決辦法
方法一、 使用fuser命令處理
安裝fuser命令
[root@server-10 ~]# yum install psmisc
查看在使用的進程
[root@server-10 ~]# fuser -mv /mnt/ USER PID ACCESS COMMAND /mnt: root kernel mount /mnt root 13830 ..c.. bash
殺死占用的進程
[root@server-10 ~]# kill -9 13830
發現 bash 退出了,新開shell並再次查看
[root@server-10 ~]# fuser -mv /mnt/ USER PID ACCESS COMMAND /mnt: root kernel mount /mnt
確認無進程連接后,使用卸載命令
[root@server-10 ~]# umount /mnt/ [root@server-10 ~]#
參數說明:
-k,--kill kill processes accessing the named file
-m,--mount show all processes using the named filesystems or block device
-v,--verbose verbose output
注意:
可以使用 fuser -km /mnt 進行 kill 進程, 可能會結束當前bash進程
可以使用 kill 命令殺掉查到對應的進程 。
強制 kill 進程可能會導致數據丟失,請確保數據得到有效備份后,再進行相關操作。
方法二、通過lsof命令處理
https://www.cnblogs.com/peida/archive/2013/02/26/2932972.html
lsof(list open files)是一個列出當前系統打開文件的工具。在linux環境下,任何事物都以文件的形式存在,通過文件不僅僅可以訪問常規數據,還可以訪問網絡連接和硬件。
[root@server-10 ~]# lsof /mnt/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME bash 16302 root cwd DIR 8,17 50 64 /mnt
找到PID對應的進程或者服務,然后殺死或者停止相應服務即可。
方法三、重啟系統(方法二報錯了,方法三簡單粗暴,成功了)
https://www.php.cn/linux-417358.html
重啟后掛載自動解除
sudo shutdown -r now