-
Notifications
You must be signed in to change notification settings - Fork 34
FAQ : User
Precondition is boot to console (booting to Desktop will lead to an automount of usb sticks)
systemd-escape --suffix=mount --path <mountpoint>
Shows you how to name your systemd files. This naming scheme is important!
My mount point is '/home/pi/Pictures/usb'
systemd-escape --suffix=mount --path /home/pi/Pictures/usb
home-pi-Pictures-usb.mount
Create 'sudo nano /etc/systemd/system/home-pi-Pictures-usb.mount'
[Unit]
Description=Mount USB
[Mount]
What=/dev/sda
Where=/home/pi/Pictures/usb
Type=vfat
[Install]
WantedBy=multi-user.target
sda
is my usb stick. You can check it with lsblk
Create 'sudo nano /etc/systemd/system/home-pi-Pictures-usb.automount'
[Unit]
Description=Automount USB device
[Automount]
Where=/home/pi/Pictures/usb
#unmount if longer than 20 sec unavailable
TimeoutIdleSec=20
[Install]
WantedBy=multi-user.target
Run sudo systemctl daemon-reload
Enable automount sudo systemctl enable home-pi-Pictures-usb.automount
and start it sudo systemctl start home-pi-Pictures-usb.automount
If you plug in your stick, a folder under /home/pi/Pictures/usb
appears, which contains the data on the stick. If you unplug the stick the 'usb' folder remains, but is not accessible. So every time you plugin a stick, the images would be under the 'usb' folder.
Remark It's important, that the '.mout' service is not enabled. Otherwise the raspbery tries to mount the stick on boot. That is OK, if you plan to use it as a permanent device. But '.automount' needs '.mount'. And for permanent mounted devices, you wouldn't need of course the '.automount' file.
Would be good, if others can test this.