Provide utility script is-rootdisk-device.sh
This provides a utility script to determine which disk contains the root filesystem. This can also be used as a helper function for io-scheduler udev rules that require specific configuration for root disk. Example usage: /usr/local/bin/is-rootdisk-device.sh ROOTDISK_DEVICE=sda /usr/local/bin/is-rootdisk-device.sh /dev/sda ROOTDISK_DEVICE=sda /usr/local/bin/is-rootdisk-device.sh /dev/sdb (i.e., no output) Partial-Bug: 1927515 Signed-off-by: Jim Gauld <james.gauld@windriver.com> Change-Id: Ib0d4a161a407b08d294c5ff9aa0b7590961e18c9
This commit is contained in:
parent
d665a1b373
commit
6045b1b8a0
@ -60,6 +60,7 @@ install -d %{buildroot}%{local_bindir}
|
||||
install %{_buildsubdir}/scripts/tc_setup.sh %{buildroot}%{local_bindir}
|
||||
install %{_buildsubdir}/scripts/remotelogging_tc_setup.sh %{buildroot}%{local_bindir}
|
||||
install %{_buildsubdir}/scripts/connectivity_test %{buildroot}%{local_bindir}
|
||||
install -m 555 %{_buildsubdir}/scripts/is-rootdisk-device.sh %{buildroot}%{local_bindir}
|
||||
install -m 555 %{_buildsubdir}/scripts/update-iso.sh %{buildroot}%{local_bindir}
|
||||
install -m 555 %{_buildsubdir}/scripts/gen-bootloader-iso.sh %{buildroot}%{local_bindir}
|
||||
install -m 555 %{_buildsubdir}/scripts/stx-iso-utils.sh %{buildroot}%{local_bindir}
|
||||
@ -95,6 +96,7 @@ systemctl enable opt-platform.service
|
||||
%{local_bindir}/tc_setup.sh
|
||||
%{local_bindir}/remotelogging_tc_setup.sh
|
||||
%{local_bindir}/connectivity_test
|
||||
%{local_bindir}/is-rootdisk-device.sh
|
||||
%{local_bindir}/set_keystone_user_option.sh
|
||||
%{local_sbindir}/patch-restart-mtce
|
||||
%{local_sbindir}/patch-restart-processes
|
||||
|
28
utilities/platform-util/scripts/is-rootdisk-device.sh
Executable file
28
utilities/platform-util/scripts/is-rootdisk-device.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Usage:
|
||||
# is-rootdisk-device <device>
|
||||
#
|
||||
# If no arguments are provided, this shows which disk contains the
|
||||
# root filesystem. If the optional device parameter is specified,
|
||||
# output is only generated when the device matches the root disk.
|
||||
|
||||
dev=$1
|
||||
|
||||
rootdev=$(lsblk --ascii -oPKNAME -n $(findmnt -n -T / -o SOURCE))
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "ROOTDISK_DEVICE=${rootdev}"
|
||||
else
|
||||
if [ "${dev}" == "/dev/${rootdev}" ] || \
|
||||
[ "/dev/${dev}" == "/dev/${rootdev}" ]; then
|
||||
echo "ROOTDISK_DEVICE=${rootdev}"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user