Microsoft MVP성태의 닷넷 이야기
Linux: 67. WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제 [링크 복사], [링크+제목 복사],
조회: 14086
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

(시리즈 글이 11개 있습니다.)
개발 환경 구성: 303. Windows 10 Bash Shell - 한글 환경을 영문으로 바꾸고 싶다면?
; https://www.sysnet.pe.kr/2/0/11058

개발 환경 구성: 554. WSL 인스턴스 export/import 방법 및 단축 아이콘 설정 방법
; https://www.sysnet.pe.kr/2/0/12569

개발 환경 구성: 556. WSL 인스턴스 초기 설정 명령어
; https://www.sysnet.pe.kr/2/0/12573

개발 환경 구성: 581. Windows에서 WSL로 파일 복사 시 root 소유권으로 적용되는 문제
; https://www.sysnet.pe.kr/2/0/12718

Linux: 46. WSL 환경에서 find 명령을 사용해 파일을 찾는 방법
; https://www.sysnet.pe.kr/2/0/12864

개발 환경 구성: 617. 윈도우 WSL 환경에서 같은 종류의 리눅스를 다중으로 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12878

개발 환경 구성: 619. Windows Server에서 WSL을 위한 리눅스 배포본을 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12882

Linux: 47. WSL - shell script에서 설정한 환경 변수가 스크립트 실행 후 반영되지 않는 문제
; https://www.sysnet.pe.kr/2/0/12918

Windows: 207. Windows Server 2022에 도입된 WSL 2
; https://www.sysnet.pe.kr/2/0/13073

개발 환경 구성: 694. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법
; https://www.sysnet.pe.kr/2/0/13484

Linux: 67. WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제
; https://www.sysnet.pe.kr/2/0/13503




WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제

mlocate 도구를 설치하면,

