Commit Graph

13 Commits (master)

Author SHA1 Message Date
Harald Hoyer 56ea45bd5a fix(shutdown): shellcheck for modules.d/99shutdown 2021-03-29 11:17:11 +02:00
Harald Hoyer 9a52c3fdb0 style: shfmt reformat
reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w .
```
2021-03-13 20:10:43 +01:00
Petr Pavlu 38ef319390 fix(shutdown): add timeout to umount calls
When terminating a system, the shutdown module attempts to unmount all
file systems from under /oldroot. This reaps remaining file systems that
systemd cannot unmount and detaches /oldroot itself.

In case that running umount for some file system repeatedly fails, the
module reports this error and continues the processing in order to
shutdown the system. This handles a condition when the umount command
actually terminates but it can happen in some cases that it waits
indefinitely.

An example with NFS mounts:
# mount -t nfs 192.168.0.1:/srv/nfs/dir /mnt/nfs
# mkdir /mnt/nfs/dir2
# mount -t nfs 192.168.0.1:/srv/nfs/dir2 /mnt/nfs/dir2
# touch /mnt/nfs/dir2/file
# systemd-run -pKillMode=none -pSendSIGKILL=no tail -f /mnt/nfs/dir2/file
Running as unit: run-r367825c967ca4d88a793ae4793c02f8b.service
# systemctl poweroff

The invoked tail command escapes normal termination by systemd and
prevents stopping mnt-nfs.mount and mnt-nfs-dir2.mount as it makes the
mounts busy. Systemd then again attempts to unmount these file systems
in systemd-shutdown but this fails as well. The utility tries to unmount
/mnt/nfs/dir2 but the kernel waits indefinitely doing a path lookup for
/mnt/nfs because network is no longer available at that point. The
systemd-shutdown gives up after 90 seconds. Finally, the control is
transferred to dracut which tries to unmount the file systems in the
same way and ends up indefinitely waiting on umount to finish.

This situation causes that the system hangs during shutdown. The patch
improves the shutdown module to add a timeout of 90 seconds for the
umount operation and continue with the shutdown if it gets reached,
similarly to what systemd-shutdown does.
2021-02-10 14:06:37 +01:00
Harald Hoyer df6bb5e959 shutdown: sleep a little, if a process was killed
If a process (maybe plymouth) was still pinning /oldroot, then shutdown
would
- kill -9 $pid
- umount_a
- umount_a
in a very short timeframe. A small sleep hopefully lets the scheduler free
up /oldroot in the mean time.
2018-05-15 13:37:53 +02:00
Harald Hoyer 54e09dfb72 shutdown: guard against read-only /run
remount the switch rooted /run writeable again.
2015-11-30 11:27:03 +01:00
Harald Hoyer 967cc19ab1 remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
Harald Hoyer 8bcfd683bd */module-setup.sh: add comments for dracut called functions 2013-10-08 10:37:56 +02:00
Harald Hoyer af11946054 dracut-functions.sh: inst_multiple == dracut_install 2013-08-07 10:33:15 +02:00
Harald Hoyer d8b627b9dc shutdown: call "losetup -D" on shutdown 2013-02-05 11:04:02 +01:00
Harald Hoyer 53fe81e752 modules.d/*/module-setup.sh: combine and specify type for installs
To speedup image creation, combine dracut_install calls and specify the exact type.
E.g. inst_script instead of the generic inst.
2012-06-29 12:41:27 +02:00
Harald Hoyer 552ecca6db Renamed all shell scripts to *.sh 2012-02-22 15:15:21 +01:00
Harald Hoyer 2560da6be2 enable shutdown module by default 2011-07-20 19:04:54 +02:00
Harald Hoyer 168fa7e571 base: add shutdown script to be called from systemd 2011-05-31 15:50:43 +02:00