update_kernel: Tolerate syslinux partition mount failure
Currently update_kernel.sh tries to tiptoe around the syslinux partition,
checking to see if partition 12 exists or if the vmlinuz target on it is
missing. It currently does not however handle the case where partition 12
exists but is unmountable.
An existing but unmountable partition 12 turns out to be the default case
for devices with a 4k block size. This is because the FAT file system on
partition 12 is created for a USB stick (with 512-byte sectors), and then
dd-blasted onto the 4k-sector device. This results in an unmountable
partition 12, and then update_kernel.sh dies during update.
This change simply makes the script aware of the possibility that mount
might fail. In tandem, we should shrink the partition 12 size down to zero
on this device. But this fix is still worthwhile as it's likely to bite every
new board bringing up a 4k-sector primary storage device.
BUG=b:116515062
TEST=Run update_kernel.sh with /dev/sda12 zeroed out, and not zeroed out,
use -x to observe script behaving properly.
Change-Id: Ie2609f1fcab65b40c231a59d525f7938a259cb6f
Reviewed-on: https://chromium-review.googlesource.com/1255942
Commit-Ready: Evan Green <evgreen@chromium.org>
Tested-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/update_kernel.sh b/update_kernel.sh
index 0a4e155..9f7e408 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -190,21 +190,24 @@
update_syslinux_kernel() {
# ARM does not have the syslinux directory, so skip it when the
- # partition or the syslinux vmlinuz target is missing.
+ # partition is missing, the file system fails to mount, or the syslinux
+ # vmlinuz target is missing.
echo "updating syslinux kernel"
remote_sh grep $(echo ${FLAGS_device}${PARTITION_NUM_EFI_SYSTEM} | cut -d/ -f3) /proc/partitions
if [ $(echo "$REMOTE_OUT" | wc -l) -eq 1 ]; then
remote_sh mkdir -p /tmp/${PARTITION_NUM_EFI_SYSTEM}
- remote_sh mount ${FLAGS_device}${PARTITION_NUM_EFI_SYSTEM} /tmp/${PARTITION_NUM_EFI_SYSTEM}
+ if remote_sh mount ${FLAGS_device}${PARTITION_NUM_EFI_SYSTEM} \
+ /tmp/${PARTITION_NUM_EFI_SYSTEM}; then
- if [ "$FLAGS_partition" = "${FLAGS_device}${PARTITION_NUM_KERN_A}" ]; then
- target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.A"
- else
- target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.B"
+ if [ "$FLAGS_partition" = "${FLAGS_device}${PARTITION_NUM_KERN_A}" ]; then
+ target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.A"
+ else
+ target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.B"
+ fi
+ remote_sh "test ! -f $target || cp /boot/vmlinuz $target"
+
+ remote_sh umount /tmp/${PARTITION_NUM_EFI_SYSTEM}
fi
- remote_sh "test ! -f $target || cp /boot/vmlinuz $target"
-
- remote_sh umount /tmp/${PARTITION_NUM_EFI_SYSTEM}
remote_sh rmdir /tmp/${PARTITION_NUM_EFI_SYSTEM}
fi
}