hypriot / flash

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

Recognize write-protected SD cards #16

Closed StefanScherer closed 8 years ago

StefanScherer commented 9 years ago

After Matt's blog post http://matthewkwilliams.com/index.php/2015/09/07/troubleshooting-microsd-card-problems/ I got the same issue on my Mac today. Just plugged in the micro SD card adapter once too often I think, the slider went to write-protect.

The flash script just hangs with

Is /dev/disk2s1 correct? y
Unmounting disk2 ...
Unmount of all volumes on disk2 was successful
Unmount of all volumes on disk2 was successful
Flashing /tmp/hypriot-rpi-20150908-173232.img to disk2 ...
Password:
dd: /dev/rdisk2: Permission denied
  64KiB 0:00:00 [9.09MiB/s] [>                                              ]  0%            

Investigating the problem shows:

$ df
Filesystem    512-blocks      Used Available Capacity  iused    ifree %iused  Mounted on
/dev/disk1     974700800 724069208 250119592    75% 90572649 31264949   74%   /
devfs                666       666         0   100%     1153        0  100%   /dev
map -hosts             0         0         0   100%        0        0  100%   /net
map auto_home          0         0         0   100%        0        0  100%   /home
/dev/disk2s1      130780     58392     72388    45%      512        0  100%   /Volumes/NO NAME
~
$ ls -l /dev/disk2
br--r-----  1 root  operator    1,   5 Sep  8 19:50 /dev/disk2
~
$ ls -l /dev/rdisk2
cr--r-----  1 root  operator    1,   5 Sep  8 19:50 /dev/rdisk2

After removing the write-protection and plugging in the SD card again it shows

$ ls -l /dev/disk2
brw-r-----  1 root  operator    1,   5 Sep  8 19:52 /dev/disk2
~
$ ls -l /dev/rdisk2
crw-r-----  1 root  operator    1,   5 Sep  8 19:52 /dev/rdisk2
~
$ ls -l /dev/disk2s1
brw-r-----  1 root  operator    1,   6 Sep  8 19:52 /dev/disk2s1