nfs 폴더가 소프트 마운트되었는지 확인하는 명령을 찾고 있습니다. 내 fstab은 다음과 같습니다.
10.10.1.3:/home/share3 /home/share3 nfs soft 0 0
답변1
아마도 mount
(에 설명된 대로)를 사용했을 것입니다.월리네이터의 대답man mount
) 나 자신은 다음과 같은 습관에서 벗어나야 한다고 말합니다 .
The listing. The listing mode is maintained for backward compatibility only. For more robust and customizable output use findmnt(8), espe‐ cially in your scripts.
이 findmnt
명령은 좀 더 유연성을 제공합니다. 예를 들어 소스 또는 대상별로 직접 찾고(필요 없이 grep
) 파일 시스템별 옵션만 출력할 수 있습니다. 비교하다:
$ mount -t nfs | grep public
192.168.1.127:/c/public on /mnt/nfs/public type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.127,mountvers=3,mountport=3097,mountproto=udp,local_lock=none,addr=192.168.1.127)
에게
$ findmnt -nM /mnt/nfs/public -oFS-OPTIONS
rw,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.127,mountvers=3,mountport=3097,mountproto=udp,local_lock=none,addr=192.168.1.127
나는 그것이 (아직) 특정 옵션의 값을 직접 얻을 수 있는 방법을 제공하지 않는다고 생각하므로 이를 위해서는 여전히 grep
또는가 awk
필요할 것입니다.
$ findmnt -nM /mnt/nfs/public -oFS-OPTIONS | grep -qE '\bsoft\b' && echo "soft" || echo "hard"
hard
귀하의 경우에는
findmnt -nM /home/share3 -oFS-OPTIONS | grep -qE '\bsoft\b' && echo "soft" || echo "hard"
답변2
명령을 사용하여 mount
모든 마운트를 표시(또는 확인 /etc/mtab
)하고 grep
특정 마운트를 선택한 다음 다른 명령을 grep
확인하여 확인할 수 있습니다 soft
.
mount | grep /home/share3 | grep -q soft
if [[ $? -eq 0 ]] ; then
echo "/home/share3 is mounted with 'soft'"
else
echo "/home/share3 is not mounted with 'soft'"
fi