sudo nano /lib/systemd/system/systemd-udevd.service
首先,打开上面的文件,将后7行注释掉,否则udev规则会触发执行,但会返回失败。
修改后如下:
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=udev Kernel Device Manager Documentation=man:systemd-udevd.service(8) man:udev(7) DefaultDependencies=no Wants=systemd-udevd-control.socket systemd-udevd-kernel.socket After=systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-sysusers.service Before=sysinit.target ConditionPathIsReadWrite=/sys [Service] Type=notify OOMscoreAdjust=-1000 Sockets=systemd-udevd-control.socket systemd-udevd-kernel.socket Restart=always RestartSec=0 ExecStart=/lib/systemd/systemd-udevd #KillMode=mixed #WatchdogSec=3min #TasksMax=infinity #MountFlags=slave #MemoryDenyWriteExecute=yes #RestrictRealtime=yes #RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6
在/etc/udev/rules.d/目录下新建规则文件98-logcopy.rules
内容如下:
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end" # Import FS infos IMPORT{program}="/sbin/blkid -o udev -p %N" # Get a label if present, otherwise specify one ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k" # Global mount options ACTION=="add", ENV{mount_options}="relatime" # Filesystem-specific mount options ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002" # Mount the device ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}" RUN+="/bin/cp -r /opt/trash/logs /media/%E{dir_name}" # Clean up after removal ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}" # Exit LABEL="media_by_label_auto_mount_end"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。