Page 1 of 1

SD Card permanently locked

Posted: Fri Aug 25, 2017 12:39 pm
by bleep42
I recently had this problem.
I have a 16Gb micro sd card, (with no external lock) which has on it Noobs with Risc OS, Raspbian, LibreElec.
I wanted to play with the partitions using gparted on a separate laptop running Ubuntu.
Specifically I wanted to decrease the size of the LibreElec partition and give the space to the Raspbian partition, these used partitions 9, 10 and 11, so easy.
First I made a copy of the whole sd card as a backup image using Win32DiskImager, just in case, so I could always go back.
I then tried to change the partition layout using gparted, but although it appeared to work, once it finished, the partition layout always appeared to be the same? I put the sd back in my Pi, and sure enough nothing had changed? Eventually after quite a lot of mucking about I realised that the card was completely locked to writing, I tried all the usual reformat methods SDFormatter, HDDLLF, (low level format), 2 different cameras, even

sudo dd if=dev/zero of=/dev/sdb bs=4096 count=4096

to write blanks to the start of the SD. Nothing would write to the SD.
So I decided to write the image file I had taken back onto a fresh new 16Gb micro SD card, using Win32DiskImager, this worked fine, I tested the image, perfect, I could write to it fine, I rebooted, everything was fine. So I removed the SD card and again used Gparted to change the partitions, this time everything worked perfectly, I reduced partition 11 down to 1Gb, moved partition 10 along, so that I could then expand partition 9 into the free space, perfect, everything worked great, I put the SD back into the Pi, perfect, so to be sure I did an

sudo apt-get dist-upgrade

to get Raspbian completely up to date, this worked and everything was fine, rebooted to be sure, yes everything was good and fully updated, so I decided to tidy up, set up a few things the way I wanted, updated a software development directory to my latest sources, all good. I then decided to again back up the SD to an img file using Win32DiskImager, this went ahead ok. I finally put the SD back into the Pi, the SD card was locked!!! So now I have 2 perfectly good 16Gb SD cards, which read fine, but can't be written to, :-( and it would appear that Win32DiskImager did it while *reading* the image :-(
I then came across this
viewtopic.php?p=162205#p162205 and this
viewtopic.php?f=28&t=160955, which lead to this
https://github.com/BertoldVdb/sdtool
I installed the sdtool onto another of my Pis, which has an external disk where /home/pi is located, so that I could then replace it's SD with the duff SD, but still have the sdtool on the disk, ran it and found that both SD cards have the

Code: Select all

[+] Write protection state: Permanent
set, I did try removing it with the unlock command but unsurprisingly it couldn't do it.
So I still have 2 x 16GB micro SD cards, which are effectively bin fodder.
Any one else had problems with SD cards becoming read only? Especially after having used Win32DiskImager?
Regards,
Kevin.

Re: SD Card permanently locked

Posted: Fri Aug 25, 2017 1:09 pm
by Canedje
This is a known problem.
SD cards are read only after be corrupted and breaking down.
It's a build in kind of protection
You need to buy a new one

Re: SD Card permanently locked

Posted: Mon Aug 28, 2017 12:59 pm
by bleep42
Canedje wrote:
Fri Aug 25, 2017 1:09 pm
This is a known problem.
SD cards are read only after be corrupted and breaking down.
It's a build in kind of protection
You need to buy a new one
Is it? Lots of Google searches don't indicate this, if so why?
I was asking if anyone else had experianced problems like this after using Win32DiskImager?
I know it is bin fodder.
Regards,
Kevin.

Re: SD Card permanently locked

Posted: Mon Aug 28, 2017 1:02 pm
by bleep42
bleep42 wrote:
Mon Aug 28, 2017 12:59 pm
Canedje wrote:
Fri Aug 25, 2017 1:09 pm
This is a known problem.
SD cards are read only after be corrupted and breaking down.
It's a build in kind of protection
You need to buy a new one
Is it? Lots of Google searches don't indicate this, if so why? I didn't do anything I shouldn't have and one card was new.
I was asking if anyone else had experianced problems like this after using Win32DiskImager?
I know it is bin fodder.
Regards,
Kevin.

Re: SD Card permanently locked

Posted: Mon Aug 28, 2017 1:14 pm
by DougieLawson
Try qualifying your Google search with "site:raspberrypi.org" it's a FAQ on here.

