2025-01-14 01:41:00 -05:00
|
|
|
# Auto-mount Service for Systems with No Desktop
|
2025-01-12 23:52:17 -05:00
|
|
|
|
2025-01-14 01:41:00 -05:00
|
|
|
**Auto-mount** uses
|
|
|
|
|
[`udisks`](https://www.freedesktop.org/wiki/Software/udisks/) to monitor and
|
|
|
|
|
respond to block-device related events, such as USB or optical drive
|
|
|
|
|
insertion/removal, partition mounting/unmounting, and more.
|
2025-01-12 23:52:17 -05:00
|
|
|
|
2025-01-14 01:41:00 -05:00
|
|
|
Out of the box, **auto-mount** will automatically mount any block device
|
|
|
|
|
containing a filesystem, when it appears in the system.
|
2025-01-12 23:52:17 -05:00
|
|
|
|
2025-01-14 01:41:00 -05:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
|
|
**Auto-mount** actions are controlled by config files, which are plain-text
|
|
|
|
|
INI-style files with `.conf` extension, consisting of section names (enclosed
|
|
|
|
|
in `[]`) followed by actions to be performed.
|
|
|
|
|
|
2025-01-14 23:15:23 -05:00
|
|
|
Config files are located in the `/etc/automount/` directory (typically) and are
|
|
|
|
|
parsed in alphabetical order. Actions in the most recent config files override
|
|
|
|
|
the ones in earlier files.
|
2025-01-14 01:41:00 -05:00
|
|
|
|
|
|
|
|
Here is an example of the default config file that comes with **auto-mount**:
|
|
|
|
|
|
|
|
|
|
```ini
|
2025-01-14 23:15:23 -05:00
|
|
|
/etc/automount/10-default.conf:
|
2025-01-14 01:41:00 -05:00
|
|
|
|
2025-01-14 15:26:12 -05:00
|
|
|
[ID_FS_USAGE=filesystem]
|
2025-01-14 01:41:00 -05:00
|
|
|
auto-mount = yes
|
|
|
|
|
```
|
|
|
|
|
|
2025-01-14 14:12:50 -05:00
|
|
|
And, here is an example of a file overriding the default action for a specific
|
|
|
|
|
drive:
|
2025-01-14 01:41:00 -05:00
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
/etc/automount/20-override.conf:
|
|
|
|
|
|
2025-01-14 15:26:12 -05:00
|
|
|
[ID_FS_UUID=E428-616E]
|
2025-01-14 01:41:00 -05:00
|
|
|
auto-mount = no
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sections and Properties
|
|
|
|
|
|
|
|
|
|
Section names consist of one or more space-delimited match conditions, which
|
|
|
|
|
can have one of the following forms:
|
|
|
|
|
|
|
|
|
|
`property=value`, `!property=value`, `property` or `!property`
|
|
|
|
|
|
|
|
|
|
The first two forms match on equality and inequality respectively, while the
|
|
|
|
|
last two match on the presence or absence of a certain property.
|
|
|
|
|
|
|
|
|
|
Values in match conditions can contain wild-card characters, such as:
|
|
|
|
|
|
|
|
|
|
`*`, `?`, `[abc]` or `[!def]`
|
|
|
|
|
|
|
|
|
|
Here is an example of a section that will match optical media containing a
|
|
|
|
|
filesystem:
|
|
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
20-optical.conf:
|
|
|
|
|
|
2025-01-14 15:26:12 -05:00
|
|
|
[ID_FS_USAGE=filesystem ID_CDROM]
|
2025-01-14 01:41:00 -05:00
|
|
|
on-unmount = /bin/eject ${DEVNAME}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
and will eject the media once it's unmounted.
|
|
|
|
|
|
|
|
|
|
Another example of a section, which will cause UDF filesystems on non-optical
|
|
|
|
|
drives to be mounted with different options:
|
|
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
20-vfat.conf:
|
|
|
|
|
|
2025-01-14 15:26:12 -05:00
|
|
|
[ID_FS_TYPE=udf !ID_TYPE=cd]
|
2025-01-14 01:41:00 -05:00
|
|
|
mount-options = uid=1000,gid=1000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
You can obtain a list of all properties for a given block device using `udevadm`:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
user@linux:~$ udevadm info -q env /dev/sr0
|
|
|
|
|
```
|
|
|
|
|
```sh
|
|
|
|
|
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/host0/target0:0:0/0:0:0:0/block/sr0
|
|
|
|
|
DEVNAME=/dev/sr0
|
|
|
|
|
DEVTYPE=disk
|
|
|
|
|
MAJOR=11
|
|
|
|
|
MINOR=0
|
|
|
|
|
SUBSYSTEM=block
|
|
|
|
|
...
|
|
|
|
|
ID_CDROM=1
|
|
|
|
|
ID_BUS=usb
|
|
|
|
|
ID_MODEL=BD-RE_BU40N
|
|
|
|
|
ID_TYPE=cd
|
|
|
|
|
ID_USB_DRIVER=usb-storage
|
|
|
|
|
...
|
|
|
|
|
ID_FS_UUID=d042881731342041
|
|
|
|
|
ID_FS_LABEL=FROM_RUSSIA_WITH_LOVE
|
|
|
|
|
ID_FS_TYPE=udf
|
|
|
|
|
ID_FS_USAGE=filesystem
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
or:
|
|
|
|
|
```sh
|
|
|
|
|
user@linux:~$ udevadm info -q env /dev/sda1
|
|
|
|
|
```
|
|
|
|
|
```sh
|
|
|
|
|
DEVPATH=/devices/pci0000:00/0000:00:0d.0/usb2/2-1/2-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
|
|
|
|
|
DEVNAME=/dev/sda1
|
|
|
|
|
DEVTYPE=partition
|
|
|
|
|
PARTN=1
|
|
|
|
|
MAJOR=8
|
|
|
|
|
MINOR=1
|
|
|
|
|
SUBSYSTEM=block
|
|
|
|
|
...
|
|
|
|
|
ID_BUS=usb
|
|
|
|
|
ID_MODEL=STORAGE_DEVICE
|
|
|
|
|
ID_TYPE=disk
|
|
|
|
|
ID_USB_DRIVER=usb-storage
|
|
|
|
|
...
|
|
|
|
|
ID_PART_TABLE_UUID=d526b372
|
|
|
|
|
ID_PART_TABLE_TYPE=dos
|
|
|
|
|
ID_FS_LABEL=TEMP
|
|
|
|
|
ID_FS_UUID=E428-616E
|
|
|
|
|
ID_FS_VERSION=FAT32
|
|
|
|
|
...
|
|
|
|
|
ID_FS_TYPE=vfat
|
|
|
|
|
ID_FS_USAGE=filesystem
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
When a block-device event occurs, **auto-mount** extracts actions from all
|
|
|
|
|
sections with matching conditions, with actions in later sections overriding
|
|
|
|
|
the ones in earlier sections.
|
|
|
|
|
|
|
|
|
|
### Actions
|
|
|
|
|
|
|
|
|
|
An action can be any of the following:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
auto-mount = yes|no
|
|
|
|
|
mount-options = ...
|
|
|
|
|
mount-as = [user][:group]
|
|
|
|
|
|
|
|
|
|
on-mount = ...
|
|
|
|
|
on-unmount = ...
|
|
|
|
|
on-add = ...
|
|
|
|
|
on-remove = ...
|
|
|
|
|
on-change = ...
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
where `...` represents a command to be executed when the action is triggered.
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
```ini
|
2025-01-14 14:12:50 -05:00
|
|
|
50-spin-down.conf:
|
|
|
|
|
|
2025-01-14 15:26:12 -05:00
|
|
|
[ID_TYPE=cd]
|
2025-01-14 01:41:00 -05:00
|
|
|
# set spin-down time to 20 minutes
|
|
|
|
|
on-add = /sbin/hdparm -S 240 ${DEVNAME}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Commands support basic variable substitution in the form `${VARIABLE}`, where
|
2025-01-14 23:15:23 -05:00
|
|
|
`VARIABLE` can be any of the device properties.
|
2025-01-14 01:41:00 -05:00
|
|
|
|
2025-01-14 23:15:23 -05:00
|
|
|
Additionally, the `on-mount` and `on-unmount` actions can use the
|
|
|
|
|
`${MOUNT_POINT}` property to determine the current mount point.
|
2025-01-14 01:41:00 -05:00
|
|
|
|
2025-01-14 23:15:23 -05:00
|
|
|
*Note: The same block device can be mounted at multiple mount points, and the
|
|
|
|
|
`on-mount` and `on-unmount` actions will be executed for each mount point.*
|
2025-01-14 01:41:00 -05:00
|
|
|
|
|
|
|
|
The `mount-options` and `mount-as` values are only applicable when
|
|
|
|
|
`auto-mount = yes`.
|
2025-01-12 23:52:17 -05:00
|
|
|
|
2025-01-14 14:12:50 -05:00
|
|
|
Share and enjoy.
|
|
|
|
|
|
2025-01-12 23:52:17 -05:00
|
|
|
## Authors
|
|
|
|
|
|
|
|
|
|
* **Dimitry Ishenko** - dimitry (dot) ishenko (at) (gee) mail (dot) com
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
This project is distributed under the GNU GPL license. See the
|
|
|
|
|
[LICENSE.md](LICENSE.md) file for details.
|