systemd mounts
by marozsas from LinuxQuestions.org on (#551PH)
Hi there,
A few weeks ago I came here with a problem that not all file systems being mounted at boot time (https://www.linuxquestions.org/quest...ot-4175677301/)
Turns out the probable cause, as suggested by @The Squash and @syg00 was the order the system mounts file systems and the fs that I wanted to mount depends on other fs to be mounted first (/home). This cause an erratic behavior. Sometimes it get mounted other times it don't, depending on which get mounted first.
So, to fix that I moved my mounts from /etc/fstab to a unit file to get mounted by systemd.
Code:UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 / btrfs defaults 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /var btrfs subvol=/@/var 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /usr/local btrfs subvol=/@/usr/local 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /tmp btrfs subvol=/@/tmp 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /srv btrfs subvol=/@/srv 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /root btrfs subvol=/@/root 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /opt btrfs subvol=/@/opt 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /home btrfs subvol=/@/home 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=cda3f542-59ea-4e2f-be54-df8e4ffa1aa5 swap swap defaults 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /.snapshots btrfs subvol=/@/.snapshots 0 0
#
# Home Miguel extra folders on slow disk
# UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /mnt/btrfs btrfs subvol=/ 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Documents btrfs subvol=/miguel/Documentos 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Downloads btrfs subvol=/miguel/Downloads 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Pictures btrfs subvol=/miguel/Imagens 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Misc btrfs subvol=/miguel/Misc 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Music btrfs subvol=/miguel/Musica 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/ProgramasRFB btrfs subvol=/miguel/ProgramasRFB 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/tmp btrfs subvol=/miguel/tmp 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Videos btrfs subvol=/miguel/Videos 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/src/UPSData btrfs subvol=/miguel/src/UPSData 0 0
#
# transmission-daemon
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /var/lib/transmission btrfs subvol=/transmission 0 0And created several unit files like this one. The others are identical, except by the fs itself.
Code:[Unit]
Description=Mount /home/miguel/Documentos
After=home.mount
[Mount]
What=/dev/disk/by-uuid/af3bd7fe-5796-4248-9917-3e71a5a56ec6
Where=/home/miguel/Documents
Type=btrfs
Options=defaults,subvol=/miguel/Documentos
[Install]
WantedBy=multi-user.targetThe problem is it works only 1 or 2 in 7 boots. Very annoying. When it don't work after the boot, "systemctl start home-miguel-Documents.mount" mounts the fs as expected, no warnings, no messages....
I have no indication of failure, other than that strange pattern Mounted/Umounting/mount: succeeded/Umount at end of status and, of course, reported by "journalctl -b -u home-miguel-Documents.mount"...
Code:systemctl status home-miguel-Documents.mount
home-miguel-Documents.mount - Mount /home/miguel/Documentos
Loaded: loaded (/etc/systemd/system/home-miguel-Documents.mount; enabled; vendor preset: disabled)
Active: inactive (dead) since Thu 2020-06-25 15:43:03 -03; 27min ago
Where: /home/miguel/Documents
What: /dev/disk/by-uuid/af3bd7fe-5796-4248-9917-3e71a5a56ec6
Jun 25 15:43:02 kimera systemd[1]: Mounted Mount /home/miguel/Documentos.
Jun 25 15:43:03 kimera systemd[1]: Unmounting Mount /home/miguel/Documentos...
Jun 25 15:43:03 kimera systemd[1]: home-miguel-Documents.mount: Succeeded.
Jun 25 15:43:03 kimera systemd[1]: Unmounted Mount /home/miguel/Documentos.I already tried with and without "After=home.mount" , no effect.
The current mount targets in my system (openSuSE tumbleweed) are:
(this one: Documents in status active is because I issued the start command in a console. Before it was inactive, like the others)
Code:systemctl list-units --type=mount --all
UNIT LOAD ACTIVE SUB DESCRIPTION
-.mount loaded active mounted Root Mount
\x2esnapshots.mount loaded active mounted /.snapshots
boot-grub2-i386\x2dpc.mount loaded active mounted /boot/grub2/i386-pc
boot-grub2-x86_64\x2defi.mount loaded active mounted /boot/grub2/x86_64-efi
boot.mount not-found inactive dead boot.mount
dev-hugepages.mount loaded active mounted Huge Pages File System
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
home-miguel-Documents.mount loaded active mounted Mount /home/miguel/Documentos
home-miguel-Downloads.mount loaded inactive dead Mount /home/miguel/Downloads
home-miguel-Misc.mount loaded inactive dead Mount /home/miguel/Misc
home-miguel-Music.mount loaded inactive dead Mount /home/miguel/Musica
home-miguel-Pictures.mount loaded inactive dead Mount /home/miguel/Pictures
home-miguel-ProgramasRFB.mount loaded inactive dead Mount /home/miguel/ProgramasRFB
home-miguel-src-UPSData.mount loaded inactive dead Mount /home/miguel/src/UPSData
home-miguel-tmp.mount loaded inactive dead Mount /home/miguel/tmp
home-miguel-Videos.mount loaded inactive dead Mount /home/miguel/Videos
home.mount loaded active mounted /home
opt.mount loaded active mounted /opt
proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executable File Formats File System
root.mount loaded active mounted /root
run-user-1000-gvfs.mount loaded active mounted /run/user/1000/gvfs
run-user-1000.mount loaded active mounted /run/user/1000
srv.mount loaded active mounted /srv
sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System
sys-kernel-config.mount loaded inactive dead Kernel Configuration File System
sys-kernel-debug.mount loaded active mounted Kernel Debug File System
sys-kernel-tracing.mount loaded active mounted Kernel Trace File System
sysroot.mount not-found inactive dead sysroot.mount
tmp.mount loaded active mounted /tmp
usr-local.mount loaded active mounted /usr/local
usr-share.mount not-found inactive dead usr-share.mount
usr.mount not-found inactive dead usr.mount
var-cache.mount not-found inactive dead var-cache.mount
var-lib-transmission.mount loaded inactive dead Mount /var/lib/transmission
var-lock.mount loaded inactive dead Lock Directory
var-run.mount loaded inactive dead Runtime Directory
var.mount loaded active mounted /var
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
37 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.What I am doing wrong ?
Why I can not get theses extra filesystems get mounted at boot time 100% of time ?
I appreciate any comments,
cheeers,


A few weeks ago I came here with a problem that not all file systems being mounted at boot time (https://www.linuxquestions.org/quest...ot-4175677301/)
Turns out the probable cause, as suggested by @The Squash and @syg00 was the order the system mounts file systems and the fs that I wanted to mount depends on other fs to be mounted first (/home). This cause an erratic behavior. Sometimes it get mounted other times it don't, depending on which get mounted first.
So, to fix that I moved my mounts from /etc/fstab to a unit file to get mounted by systemd.
Code:UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 / btrfs defaults 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /var btrfs subvol=/@/var 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /usr/local btrfs subvol=/@/usr/local 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /tmp btrfs subvol=/@/tmp 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /srv btrfs subvol=/@/srv 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /root btrfs subvol=/@/root 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /opt btrfs subvol=/@/opt 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /home btrfs subvol=/@/home 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=cda3f542-59ea-4e2f-be54-df8e4ffa1aa5 swap swap defaults 0 0
UUID=3d62e0b9-5a9c-43b2-954f-0a50077cbb25 /.snapshots btrfs subvol=/@/.snapshots 0 0
#
# Home Miguel extra folders on slow disk
# UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /mnt/btrfs btrfs subvol=/ 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Documents btrfs subvol=/miguel/Documentos 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Downloads btrfs subvol=/miguel/Downloads 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Pictures btrfs subvol=/miguel/Imagens 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Misc btrfs subvol=/miguel/Misc 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Music btrfs subvol=/miguel/Musica 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/ProgramasRFB btrfs subvol=/miguel/ProgramasRFB 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/tmp btrfs subvol=/miguel/tmp 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/Videos btrfs subvol=/miguel/Videos 0 0
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /home/miguel/src/UPSData btrfs subvol=/miguel/src/UPSData 0 0
#
# transmission-daemon
#UUID=af3bd7fe-5796-4248-9917-3e71a5a56ec6 /var/lib/transmission btrfs subvol=/transmission 0 0And created several unit files like this one. The others are identical, except by the fs itself.
Code:[Unit]
Description=Mount /home/miguel/Documentos
After=home.mount
[Mount]
What=/dev/disk/by-uuid/af3bd7fe-5796-4248-9917-3e71a5a56ec6
Where=/home/miguel/Documents
Type=btrfs
Options=defaults,subvol=/miguel/Documentos
[Install]
WantedBy=multi-user.targetThe problem is it works only 1 or 2 in 7 boots. Very annoying. When it don't work after the boot, "systemctl start home-miguel-Documents.mount" mounts the fs as expected, no warnings, no messages....
I have no indication of failure, other than that strange pattern Mounted/Umounting/mount: succeeded/Umount at end of status and, of course, reported by "journalctl -b -u home-miguel-Documents.mount"...
Code:systemctl status home-miguel-Documents.mount
home-miguel-Documents.mount - Mount /home/miguel/Documentos
Loaded: loaded (/etc/systemd/system/home-miguel-Documents.mount; enabled; vendor preset: disabled)
Active: inactive (dead) since Thu 2020-06-25 15:43:03 -03; 27min ago
Where: /home/miguel/Documents
What: /dev/disk/by-uuid/af3bd7fe-5796-4248-9917-3e71a5a56ec6
Jun 25 15:43:02 kimera systemd[1]: Mounted Mount /home/miguel/Documentos.
Jun 25 15:43:03 kimera systemd[1]: Unmounting Mount /home/miguel/Documentos...
Jun 25 15:43:03 kimera systemd[1]: home-miguel-Documents.mount: Succeeded.
Jun 25 15:43:03 kimera systemd[1]: Unmounted Mount /home/miguel/Documentos.I already tried with and without "After=home.mount" , no effect.
The current mount targets in my system (openSuSE tumbleweed) are:
(this one: Documents in status active is because I issued the start command in a console. Before it was inactive, like the others)
Code:systemctl list-units --type=mount --all
UNIT LOAD ACTIVE SUB DESCRIPTION
-.mount loaded active mounted Root Mount
\x2esnapshots.mount loaded active mounted /.snapshots
boot-grub2-i386\x2dpc.mount loaded active mounted /boot/grub2/i386-pc
boot-grub2-x86_64\x2defi.mount loaded active mounted /boot/grub2/x86_64-efi
boot.mount not-found inactive dead boot.mount
dev-hugepages.mount loaded active mounted Huge Pages File System
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
home-miguel-Documents.mount loaded active mounted Mount /home/miguel/Documentos
home-miguel-Downloads.mount loaded inactive dead Mount /home/miguel/Downloads
home-miguel-Misc.mount loaded inactive dead Mount /home/miguel/Misc
home-miguel-Music.mount loaded inactive dead Mount /home/miguel/Musica
home-miguel-Pictures.mount loaded inactive dead Mount /home/miguel/Pictures
home-miguel-ProgramasRFB.mount loaded inactive dead Mount /home/miguel/ProgramasRFB
home-miguel-src-UPSData.mount loaded inactive dead Mount /home/miguel/src/UPSData
home-miguel-tmp.mount loaded inactive dead Mount /home/miguel/tmp
home-miguel-Videos.mount loaded inactive dead Mount /home/miguel/Videos
home.mount loaded active mounted /home
opt.mount loaded active mounted /opt
proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executable File Formats File System
root.mount loaded active mounted /root
run-user-1000-gvfs.mount loaded active mounted /run/user/1000/gvfs
run-user-1000.mount loaded active mounted /run/user/1000
srv.mount loaded active mounted /srv
sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System
sys-kernel-config.mount loaded inactive dead Kernel Configuration File System
sys-kernel-debug.mount loaded active mounted Kernel Debug File System
sys-kernel-tracing.mount loaded active mounted Kernel Trace File System
sysroot.mount not-found inactive dead sysroot.mount
tmp.mount loaded active mounted /tmp
usr-local.mount loaded active mounted /usr/local
usr-share.mount not-found inactive dead usr-share.mount
usr.mount not-found inactive dead usr.mount
var-cache.mount not-found inactive dead var-cache.mount
var-lib-transmission.mount loaded inactive dead Mount /var/lib/transmission
var-lock.mount loaded inactive dead Lock Directory
var-run.mount loaded inactive dead Runtime Directory
var.mount loaded active mounted /var
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
37 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.What I am doing wrong ?
Why I can not get theses extra filesystems get mounted at boot time 100% of time ?
I appreciate any comments,
cheeers,