$ sudo apt install mlocate
Reading package lists... Done
...[생략]...
Initializing mlocate database; this may take some time...
Progress: [ 60%] [################################################################............................................]

WSL 환경의 경우 위와 같이 일정 수준의 진도에서 한참 동안 멈춰있을 것입니다. 왜냐하면, 윈도우의 C, D 드라이브 등에 매핑된 /mnt 디렉터리로 인해 인덱싱 시간이 오래 걸리기 때문인데요, 게다가 그 이후 검색에서도 원치 않게 /mnt 디렉터리를 포함한 결과를 출력하는 문제가 있습니다.

따라서, (find 명령에서 /mnt를 제외한 것처럼) mlocate에게 /mnt를 제외해야 하는데요, 이에 대해서는 /etc/updatedb.conf 파일을 직접 편집하면 됩니다.

$ cat /etc/updatedb.conf
PRUNE_BIND_MOUNTS="yes"
£ PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /home/.ecryptfs /var/lib/schroot"
PRUNEFS="NFS afs autofs binfmt_misc ceph cgroup cgroup2 cifs coda configfs curlftpfs debugfs devfs devpts devtmpfs ecryptfs ftpfs fuse.ceph fuse.cryfs fuse.encfs fuse.glusterfs fuse.gvfsd-fuse fuse.mfs fuse.rozofs fuse.sshfs fusectl fusesmb hugetlbfs iso9660 lustre lustre_lite mfs mqueue ncpfs nfs nfs4 ocfs ocfs2 proc pstore rpc_pipefs securityfs shfs smbfs sysfs tmpfs tracefs udev udf usbfs"

이 파일에서 PRUNEPATHS에 다음과 같이 /mnt를 추가해 줍니다.

PRUNEPATHS="/mnt /tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /home/.ecryptfs /var/lib/schroot"

이후 변경 사항을 반영하기 위해 updatedb를 관리자 권한으로 재실행합니다.

$ updatedb
updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'

$ sudo updatedb




그런데, 달리 생각해 보면 locate의 /mnt 검색을 그냥 또 다른 윈도우 명령어 Shell의 기능처럼 받아들일 수도 있습니다. 인덱싱 크기도,

// /mnt 포함했을 때,

$ ls -l /var/lib/mlocate/mlocate.db
-rw-r----- 1 root mlocate 187268412 Dec 27 14:00 /var/lib/mlocate/mlocate.db

// /mnt 제외했을 때,

$ ls -l /var/lib/mlocate/mlocate.db
-rw-r----- 1 root mlocate 5681370 Dec 26 19:27 /var/lib/mlocate/mlocate.db

미포함했을 때의 5MB에 비해 180MB 정도로 크긴 하지만 그래도 뭐 저 정도면 요즘 시대의 외장 스토리지에서는 크게 부담스러운 수준은 아닙니다.

참고로, updatedb 명령의 인자를 보면 --add-prunepaths 옵션이 있는데요,

$ sudo updatedb --add-prunepaths "/mnt"

직관적으로는 저 명령어가 /etc/updatedb.conf에 /mnt 예외를 추가할 것처럼 느껴지겠지만, 실제로 하는 일은 /var/lib/mlocate/mlocate.db 인덱스 파일에서 /mnt 경로에 대한 인덱싱을 제거하는 역할만 합니다. (따라서 conf 파일의 변경이 없으므로 이런 경우에는 "sudo udpatedb" 명령어를 내려 다시 인덱싱을 하면 add-prunepaths 옵션 전의 상황으로 바뀝니다.)




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 12/27/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
11928정성태6/5/201922772오류 유형: 543. PowerShell 확장 설치 시 "Catalog file '[...].cat' is not found in the contents of the module" 오류 발생
11927정성태6/5/201923909스크립트: 15. PowerShell ISE의 스크립트를 복사 후 PPT/Word에 붙여 넣으면 한글이 깨지는 문제 [1]
11926정성태6/4/201922863오류 유형: 542. Visual Studio - pointer to incomplete class type is not allowed
11925정성태6/4/201924383VC++: 131. Visual C++ - uuid 확장 속성과 __uuidof 확장 연산자파일 다운로드1
11924정성태5/30/201926002Math: 57. C# - 해석학적 방법을 이용한 최소 자승법 [1]파일 다운로드1
11923정성태5/30/201925368Math: 56. C# - 그래프 그리기로 알아보는 경사 하강법의 최소/최댓값 구하기파일 다운로드1
11922정성태5/29/201922494.NET Framework: 840. ML.NET 데이터 정규화파일 다운로드1
11921정성태5/28/201929966Math: 55. C# - 다항식을 위한 최소 자승법(Least Squares Method)파일 다운로드1
11920정성태5/28/201918186.NET Framework: 839. C# - PLplot 색상 제어
11919정성태5/27/201924875Math: 54. C# - 최소 자승법의 1차 함수에 대한 매개변수를 단순 for 문으로 구하는 방법 [1]파일 다운로드1
11918정성태5/25/201923925Math: 53. C# - 행렬식을 이용한 최소 자승법(LSM: Least Square Method)파일 다운로드1
11917정성태5/24/201925546Math: 52. MathNet을 이용한 간단한 통계 정보 처리 - 분산/표준편차파일 다운로드1
11916정성태5/24/201923923Math: 51. MathNET + OxyPlot을 이용한 간단한 통계 정보 처리 - Histogram파일 다운로드1
11915정성태5/24/201928111Linux: 11. 리눅스의 환경 변수 관련 함수 정리 - putenv, setenv, unsetenv
11914정성태5/24/201926810Linux: 10. 윈도우의 GetTickCount와 리눅스의 clock_gettime파일 다운로드1
11913정성태5/23/201921328.NET Framework: 838. C# - 숫자형 타입의 bit(2진) 문자열, 16진수 문자열 구하는 방법파일 다운로드1
11912정성태5/23/201922338VS.NET IDE: 137. Visual Studio 2019 버전 16.1부터 리눅스 C/C++ 프로젝트에 추가된 WSL 지원
11911정성태5/23/201921754VS.NET IDE: 136. Visual Studio 2019 - 리눅스 C/C++ 프로젝트에 인텔리센스가 동작하지 않는 경우
11910정성태5/23/201930517Math: 50. C# - MathNet.Numerics의 Matrix(행렬) 연산 [1]파일 다운로드1
11909정성태5/22/201926318.NET Framework: 837. C# - PLplot 사용 예제 [1]파일 다운로드1
11908정성태5/22/201924886.NET Framework: 836. C# - Python range 함수 구현파일 다운로드1
11907정성태5/22/201920324오류 유형: 541. msbuild - MSB4024 The imported project file "...targets" could not be loaded
11906정성태5/21/201920866.NET Framework: 835. .NET Core/C# - 리눅스 syslog에 로그 남기는 방법
11905정성태5/21/201921165.NET Framework: 834. C# - 폴더 경로 문자열에서 "..", "." 표기를 고려한 최종 문자열을 얻는 방법 - 두 번째 이야기
11904정성태5/21/201931086.NET Framework: 833. C# - Open Hardware Monitor를 이용한 CPU 온도 정보 [1]파일 다운로드1
11903정성태5/21/201924624오류 유형: 540. .NET Core - System.PlatformNotSupportedException: The named version of this synchronization primitive is not supported on this platform.
... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...