Skip to content

IR: Check target media exists before writing #91

@ts-kris

Description

@ts-kris

For example, if sdimage.tar.xz is present on the USB drive, but the SD card is not inserted, check this ahead of time.

Currently, it obviously eventually fails, but, in a non-obvious way. For example:

Starting image replication...
======= Writing sd filesystem ========
======= Writing emmc filesystem ========

tsimx9 production environment
tsimx9 login: 
One or more operations failed!
==================================================
mklabel /dev/mmcblk1
==================================================
Check /tmp/logs for more information.
...
# cat /tmp/logs/sd-writefs 
+ FS_FMT=ext4
+ FS_CMD=mkfs.ext4
+ PART_FMT=gpt
+ dd 'if=/dev/zero' 'of=/dev/mmcblk1' 'bs=512' 'count=1'
1+0 records in
1+0 records out
512 bytes copied, 0.0001015 s, 5.0 MB/s
+ parted -s -a optimal /dev/mmcblk1 mklabel gpt
Error: device is too small for GPT
+ err_exit 'mklabel /dev/mmcblk1'
+ echo 'mklabel /dev/mmcblk1'
+ exit

The failure is that mklabel had failed. This is because we "cleared" the partition table which actually left a 512 byte file of the same name in /dev/. All write scripts, such as tar, dd, U-Boot, etc., should first verify the target media is present, and err_exit if not with a more appropriate and obvious error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions