Skip to content

Commit

Permalink
initscripts-nilrt: add a script to free up dump-related EFI variables…
Browse files Browse the repository at this point in the history
… on boot

The kernel can insert crash information into EFI variables (via efi-pstore)
for later retrieval (typically by systemd-pstore). However, if nothing ever
retreives and cleans up those variables, they can build up and inhibit the
provisioning process.

Since this release of NI Linux RT is still using sysvinit and not systemd,
it does not have systemd-pstore; therefore it does not have a means to
meaningfully process the crash information from efi-pstore. Thus we opt to
simply clean up the state to avoid filling the EFI variable store.

Signed-off-by: Brandon Streiff <brandon.streiff@ni.com>
Natinst-AzDO-ID: 1154633
  • Loading branch information
bstreiff authored and amstewart committed Oct 23, 2020
1 parent b545939 commit 196d987
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
46 changes: 46 additions & 0 deletions recipes-ni/initscripts-nilrt/files/nicleanefivars
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: nicleanefivars
# Required-Start: $mountvirtfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: nicleanefivars
# Description: This is a script that cleans old efi-pstore information.
### END INIT INFO

# Previous kernels may have stored kernel crash information in EFI for
# systemd to retrieve later. However, this version of NI Linux RT does
# not use systemd and therefore does not have a way to meaningfully
# utilize this information. In order to prevent future issues due to
# exhaustion of EFI variable storage, erase all prior dump information.

NAME=nicleanefivars
SCRIPTNAME=/etc/init.d/$NAME

EFI_CRASH_CLEANUP=y

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# no-op if EFI_CRASH_CLEANUP=n is set in /etc/default/nicleanefivars
case "$EFI_CRASH_CLEANUP" in
[Nn]*)
exit 0
;;
esac

case "$1" in
start)
LINUX_EFI_CRASH_GUID="cfc8fc79-be2e-4ddc-97f0-9f98bfe298a0"
find /sys/firmware/efi/efivars -name "*-${LINUX_EFI_CRASH_GUID}" -exec /bin/rm {} +
;;
stop|status|reload|restart|force-reload)
;;
*)
echo "Usage: $SCRIPTNAME {start}" >&2
exit 3
;;
esac

exit 0
4 changes: 4 additions & 0 deletions recipes-ni/initscripts-nilrt/initscripts-nilrt_1.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RDEPENDS_${PN}_append_x64 = " nilrtdiskcrypt "
SRC_URI = "file://nisetbootmode \
file://firewall \
file://mountdebugfs \
file://nicleanefivars \
file://nicleanstalelinks \
file://nicreatecpusets \
file://nicreatecpuacctgroups \
Expand Down Expand Up @@ -167,6 +168,9 @@ do_install_append_x64 () {

install -m 0755 ${WORKDIR}/niclosedisks ${D}${sysconfdir}/init.d
update-rc.d -r ${D} niclosedisks start 41 0 . start 41 6 .

install -m 0755 ${WORKDIR}/nicleanefivars ${D}${sysconfdir}/init.d
update-rc.d -r ${D} nicleanefivars start 10 S .
}

do_install_ptest () {
Expand Down

0 comments on commit 196d987

Please sign in to comment.