Last active
May 7, 2025 19:07
-
-
Save Neradoc/c1d0f74c0a3ee7d514d40d38686add7a to your computer and use it in GitHub Desktop.
Remount all Circuitpython/Microcontroller drives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cpremount() { | |
# | |
# This works around bug where, by default, | |
# macOS 14.x before 14.4 writes part of a file immediately, | |
# and then doesn't update the directory for 20-60 seconds, causing | |
# the file system to be corrupted. | |
# | |
if [[ "$1" != "" ]]; then | |
_drive="$1" | |
echo "Remounting $_drive" | |
disky=`df | grep "$_drive" | cut -d" " -f1` | |
if [[ "$disky" != "" ]]; then | |
sudo umount /Volumes/"$_drive" | |
sudo mkdir /Volumes/"$_drive" | |
sleep 2 | |
sudo mount -v -o noasync -t msdos $disky /Volumes/"$_drive" | |
else | |
echo "Drive $1 not found" | |
fi | |
else | |
# Find all microcontroller drives with discotool | |
for volume in `discotool get volume`; do | |
_drive=`basename $volume` | |
if [[ "$_drive" != "" ]]; then | |
cpremount "$_drive" | |
fi | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment