flashing SD card fails at 99% on Mac under Big Sur

Using Balena Etcher 1.5.112 I get a failure at flashing a 128Gb SD card with an image created from a Raspberry Pi 128Gb SD card system.

Below are the snippets of the log output when the failure occurs (I’ve not included all of the log entries showing the successful writes up to the point of failure)

[51216:1210/135145.562550:INFO:CONSOLE(6038)] “Flashing 1 device, 99% at 55.40 MB/s (total 55.40 MB/s) eta in 7s with 0 failed devices”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (6038)

[51216:1210/135146.564230:INFO:CONSOLE(6038)] “Flashing 1 device, 99% at 56.40 MB/s (total 56.40 MB/s) eta in 6s with 0 failed devices”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (6038)

[51216:1210/135146.758971:INFO:CONSOLE(56878)] “Thu Dec 10 2020 13:51:46 GMT+0000 (Greenwich Mean Time) Input/output error ({“image”:{“size”:128177930240,“compressedSize”:11563684702,“hasMBR”:true,“path”:”/Users/ksaro1/Desktop/20201209_161116_pi_clone.gz",“partitions”:[{“offset”:4194304,“size”:268435456,“type”:12,“index”:1},{“offset”:272629760,“size”:127905300480,“type”:131,“index”:2}],“isCompressed”:true,“name”:“20201209_161116_pi_clone”,“isSizeEstimated”:true,“extension”:“gz”},“drives”:[{“size”:127865454592,“isVirtual”:false,“enumerator”:“DiskArbitration”,“logicalBlockSize”:512,“raw”:"/dev/rdisk6",“error”:null,“isReadOnly”:false,“displayName”:"/dev/disk6",“blockSize”:512,“isSCSI”:false,“isRemovable”:true,“device”:"/dev/disk6",“busVersion”:null,“isSystem”:false,“busType”:“Secure Digital”,“isCard”:true,“isUSB”:false,“devicePath”:“IODeviceTree:/PCI0@0/RP10@1D,1/SDXC@0,1”,“mountpoints”:[{“path”:"/Volumes/boot",“label”:“boot”}],“description”:“Apple SDXC Reader Media”,“isUAS”:null,“partitionTableType”:“mbr”}],“driveCount”:1,“uuid”:“e6ca9510-c9af-4c55-a4f5-fdb2f3bac997”,“flashInstanceUuid”:“e6ca9510-c9af-4c55-a4f5-fdb2f3bac997”,“unmountOnSuccess”:true,“sample”:0.1,“applicationSessionUuid”:“f2cbf9a9-af7d-48c0-ade6-c27a79e493aa”,“flashingWorkflowUuid”:“7f8acb00-b810-4f8b-b899-6e6b7d83333f”})", source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (56878)

[51216:1210/135147.568855:INFO:CONSOLE(6038)] “Flashing 0 devices, 99% at 56.90 MB/s (total 0.00 MB/s) eta in 6s with 1 failed device”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (6038)

[51216:1210/135201.053464:INFO:CONSOLE(56878)] “Finish: 127851823104”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (56878)

[51216:1210/135201.468415:INFO:CONSOLE(56878)] “Terminating IPC server”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (56878)

[51216:1210/135201.598249:INFO:CONSOLE(56878)] “Flash results [object Object]”, source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (56878)

[51216:1210/135201.832691:INFO:CONSOLE(56878)] “Thu Dec 10 2020 13:52:01 GMT+0000 (Greenwich Mean Time) Done ({“image”:{“size”:128177930240,“compressedSize”:11563684702,“hasMBR”:true,“path”:”/Users/ksaro1/Desktop/20201209_161116_pi_clone.gz",“partitions”:[{“offset”:4194304,“size”:268435456,“type”:12,“index”:1},{“offset”:272629760,“size”:127905300480,“type”:131,“index”:2}],“isCompressed”:true,“name”:“20201209_161116_pi_clone”,“isSizeEstimated”:true,“extension”:“gz”},“drives”:[{“size”:127865454592,“isVirtual”:false,“enumerator”:“DiskArbitration”,“logicalBlockSize”:512,“raw”:"/dev/rdisk6",“error”:null,“isReadOnly”:false,“displayName”:"/dev/disk6",“blockSize”:512,“isSCSI”:false,“isRemovable”:true,“device”:"/dev/disk6",“busVersion”:null,“isSystem”:false,“busType”:“Secure Digital”,“isCard”:true,“isUSB”:false,“devicePath”:“IODeviceTree:/PCI0@0/RP10@1D,1/SDXC@0,1”,“mountpoints”:[{“path”:"/Volumes/boot",“label”:“boot”}],“description”:“Apple SDXC Reader Media”,“isUAS”:null,“partitionTableType”:“mbr”}],“driveCount”:1,“uuid”:“e6ca9510-c9af-4c55-a4f5-fdb2f3bac997”,“status”:“finished”,“flashInstanceUuid”:“e6ca9510-c9af-4c55-a4f5-fdb2f3bac997”,“unmountOnSuccess”:true,“errors”:[{“name”:“Error”,“description”:“Apple SDXC Reader Media”,“code”:“EIO”,“syscall”:“write”,“errno”:-5,“device”:"/dev/disk6"}],“devices”:{“failed”:1,“successful”:0},“bytesWritten”:127851823104,“sourceMetadata”:{“isCompressed”:true,“name”:“20201209_161116_pi_clone”,“size”:127851823104,“compressedSize”:11563684702,“isSizeEstimated”:false},“sample”:0.1,“applicationSessionUuid”:“f2cbf9a9-af7d-48c0-ade6-c27a79e493aa”,“flashingWorkflowUuid”:“7f8acb00-b810-4f8b-b899-6e6b7d83333f”})", source: file:///Applications/balenaEtcher.app/Contents/Resources/app/generated/gui.js (56878)

Hey Alex, thanks for reaching out, we’ll have a look and get back to you.

I see Input/output error in the logs.

Maybe the SD card has issues.

Can you try with another SD card on Etcher or the same SD card with dd: gunzip -c /Users/ksaro1/Desktop/20201209_161116_pi_clone.gz | sudo dd of=/dev/rdisk6 bs=1048576. The same error will probably happen. Please double check the /dev/rdsik6 is the correct drive before running this !

@zvin I only have the 1 spare 128Gb SD card for now.

I tried your suggestion and indeed the dd failed - see below

saro1@Alexs-iMac.home.gateway:/Users/ksaro1 $ @ dd if=Desktop/20201209_161116_pi_clone of=/dev/rdisk6 bs=1048576

dd: /dev/rdisk6: Input/output error

121943+0 records in

121942+0 records out

So, does this mean the SD card is faulty? I had re-purposed this card from being used in a digital camera where it worked fine.

Could this mean that not all 128Gb SD cards are equal in size?

Could this mean that not all 128Gb SD cards are equal in size?

Yes

So, does this mean the SD card is faulty?

Normally, Etcher will not start flashing if the image does not fit in the drive.
However you can’t know the uncompressed size of gzipped files larger than 4GiB.
Etcher tries to guess it by reading the partition table at the beginning of gzipped disk images but it’s only a guess and the image itself may be larger than the offset + size of the last partition in it.

So maybe the image is too large for the SD card.
If Etcher accepts to flash the uncompressed image, it means that the SD is large enough.

You can get the exact size of your SD card with diskutil info /dev/disk6, check the Disk Size: line.

If it is larger than the image, it means that it is faulty, at least in the last megabytes, otherwise it is just to small for this disk image.

@zvin - I tried your suggestion of flashing the unzipped image and indeed Balena Etcher reports that the SD card was too small for the Image. BUT - the message is odd, as it reports the image as 128Gb and the target card’s size as 128Gb?

See screenshot

$ diskutil info /dev/rdisk6
Device Identifier: disk6
Device Node: /dev/disk6
Whole: Yes
Part of Whole: disk6
Device / Media Name: Built In SDXC Reader

Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None

Content (IOContent): FDisk_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: Secure Digital
SMART Status: Not Supported

Disk Size: 127.9 GB (127865454592 Bytes) (exactly 249737216 512-Byte-Units)
Device Block Size: 512 Bytes

Media OS Use Only: No
Media Read-Only: No
Volume Read-Only: Not applicable (no file system)

Device Location: Internal
Removable Media: Removable
Media Removal: Software-Activated

Solid State: Info not available
Virtual: No

Hello Alex,

The message you’re seing on etcher is because the UI rounds the number (to 128GB) to avoid having to show the a big number expressed in bytes. If we take a look at the exact sizes of both the disk(card) and the image, we’ll probably see that the image is actually a bit bigger than the disk.

From your last message you can see that the disk is 127.9 GB (127865454592 Bytes). To check the exact size of the image, you can try mounting it and then running the same command ( diskutil info diskx) replacing diskx for the disk that was just mounted.

Let us know how that goes.
Cheers,
Nico.

You’re right this message is odd, We’ll improve it in the next release.

Thanks for reporting this.

@ntzovanis - unfortunately the flash image from my Raspberry Pi does not show as a mountable Mac image file. So I can’t see what the flash image size shows as an image. The file size is 119Gb. I don’t know if that means anything though, as the original Balena Etcher, and dd command, show 128Gb being transferred.

Since I wasn’t able to mount the SD card image I took the original Raspeberry Pi 4 SD card that I created the image from and inserted that card into the Mac’s SD card reader. Running diskutil on the Mac, with this card inserted resulted in the following:

/dev/disk2 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *128.2 GB disk2
1: Windows_FAT_32 ⁨boot⁩ 268.4 MB disk2s1
2: Linux ⁨⁩ 127.9 GB disk2s2

This information seems to indicate that indeed the original SD card is 300Mb larger than the other SD card.

So, it would seem that not all SD cards are created equal. This makes cloning of images quite messy. This is a new one to me.

Thanks all for the assistance. I’ve now found that this issue isn’t a Balena Etcher issue at all, but an issue with sizing Raspberry Pi SD card images. I’ve found PiShrink, which shrinks the full SD card image to the smallest size possible. This image can then be flashed to a new SD card using Balena Etcher. Once flashed and booted, the original filesystem size can be restored via the Raspbian config command.