umount-장치가 사용 중입니다 (In some

때때로 장치를 마운트 해제하려는 경우 (예 :

sudo umount /dev/loop0

나는 메시지를 얻을 것이다

umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

보통 콘솔 창을 닫으면 (이 경우에는 xfce4-terminal)이 문제를 해결합니다 umount.

이 문제는 무엇을 의미합니까? 더 똑똑한 해결책이 있습니까?



답변

일부 프로세스에는 마운트 지점 아래에 작업 디렉토리 또는 열린 파일 핸들이 있습니다. 가장 좋은 방법은 문제를 일으키는 프로세스를 종료하고 작업 디렉토리를 변경하거나 마운트 해제하기 전에 파일 핸들을 닫는 것입니다.

리눅스에는 대안이 있습니다. umount -l“게으른”마운트 해제 통화를 사용 합니다. 파일 시스템은 계속 마운트되지만 이미 사용중인 프로세스를 제외하고는 파일 시스템을 보거나 사용할 수 없습니다. 문제가있는 프로그램이 종료되면 (시스템을 통해) 파일 시스템 마운트 해제가 “완료”됩니다.


답변

fuser마운트 된 파일 시스템을 사용하여 모든 프로세스를 종료하는 데 사용할 수도 있습니다 .

fuser -cuk /mnt

옵션 :

-c
    Same as -m option, used for POSIX compatibility.

-u, --user
    Append the user name of the process owner to each PID.

-k, --kill
    Kill  processes accessing the file. Unless changed with -SIGNAL, SIGKILL is sent. An fuser process
    never kills itself, but may kill other fuser processes. The  effective  user  ID  of  the  process
    executing fuser is set to its real user ID before attempting to kill.kill.

-m NAME, --mount NAME
    NAME specifies a file on a mounted file system or a block device that is  mounted.  All  processes
    accessing  files  on  that  file  system  are  listed.   If  a  directory file is specified, it is
    automatically changed to NAME/. to use any file system that might be mounted on that directory.

에서 직접 확인 explainshell .


답변

“일반적인 해결책”이 주어지면, 콘솔 창에서 실행중인 쉘이 해당 장치의 파일 시스템에 현재 작업 디렉토리로 디렉토리가 있음을 의미합니다.

일반적으로 Linux와 Unix는 프로세스에 해당 파일 시스템에 현재 작업 디렉토리가있는 경우 파일 시스템 마운트를 유지하기를 매우 원합니다.

cd콘솔 창을 사용 하여 콘솔 창을 /mnt죽이지 않고 디렉토리 내부 또는 외부에서 디렉토리를 빠져 나갈 수 있습니다.


답변

이 질문이 매우 오래된 경우에도 답변으로 공유 할 장치 마운트 해제를 방해 할 수있는 상황을 발견했습니다.

머신에서 NFS 공유를 호스팅하고 있고 마운트 해제하려는 장치가 해당 NFS 공유를 지원하는 경우 공유를 중지해야합니다 ( sudo service nfs-kernel-server stop최신 버전의 Ubuntu에서 NFS 서비스를 중지하여 가장 잘 수행됨) ). NFS 서버가 lsof 또는 퓨저에 표시되지 않아 문제를 식별하기가 어려울 수 있습니다.


답변