3 type getarg
> /dev
/null
2>&1 || .
/lib
/dracut-lib.sh
6 info
"note - fsck suggests reboot, if you"
7 info
"leave shell, booting will continue normally"
8 emergency_shell
-n "(reboot ?)"
12 warn
"*** An error occurred during the file system check."
13 warn
"*** Dropping you to a shell; the system will try"
14 warn
"*** to mount the filesystem(s), when you leave the shell."
15 emergency_shell
-n "(Repair filesystem)"
18 # inherits: _ret _drv _out
20 [ "$_ret" -gt 0 ] && warn
"$_drv returned with $_ret"
21 if [ "$_ret" -ge 4 ]; then
22 [ -n "$_out" ] && echo "$_out" | vwarn
25 [ -n "$_out" ] && echo "$_out" | vinfo
26 [ "$_ret" -ge 2 ] && fsck_ask_reboot
30 # note: this function sets _drv of the caller
40 # } >/dev/null 2>&1 &&
41 # _drv="_drv=none fsck_drv_xfs" &&
46 type e2fsck
> /dev
/null
2>&1 \
47 && _drv
="fsck_drv_com e2fsck" \
51 type fsck.f2fs
> /dev
/null
2>&1 \
52 && _drv
="fsck_drv_com fsck.f2fs" \
56 type jfs_fsck
> /dev
/null
2>&1 \
57 && _drv
="fsck_drv_com jfs_fsck" \
61 type reiserfsck
> /dev
/null
2>&1 \
62 && _drv
="fsck_drv_com reiserfsck" \
66 # type btrfsck >/dev/null 2>&1 &&
67 # _drv="_drv=none fsck_drv_btrfs" &&
72 # nfs can be a nop, returning success
77 type fsck
> /dev
/null
2>&1 \
78 && _drv
="fsck_drv_std fsck" \
86 # note: all drivers inherit: _drv _fop _dev
89 # xfs fsck is not necessary... Either it mounts or not
94 # btrfs fsck is not necessary... Either it mounts or not
98 # common code for checkers that follow usual subset of options and return codes
104 if ! strglobin
"$_fop" "-[ynap]"; then
105 _fop
="-a${_fop:+ "$_fop"}"
108 info
"issuing $_drv $_fop $_dev"
109 # we enforce non-interactive run, so $() is fine
110 # shellcheck disable=SC2086
111 _out
=$
($_drv $_fop "$_dev")
118 # code for generic fsck, if the filesystem checked is "unknown" to us
124 info
"issuing fsck $_fop $_dev"
125 # note, we don't enforce -a here, thus fsck is being run (in theory)
126 # interactively; otherwise some tool might complain about lack of terminal
127 # (and using -a might not be safe)
128 # shellcheck disable=SC2086
129 fsck
$_fop "$_dev" > /dev
/console
2>&1
136 # checks single filesystem, relying on specific "driver"; we don't rely on
137 # automatic checking based on fstab, so empty one is passed;
138 # takes 4 arguments - device, filesystem, filesystem options, additional fsck options;
139 # first 2 arguments are mandatory (fs may be auto or "")
140 # returns 255 if filesystem wasn't checked at all (e.g. due to lack of
141 # necessary tools or insufficient options)
143 local FSTAB_FILE
=/etc
/fstab.empty
145 local _fs
="${2:-auto}"
149 [ $# -lt 2 ] && return 255
150 _dev
=$
(readlink
-f "$(label_uuid_to_dev "$_dev")")
151 [ -e "$_dev" ] ||
return 255
152 _fs
=$
(det_fs
"$_dev" "$_fs")
153 fsck_able
"$_fs" ||
return 255
155 info
"Checking $_fs: $_dev"
161 # takes list of filesystems to check in parallel; we don't rely on automatic
162 # checking based on fstab, so empty one is passed
164 local FSTAB_FILE
=/etc
/fstab.empty
170 [ $# -eq 0 ] ||
! type fsck
> /dev
/null
2>&1 && return 255
172 info
"Checking filesystems (fsck -M -T -a):"
178 _out
="$(fsck -M -T "$@
" -- -a)"
186 # verify supplied filesystem type:
187 # if user provided the fs and we couldn't find it, assume user is right
188 # if we found the fs, assume we're right
191 local _orig
="${2:-auto}"
194 _fs
=$
(udevadm info
--query=property
--name="$_dev" \
195 |
while read -r line ||
[ -n "$line" ]; do
196 if str_starts
"$line" "ID_FS_TYPE="; then
197 echo "${line#ID_FS_TYPE=}"
203 if [ "$_fs" = "auto" ]; then
221 [ -z "$_rootfstype" ] && _rootfstype
=$
(getarg rootfstype
=)
222 [ -z "$_rootflags" ] && _rootflags
=$
(getarg rootflags
=)
224 [ -z "$_rootfstype" ] && _rootfstype
="auto"
226 if [ -z "$_rootflags" ]; then
227 _rootflags
="ro,x-initrd.mount"
229 _rootflags
="ro,$_rootflags,x-initrd.mount"
234 CMDLINE
=$
(getcmdline
)
235 for _o
in $CMDLINE; do
245 if [ "$_rw" = "1" ]; then
246 _rootflags
="$_rootflags,rw"
247 if ! getargbool
0 rd.skipfsck
; then
252 if grep -q "$_root /sysroot" /etc
/fstab
; then
253 echo "$_root /sysroot $_rootfstype $_rootflags $_fspassno 0" >> /etc
/fstab
258 if type systemctl
> /dev
/null
2> /dev
/null
; then
259 systemctl daemon-reload
260 systemctl
--no-block start initrd-root-fs.target