젠투에 USB 스틱 자동 마운트

젠투에 USB 스틱 자동 마운트

간단한 Genoo 설치를 설치하고 두 명의 사용자와 게스트 계정을 활성화했습니다. 사용자 읽기 및 쓰기 권한이 있는 모든 계정에 USB 스틱을 삽입하면 자동으로 마운트하고 싶습니다.

가장 좋은 접근 방식은 무엇입니까? 나는 시스템의 수퍼유저이며 시스템 파일을 설치하거나 수정할 수 있습니다. 많은 파일을 수정하지 않고도 할 수 있는 간단한 솔루션을 찾고 있습니다.

답변1

좋은 시간 보내세요젠투 하우투 udev를 사용한 완전 자동 USB 설치
다른 방법 - 설명된 대로 udev 규칙에 몇 가지 규칙을 추가합니다.여기

일반적으로 /etc/udev/rules.d/다음 내용을 포함하는 파일(이름을 "10-flash-mounts.rules"로 지정)을 생성해야 합니다.

#!/bin/sh  
# start at sdb to ignore the system hard drive  
KERNEL!="sd[b-z]*", GOTO="exit"  
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="exit"  

# import some useful filesystem info as variables  
IMPORT{program}="/sbin/blkid -o udev -p %N"  

# get the label if present, otherwise assign one based on device/partition  
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"  
ENV{ID_FS_LABEL}=="", ENV{dir_name}="flash_drive_%k"  

# create the dir in /media and symlink it to /mnt  
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"  

# global mount options  
#ACTION=="add", ENV{mount_options}="relatime"  

# filesystem-specific mount options (777/666 dir/file perms for vfat) 
ACTION=="add",ENV{mount_options_vfat}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users"

# add device to /etc/fstab  
#ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} vfat %E{mount_options_vfat} 0 0' /etc/fstab"  

# mount device  
ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/mount -t auto -o %E{mount_options_vfat} /dev/%k '/media/%E{dir_name}'"  

# clean up after device removal  
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"  
ACTION=="remove", ENV{ID_FS_TYPE}!="", RUN+="/bin/sed -i '/\/dev\/%k /d' /etc/fstab"  

# exit  
LABEL="exit"

관련 정보