]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/98systemd/dracut-cmdline.sh
Add rd.hostonly kernel command line parameters
[thirdparty/dracut.git] / modules.d / 98systemd / dracut-cmdline.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
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 [ -f /etc/initrd-release ] && . /etc/initrd-release
11 [ -n "$VERSION" ] && info "dracut-$VERSION"
12
13 if ! getargbool 1 'rd.hostonly'; then
14 remove_hostonly_files
15 fi
16
17 getargbool 0 rd.udev.log-priority=info -d rd.udev.info -d -n -y rdudevinfo && echo 'udev_log="info"' >> /etc/udev/udev.conf
18 getargbool 0 rd.udev.log-priority=debug -d rd.udev.debug -d -n -y rdudevdebug && echo 'udev_log="debug"' >> /etc/udev/udev.conf
19
20 source_conf /etc/conf.d
21
22 root=$(getarg root=)
23
24 rflags="$(getarg rootflags=)"
25 getargbool 0 ro && rflags="${rflags},ro"
26 getargbool 0 rw && rflags="${rflags},rw"
27 rflags="${rflags#,}"
28
29 fstype="$(getarg rootfstype=)"
30 if [ -z "$fstype" ]; then
31 fstype="auto"
32 fi
33
34 export root
35 export rflags
36 export fstype
37
38 make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
39 # run scriptlets to parse the command line
40 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
41 source_hook cmdline
42
43 [ -f /lib/dracut/parse-resume.sh ] && . /lib/dracut/parse-resume.sh
44
45 case "$root" in
46 block:LABEL=*|LABEL=*)
47 root="${root#block:}"
48 root="$(echo $root | sed 's,/,\\x2f,g')"
49 root="block:/dev/disk/by-label/${root#LABEL=}"
50 rootok=1 ;;
51 block:UUID=*|UUID=*)
52 root="${root#block:}"
53 root="block:/dev/disk/by-uuid/${root#UUID=}"
54 rootok=1 ;;
55 block:PARTUUID=*|PARTUUID=*)
56 root="${root#block:}"
57 root="block:/dev/disk/by-partuuid/${root#PARTUUID=}"
58 rootok=1 ;;
59 block:PARTLABEL=*|PARTLABEL=*)
60 root="${root#block:}"
61 root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}"
62 rootok=1 ;;
63 /dev/*)
64 root="block:${root}"
65 rootok=1 ;;
66 esac
67
68 [ -z "$root" ] && die "No or empty root= argument"
69 [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
70
71 export root rflags fstype netroot NEWROOT
72
73 export -p > /dracut-state.sh
74
75 exit 0