summaryrefslogtreecommitdiffstats
path: root/dracut/anaconda-pre-shutdown.sh
blob: 2b977861bbc2ec009f49228910b858e02d877271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Fix mount loops that prevent unmount/eject.
#
# During startup, we mount our repo (e.g. the DVD) at $repodir or $isodir.
# We then mount the runtime image from that repo at /newroot and switch into it.
# Switching moves $repodir to /newroot/$repodir, which creates a mount loop:
#
# -> You can't unmount the runtime image because the DVD is mounted under it
# -> You can't unmount the DVD because it holds the mounted runtime image
#
# And now you can't unmount or eject the DVD!
#
# We fix this by moving the repo mounts back out from under the runtime image
# during shutdown. Then everything can be unmounted like normal.

. /lib/anaconda-lib.sh

for mnt in $repodir $isodir; do
    # systemd-shutdown puts old root at /oldroot
    oldmnt=/oldroot$mnt
    grep -qw $oldmnt /proc/mounts && mount --move $oldmnt $mnt
done