You are not logged in.

#1 2024-12-05 22:32:59

jsaxx
Member
Registered: 2022-11-07
Posts: 19

Handling mounts on shutdown

Hello All,

I am wondering what is the best way to handle mounts on shutdowns/reboots.

Lemme give some context:

Very often when powering off, I would get the following error on a mount:

Broadcast message from user@host on pts/0 (Thu 2024-12-05 22:34:84 CET):

The system will power off now!

[FAILED] Failed unmounting /mnt/Games. 
[***   ] A stop job is running for User Manager for UID 1000 (28s / 1min 49s) 

and I can then see in journalctl

Dec 05 22:25:37 host umount[38823]: umount: /mnt/Storage: target is busy.
Dec 05 22:25:37 host systemd[1]: Unmounting /mnt/Storage...
Dec 05 22:25:37 host systemd[1]: Failed unmounting /mnt/Storage.

To me seems pretty clear that this happens because some process is still accessing the mount, that cannot then be unmounted during shutdown.

To circumvent this I have modified /etc/systemd/logind.conf with the following/

KillUserProcesses=yes
KillExcludeUsers=root

This seems to have done the trick, but imo it is not a very elegant way to handle the situation.

What are the best practices/suggestions to handle it? Am I doing something wrong?

Thanks!



adding fstab below for more details

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# Swap
UUID=fe20320c-29c1-4906-a4a3-ee724a45f1a3       none            swap            defaults        0 0
# Boot/EFI
UUID=3B2A-57B7 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
# Computer
UUID=b4b8e732-c30f-480c-b597-2b497898c712 / ext4 rw,relatime 0 1
# Games
LABEL=Games /mnt/Games btrfs compress-force=zstd,nosuid,nodev,nofail,relatime 0 0
# Storage
LABEL=Storage /mnt/Storage btrfs compress-force=zstd,nosuid,nodev,nofail,relatime,autodefrag 0 0
/dev/md0 /mnt/Games auto nosuid,nodev,nofail,x-gvfs-show 0 0

Offline

#2 2024-12-06 00:43:01

cryptearth
Member
Registered: 2024-02-03
Posts: 2,165

Re: Handling mounts on shutdown

you have two lines mounting to /mnt/Games:
LABEL=Games
and
/dev/md0
you should clean this up first

then - as "games" gives a hint: how about game launchers like steam, heroic, lutirs, etc? do you manual quit them before logging off - or do you do it the windows way: having a metric ton of crap in the background and just kill the current session by force reboot?
how about a
lsof /mnt/Games
before shutting down to see what processes have open handles on that mount point

Offline

#3 2024-12-06 14:49:46

jsaxx
Member
Registered: 2022-11-07
Posts: 19

Re: Handling mounts on shutdown

cryptearth wrote:

you have two lines mounting to /mnt/Games:
LABEL=Games
and
/dev/md0
you should clean this up first

then - as "games" gives a hint: how about game launchers like steam, heroic, lutirs, etc? do you manual quit them before logging off - or do you do it the windows way: having a metric ton of crap in the background and just kill the current session by force reboot?
how about a
lsof /mnt/Games
before shutting down to see what processes have open handles on that mount point

thanks cryptearth, I did not even notice the final line on fstab, that one should not be there at all. In any case with a clean fstab the situation does still happen.

This thing is not really regular, sometimes I can poweroff with a game still running, and I will not receive any error. Other times, if I close up all apps I do get the error. And this happen on /Storage as well, so it should not be related to a specific program hitting the mount.

And is not really about "the windows way" (whatever that means ¯\_(ツ)_/¯ ) or not, I know this happen because there is some process still working on the specific mount. I am interested in knowing what is the "best practice" in handling those while shutting down, if not forcefully killing them all via conf or manually.

Offline

#4 2024-12-07 12:17:22

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,045

Re: Handling mounts on shutdown


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-12-12 09:36:12

jsaxx
Member
Registered: 2022-11-07
Posts: 19

Re: Handling mounts on shutdown

thanks Lone_Wolf, this is what I needed to see! What the wiki suggests is pretty much what I did, I just wanted confirmation that this was the right way to go about it.

Offline

Board footer

Powered by FluxBB