]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/98systemd/dracut-mount.sh
ae01512ce2e65faf47ffccf1a694b7f5a5df20d3
[thirdparty/dracut.git] / modules.d / 98systemd / dracut-mount.sh
1 #!/bin/sh
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 export DRACUT_SYSTEMD=1
5 if [ -f /dracut-state.sh ]; then
6 . /dracut-state.sh 2>/dev/null
7 fi
8 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
9
10 source_conf /etc/conf.d
11
12 make_trace_mem "hook mount" '1:shortmem' '2+:mem' '3+:slab'
13
14 getarg 'rd.break=mount' -d 'rdbreak=mount' && emergency_shell -n mount "Break mount"
15 # mount scripts actually try to mount the root filesystem, and may
16 # be sourced any number of times. As soon as one suceeds, no more are sourced.
17 i=0
18 while :; do
19 if ismounted "$NEWROOT"; then
20 usable_root "$NEWROOT" && break;
21 umount "$NEWROOT"
22 fi
23 for f in $hookdir/mount/*.sh; do
24 [ -f "$f" ] && . "$f"
25 if ismounted "$NEWROOT"; then
26 usable_root "$NEWROOT" && break;
27 warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
28 umount "$NEWROOT"
29 rm -f "$f"
30 fi
31 done
32
33 i=$(($i+1))
34 [ $i -gt 20 ] && action_on_fail "Can't mount root filesystem" && break
35 done
36
37 export -p > /dracut-state.sh
38
39 exit 0