hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

Flash error: hdiutil: couldn't unmount "disk2" - Resource busy #169

Closed xunholy closed 4 years ago

xunholy commented 4 years ago

Whilst running my flash command as follows;

flash \
    --userdata setup/cloud-config.yml \
    ~/Downloads/ubuntu-19.10.1-preinstalled-server-arm64+raspi3.img

I get a sporatic error where my flash gets to the end and then fails with the following response:

Is /dev/disk2 correct? y
Unmounting /dev/disk2 ...
Unmount of all volumes on disk2 was successful
Unmount of all volumes on disk2 was successful
Flashing ~/Downloads/ubuntu-19.10.1-preinstalled-server-arm64+raspi3.img to /dev/rdisk2 ...
Password:
0+47533 records in
0+47533 records out
3115115520 bytes transferred in 109.241900 secs (28515757 bytes/sec)
Mounting Disk
Mounting /dev/disk2 to customize...
Copying cloud-init setup/cloud-config.yml to /Volumes/system-boot/user-data ...
Unmounting /dev/disk2 ...
hdiutil: couldn't unmount "disk2" - Resource busy
Something went wrong.

Not sure how to reproduce it however it happens at least 7/10 times I attempt to flash my card.

xunholy commented 4 years ago

Fixing this locally on my MacOS I just tweaked the following:

echo "Unmounting ${disk} ..."
sleep 5

I'm guessing there might have been some type of race condition or the copy operation wasn't completed and/or verified before performing the detach so increasing the sleep to 5 was adequate for the copy to complete gracefully.

StefanScherer commented 4 years ago

Closed by #171

xunholy commented 4 years ago

Thanks @StefanScherer - look forward to the next release 👍

StefanScherer commented 4 years ago

@xUnholy flash version 2.6.0 is released. :shipit: