社内SEの話

日々起きたことの記録用

LinuxからWinodws共有フォルダに接続したらセッションが残る

↓プログラミングで副業を考えたらこちら↓

環境・構成

[Windows7] <---- [Ubuntu 18.04]

Windows7共有設定 ・AD管理下のPC

Ubuntu設定

マウント
mount -t cifs -o username=<username>,password=<password> <IPaddress/共有フォルダ> /opt/project/mount
アンマウント
umount /opt/project/mount

問題

共有フォルダからExcelをコピーしてPythonバッチ処理させる。
その後共有フォルダに処理させたExcelファイルをコピーするというバッチをGW明けから運用開始。
しかし週を明けた今日共有もとのファイルにアクセスできないという連絡が入る。
確認してみるとセッション残っており接続中のセッションが10個ある。
WindowsクライアントOSは接続同時セッション数は10に制限されているので上限にある状態。
このタイミングでバッチに問題があることが発覚。

対策

mount時に新しいセッションを作ることはでき、umountしてマウントを解除してもセッションが残ると言うことはumount側の問題かと思われる。
umountのヘルプを見てみる

umount -h  
  
Usage:  
 umount [-hV]  
 umount -a [options]  
 umount [options] <source> | <directory>  
  
Unmount filesystems.  
  
Options:  
 -a, --all               unmount all filesystems (意訳 すべてのマウントを解除する)  
 -A, --all-targets       unmount all mountpoints for the given device in the current namespace  
 -c, --no-canonicalize   don't canonicalize paths  
 -d, --detach-loop       if mounted loop device, also free this loop device  
     --fake              dry run; skip the umount(2) syscall  
 -f, --force             force unmount (in case of an unreachable NFS system)  
 -i, --internal-only     don't call the umount.<type> helpers  
 -n, --no-mtab           don't write to /etc/mtab  
 -l, --lazy              detach the filesystem now, clean up things later  
 -O, --test-opts <list>  limit the set of filesystems (use with -a)  
 -R, --recursive         recursively unmount a target with all its children  
 -r, --read-only         in case unmounting fails, try to remount read-only  
 -t, --types <list>      limit the set of filesystem types  
 -v, --verbose           say what is being done  
 -h, --help              display this help  
 -V, --version           display version  

オプションは別にしてunmountの引数がソースになっているので今回の場合は
umount /opt/project/mount
ではなく
umount <IPaddress/共有フォルダ>
でなくてはいけない
対策後のコマンドで実行してみるとセッションは無事解除された。

コマンド作成時にどこかで勘違いしたんだろう

後困った人用に意訳を時間があれば更新します。