Re: SD Card permanently locked

Posted: Wed Aug 30, 2017 8:36 am
by bleep42
DougieLawson wrote:
Mon Aug 28, 2017 1:14 pm
Try qualifying your Google search with "site:raspberrypi.org" it's a FAQ on here.
I must be being incredibly stupid as I can't find anything similar to this problem on these forums, no FAQ either.
Regards,
Kevin.

Re: SD Card permanently locked

Posted: Wed Aug 30, 2017 9:32 am
by mahjongg

Re: SD Card permanently locked

Posted: Wed Aug 30, 2017 5:39 pm
by bleep42
mahjongg wrote:
Wed Aug 30, 2017 9:32 am
one example:
viewtopic.php?f=28&t=154914
Thanks mahjongg,
I hadn't found that one, that seem to confirm that it is a problem with Win32DiskImager he says exactly the same as me "It started when I used Win32DiskImger to install a new image file" and both the forum links I put in my waffle also mention Win32DiskImager.
Ok so it looks like Win32DiskImager is purposly and permanently locking SD cards? why would it do that, unless it's malicious?

Regards,
Kevin.

Re: SD Card permanently locked

Posted: Wed Aug 30, 2017 6:09 pm
by gkaiseril
It is also a problem when using a USB card reader on the Pi. The SD card manufacturers have some control bits with the card that indicate a locked condition. Since each manufacturer writes a driver for their cards these control bits are not usable by most users.

Re: SD Card permanently locked

Posted: Thu Aug 31, 2017 5:35 pm
by mahjongg
bleep42 wrote:
Wed Aug 30, 2017 5:39 pm
mahjongg wrote:
Wed Aug 30, 2017 9:32 am
one example:
viewtopic.php?f=28&t=154914
Thanks mahjongg,
I hadn't found that one, that seem to confirm that it is a problem with Win32DiskImager he says exactly the same as me "It started when I used Win32DiskImger to install a new image file" and both the forum links I put in my waffle also mention Win32DiskImager.
Ok so it looks like Win32DiskImager is purposly and permanently locking SD cards? why would it do that, unless it's malicious?

Regards,
Kevin.
I myself dont believe that Win32DiskImager causes an SD-card to become permanently locked, there isn't a universal mechanism to set this bit in the card that works across all cards, and yes, why would they do so. Nor for a moment do I think there could be malicious reasons, that just paranoia talking. I googled, but could find nothing about this Win32DiskImager behavior, but you can check the buglist here: https://sourceforge.net/p/win32diskimag ... rce=navbar

Also you can use another imaging program instead of Win32DiskImager.

an SD-card can set the write protect bit itself if it senses its flash memory cells are becoming difficult to write to....

read this, its interesting.... http://www.bunniestudios.com/blog/?page_id=1022

Re: SD Card permanently locked

Posted: Thu Aug 31, 2017 6:21 pm
by bleep42
Thanks Mahjongg,
I'll have a read of the link, however one of the cards was almost new, so unlikely to be warn out.
Everything was perfect on the second card until I used Win32DiskImager to read an image file, this is on a PC, not the Pi. Then as soon as I plugged it back into my Pi, it was locked. I would agree that it's unlikely to be Win32DiskImager, but...
I haven't found any other nice Image readers and writers, most only write.
Thanks for looking at this,
Regards,
Kevin.

Re: SD Card permanently locked

Posted: Thu Aug 31, 2017 7:29 pm
by jahboater
bleep42 wrote:
Thu Aug 31, 2017 6:21 pm
I haven't found any other nice Image readers and writers, most only write.
Use the Pi itself?

On Linux you have dd which will happily both read and write SD cards.

Then there is PiClone or SD card copier..

Re: SD Card permanently locked

Posted: Sat Feb 03, 2018 7:27 pm
by Polleke
Same problem of "write-protection" with four 16GB microSD cards. Tried all tricks found on the net, with zero result.
BUT THEN I TRIED THIS: I put them in an SD-adapter, and then formatted them in my PHOTOCAMERA (Canon Powershot, but I suspect any camera will do). Worked like a charm !!

Re: SD Card permanently locked

Posted: Tue Apr 10, 2018 12:35 pm
by dwwaddell
I ended up with a 32GB SD card in this condition when I accidentally rebooted the Pi during an "sudo apt upgrade". There is nothing I have been able to do to write to the card to fix the problem.