98usrmount: print mount options
[dracut.git] / modules.d / 98usrmount / mount-usr.sh
blobf4d59b3eb5d1c6b3f6bde9dac2d394c36e8383f9
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
5 type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
6 type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
8 fsck_usr()
10 local _dev=$1
11 local _fs=$2
12 local _fsopts=$3
13 local _fsckoptions
15 if [ -f "$NEWROOT"/fsckoptions ]; then
16 _fsckoptions=$(cat "$NEWROOT"/fsckoptions)
19 if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
20 _fsckoptions="-f $_fsckoptions"
21 elif [ -f "$NEWROOT"/.autofsck ]; then
22 [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck
23 if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
24 AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
26 if [ -n "$AUTOFSCK_SINGLEUSER" ]; then
27 warn "*** Warning -- the system did not shut down cleanly. "
28 warn "*** Dropping you to a shell; the system will continue"
29 warn "*** when you leave the shell."
30 emergency_shell
32 _fsckoptions="$AUTOFSCK_OPT $_fsckoptions"
35 fsck_single "$_dev" "$_fs" "$_fsopts" "$_fsckoptions"
38 mount_usr()
40 local _dev _mp _fs _opts _rest _usr_found _ret _freq _passno
41 # check, if we have to mount the /usr filesystem
42 while read _dev _mp _fs _opts _freq _passno; do
43 [ "${_dev%%#*}" != "$_dev" ] && continue
44 if [ "$_mp" = "/usr" ]; then
45 case "$_dev" in
46 LABEL=*)
47 _dev="$(echo $_dev | sed 's,/,\\x2f,g')"
48 _dev="/dev/disk/by-label/${_dev#LABEL=}"
50 UUID=*)
51 _dev="${_dev#block:}"
52 _dev="/dev/disk/by-uuid/${_dev#UUID=}"
54 esac
55 if strstr "$_opts" "subvol=" && \
56 [ "${root#block:}" -ef $_dev ]
57 [ -n "$rflags" ]; then
58 # for btrfs subvolumes we have to mount /usr with the same rflags
59 _opts="${_opts:+${_opts},}${rflags}"
60 elif getargbool 0 ro; then
61 # if "ro" is specified, we want /usr to be mounted read-only
62 _opts="${_opts:+${_opts},}ro"
63 elif getargbool 0 rw; then
64 # if "rw" is specified, we want /usr to be mounted read-write
65 _opts="${_opts:+${_opts},}rw"
67 echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno"
68 _usr_found="1"
69 break
71 done < "$NEWROOT/etc/fstab" >> /etc/fstab
73 if [ "x$_usr_found" != "x" ]; then
74 # we have to mount /usr
75 _fsck_ret=0
76 if ! getargbool 0 rd.skipfsck; then
77 if [ "0" != "${_passno:-0}" ]; then
78 fsck_usr "$_dev" "$_fs" "$_opts"
79 _fsck_ret=$?
80 [ $_fsck_ret -ne 255 ] && echo $_fsck_ret >/run/initramfs/usr-fsck
84 info "Mounting /usr with -o $_opts"
85 mount "$NEWROOT/usr" 2>&1 | vinfo
87 if ! ismounted "$NEWROOT/usr"; then
88 warn "Mounting /usr to $NEWROOT/usr failed"
89 warn "*** Dropping you to a shell; the system will continue"
90 warn "*** when you leave the shell."
91 emergency_shell
96 if [ -f "$NEWROOT/etc/fstab" ]; then
97 mount_usr