[initramfs]: SSD firmware upgrade in initramfs (#10748)

Why I did it
To upgrade SSD firmware in initramfs while rebooting from SONiC to SONiC and during NOS to SONiC migration.

How I did it
New option 'ssd-upgrader-part’ is introduced in grub command line, to indicate the partition and its filesystem type in which the SSD firmware updater is present. ‘ssd-upgrader-part’ syntax is ssd-upgrader-part=<partition>,<filesystem type>. Example: ssd-upgrader-part=/dev/sda8,ext4

A new initramfs script ‘ssd-upgrade’ is included in init-premount and it invokes the SSD firmware updater (ssd-fw-upgrade) present in the partition indicated by the boot option 'ssd-upgrader-part'

How to verify it
In SONiC, the SSD firmware updater is copied to “/host/” directory.
Fast-reboot is to be initiated with the ‘-u’ option ([scripts/fast-reboot] Add option to include ssd-upgrader-part boot option with SONiC partition sonic-utilities#2150)
After reboot, while booting into SONiC the SSD firmware updater will be executed in initramfs.
This commit is contained in:
Arun Saravanan Balachandran 2022-05-12 20:41:02 +05:30 committed by GitHub
parent 992d233090
commit f4b22f67a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 0 deletions

View File

@ -189,6 +189,10 @@ sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-
sudo cp files/initramfs-tools/resize-rootfs $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/resize-rootfs
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/resize-rootfs
# Hook into initramfs: upgrade SSD from initramfs
sudo cp files/initramfs-tools/ssd-upgrade $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/ssd-upgrade
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/ssd-upgrade
# Hook into initramfs: run fsck to repair a non-clean filesystem prior to be mounted
sudo cp files/initramfs-tools/fsck-rootfs $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/fsck-rootfs
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/fsck-rootfs

View File

@ -114,6 +114,9 @@ migrate_nos_configuration()
# remove nos-config-part from cmdline
sed -r -i.bak "s/nos-config-part=[^[:space:]]+//" /host/grub/grub.cfg
# remove ssd-upgrader-part from cmdline
sed -r -i.bak "s/ssd-upgrader-part=[^[:space:]]+//" /host/grub/grub.cfg
# Mount the previous NOS's partition
NOS_DIR=/mnt/nos_migration
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt

View File

@ -0,0 +1,35 @@
#!/bin/sh
case $1 in
prereqs)
exit 0
;;
esac
# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
case "$x" in
ssd-upgrader-part=*)
ssd_upgrader_part="${x#ssd-upgrader-part=}"
;;
esac
done
if [ ! -z "$ssd_upgrader_part" ]; then
echo "ssd-upgrader-part found in /proc/cmdline" > /tmp/ssd-fw-upgrade.log
mkdir -p /mnt/ssd_upgrader_part
mount -t "${ssd_upgrader_part#*,}" "${ssd_upgrader_part%,*}" /mnt/ssd_upgrader_part
if [ -x /mnt/ssd_upgrader_part/ssd-fw-upgrade ]; then
cp /mnt/ssd_upgrader_part/ssd-fw-upgrade /tmp/
cd /tmp/
umount /mnt/ssd_upgrader_part
rm -r /mnt/ssd_upgrader_part
./ssd-fw-upgrade >> /tmp/ssd-fw-upgrade.log 2>&1
else
echo "ssd-fw-upgrade not found" >> /tmp/ssd-fw-upgrade.log
umount /mnt/ssd_upgrader_part
rm -r /mnt/ssd_upgrader_part
fi
gzip /tmp/ssd-fw-upgrade.log
fi

View File

@ -190,3 +190,8 @@ fi
if [ -f /tmp/fsck.log.gz ]; then
mv /tmp/fsck.log.gz ${rootmnt}/var/log
fi
## ssd-fw-upgrade log file: /tmp will be lost when overlayfs is mounted
if [ -f /tmp/ssd-fw-upgrade.log.gz ]; then
mv /tmp/ssd-fw-upgrade.log.gz ${rootmnt}/var/log
fi