Outils pour utilisateurs

Outils du site


tech:systemd_autofs

SystemD Autofs Automount

Ou comment monter automatiquement un lecteur via SystemD

Voir :

Voir aussi

/etc/systemd/system/mnt-partage.mount

[Unit]
Description=Partage
 
[Mount]
What=//serveur/Partage
Where=/mnt/partage
Type=cifs
#Options=_netdev,rw,uid=1100,forceuid,gid=1100,forcegid,file_mode=0777,dir_mode=0777,noperm,credentials=/root/.cifs_partage
Options=noexec,nosuid,nodev,rw,uid=1100,forceuid,gid=1100,forcegid,file_mode=0777,dir_mode=0777,noperm,credentials=/root/.cifs_partage
 
[Install]
WantedBy=multi-user.target

/etc/systemd/system/mnt-partage.automount

[Unit]
Description=Automount Partage
#Requires=network-online.target
#After=network-online.service
 
[Automount]
Where=/mnt/partage
TimeoutIdleSec=10
 
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
 
systemctl disable mnt-partage.mount
systemctl enable mnt-partage.automount

Remarque : le nom du fichier à son importance. Pour un montage /mnt/plop le fichier doit s'appeler mnt-plop.mount

Vérif

systemctl status /mnt/partage
journalctl -u /mnt/partage

La partition est vu comme montée en autofs par la commande mount

# mount |grep /mnt/partage
systemd-1 on /mnt/partage type autofs (rw,relatime,fd=28,pgrp=1,timeout=10,minproto=5,maxproto=5,direct,pipe_ino=38828)

En cas de pb pour forcer le démontage. A utiliser si la commande df ne rien pas la main.

sudo umount -a -t cifs -l
sudo umount -a -t autofs -l

Diag

Pour retrouver le nom du service KO :

systemctl list-units --state failed --type mount --type automount --no-pager

Puis copier-coller le nom entre des quotes

systemctl status 'mnt-app-c888_yy\x2yyyy\x2yyy\x2dapp-data-mounts-Quayyyyyy-Envoi.mount' 
dmesg

Autres

Si caractères spéciaux

$ systemd-escape --suffix mount -p /mnt/foo-bar
mnt-foo\x2dbar.mount
 
$ systemd-escape -u 'mnt-foo\x2dbar.mount'
mnt/foo-bar.mount

NOTE : '\x' pour échapper ASCII en notation hexadécimale \ '2d' corespond au code hexa du trait d'union.

https://github.com/systemd/systemd/blob/master/units/sys-fs-fuse-connections.mount

/etc/systemd/sys-fs-fuse-connections.mount

#  SPDX-License-Identifier: LGPL-2.1+
#
#  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=FUSE Control File System
Documentation=https://www.kernel.org/doc/Documentation/filesystems/fuse.txt
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
DefaultDependencies=no
ConditionPathExists=/sys/fs/fuse/connections
ConditionCapability=CAP_SYS_ADMIN
ConditionVirtualization=!private-users
After=systemd-modules-load.service
Before=sysinit.target
 
[Mount]
What=fusectl
Where=/sys/fs/fuse/connections
Type=fusectl
Options=nosuid,nodev,noexec

Si SNMP

Message d'erreur sur la console si partage injoignable

CIFS VFS: cifs_mount failed w/return code

Solution

/etc/snmp/snmpd.conf

skipNFSInHostResources 1

Autres solution

https://www.justegeek.fr/montage-automatique-partages-cifs-systemd/

Ajouter l'option suivant dans le fstab : x-systemd.automount,x-systemd.device-timeout=3

tech/systemd_autofs.txt · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki