media-automount:基于 udev 和 systemd 的可移动媒体自动挂载工具项目

可用于在无 udisks2 守护进程的简单系统中自动挂载可移动媒体设备。通过 udev 规则和 systemd 服务实现,支持多种文件系统,可自定义挂载选项,避免桌面环境依赖,日志可通过 journalctl 查看。【此简介由AI生成】

Branch1Tags0
FilesLast commitLast update
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago

udev-media-automount

Auto mount removable media devices by means of udev rules.

This is intended for simple systems that don't want or can't run the udisks2 daemon (which is designed for GNOME/KDE desktop environments and at the time of this writting is frustrating to set up from a bare commandline).

This combines the previous udev rules I was using in my xdg_config repository with some structure and ideas taken from tylorchu's usb-automount.

Every device that is inserted and isn't already configured in /etc/fstab will be mounted by media-automount. This includes not only usb devices but also card readers and other media with a /dev/sd* device.

If there are devices you don't want to automount neither at boot nor with media-automount, you can add them in /etc/fstab with the option 'noauto'.

The mount options might differ to the filesystem type for the device plugged in. E.g. vFAT and NTFS devices will be mounted with the "flush" option to try to prevent damage on accidental removals of the device with unclean umounts. Also whenever ntfs-3g is available, it will be used to mount ntfs devices.

The mount directory will appear in /media/ under a name with pattern: <LABEL OF THE FS>.<FS TYPE> (if duplicate, _<NUMBER> will be appended).

Due to changes in udev (long running processes are killed), it's necessary to use systemd for spawning a mounting service.

To check the logs produced by the script, run journalctl -t media-automount, add -b for current boot.

Installation

For Archlinux, the udev-media-automount AUR package is offered.

For other systems, you may download the content of the repository from https://github.com/Ferk/udev-media-automount/archive/refs/heads/master.zip

You can then install it using the following instructions

unzip master.zip
cd udev-media-automount-master
sudo make install
sudo udevadm control --reload-rules
sudo udevadm trigger

Configuration

The folder /etc/media-automount.d can be used to set custom mount options for specific device types.

If a file with filename matching a filesystem type (eg. vfat, nfts, etc) is found, it'll be loaded when a device using the given filesystem is to be mounted. This can be used to change the parameters provided to mount.

An example below for /etc/media-automount.d/ntfs:

# Mount options to use for auto-mounting NTFS drives
AUTOMOUNT_OPTS='errors=remount-ro,relatime,utf8,user,flush'

# Always use NTFS-3G to automount NTFS filesystems
AUTOMOUNT_TYPE="ntfs-3g"

Note that these files are sourced as shell scripts, so it's possible to include logic in them in case you want to conditionally apply some configuration.

Introduction

可用于在无 udisks2 守护进程的简单系统中自动挂载可移动媒体设备。通过 udev 规则和 systemd 服务实现,支持多种文件系统,可自定义挂载选项,避免桌面环境依赖,日志可通过 journalctl 查看。【此简介由AI生成】

Customize your domain