This commit is contained in:
waldek 2021-08-24 01:30:47 +02:00
parent 2fcc62a903
commit 1b591284a9
1 changed files with 54 additions and 0 deletions

54
modules/qualifying/tmp.md Normal file
View File

@ -0,0 +1,54 @@
# Solution
## First alternative solution
### The udev rule
```
➜ ~ git:(master) ✗ cat /etc/udev/rules.d/99-backup_to_usb_stick.rules
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="2469ffe5-e066-476d-805a-cde85a58ea3b", ACTION=="add", TAG+="systemd", SYMLINK+="backup_partition"
➜ ~ git:(master) ✗
```
### The device file
```
➜ ~ git:(master) ✗ cat /etc/systemd/system/dev-backup_partition.device
[Unit]
Description=my device
Wants=tester.service
➜ ~ git:(master) ✗
```
### The service file
```
➜ ~ git:(master) ✗ cat /etc/systemd/system/tester.service
[Unit]
Description=A tester
Requires=dev-backup_partition.device
After=dev-backup_partition.device
[Service]
ExecStart=echo "test"
[Install]
WantedBy=default.target
➜ ~ git:(master) ✗
```
## Second alternative solution
Can be done via mount files as well.
### The udev rule
```
➜ ~ git:(master) ✗ cat /etc/udev/rules.d/99-backup_to_usb_stick.rules
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="2469ffe5-e066-476d-805a-cde85a58ea3b", ACTION=="add", TAG+="systemd", SYMLINK+="backup_partition", RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode /media/backup_stick"
➜ ~ git:(master) ✗
```
### The mount file
### The service file