Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] SD memory card not erasing, even with dd.
Date: Wed, 29 Dec 2021 14:21:59
Message-Id: d0c686d1-b8e3-c408-5c33-489b993bea3a@gmail.com
In Reply to: Re: [gentoo-user] SD memory card not erasing, even with dd. by William Kenworthy
1 William Kenworthy wrote:
2 >
3 > On 29/12/21 20:26, Michael wrote:
4 >> On Tuesday, 28 December 2021 20:21:32 GMT Dale wrote:
5 >>> Howdy,
6 >>>
7 >>> As some may recall, I have quite a few deer trail cameras that use SD
8 >>> memory cards.  On occasion some of the cards start acting weird.  I've
9 >>> got one that is really weird.  Usually I just replace them but this one
10 >>> is a bit of a puzzle I'd like to solve.  When it stopped working, it
11 >>> had
12 >>> a dozen or so short videos on it that are about 30MBs on average.  Some
13 >>> color and large, some black and white night vision and fairly small.
14 >>> When it stopped working, I tried to reformat the thing.  The files
15 >>> remained even after that.  I then ran dd and zeroed the thing, files
16 >>> still there even tho dd reported no problems.  I then used this GUI
17 >>> disk
18 >>> program that tests memory cards and it claims the card is fine.  It
19 >>> writes files to it, reads them back.  I also used it to reformat the
20 >>> card.  The original videos are still there.  Today I decided to play
21 >>> with it again.  I ran this dd command on the stick.
22 >>>
23 >>>
24 >>> root@fireball / # dd if=/dev/zero of=/dev/sdh bs=4K conv=notrunc
25 >>> oflag=direct status=progress
26 >>> 31907364864 bytes (32 GB, 30 GiB) copied, 3956 s, 8.1 MB/s
27 >>> dd: error writing '/dev/sdh': No space left on device
28 >>> 7791745+0 records in
29 >>> 7791744+0 records out
30 >>> 31914983424 bytes (32 GB, 30 GiB) copied, 3956.94 s, 8.1 MB/s
31 >>> root@fireball / #
32 >>>
33 >>>
34 >>> As you can see, no errors. It wrote zeros until it ran out of space.
35 >>> Guess what, the original videos are still on the card.  File listing:
36 >>>
37 >>>
38 >>> root@fireball / # ls -al /run/media/dale/2140-2E00/DCIM/100MEDIA/*
39 >>> -rw-r--r-- 1 dale users        0 May  6  2018
40 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/AAAAAAAA.AAA
41 >>> -rw-r--r-- 1 dale users        0 May  6  2018
42 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/BBBBBBBB.BBB
43 >>> -rw-r--r-- 1 dale users 14335272 May  2  2018
44 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0823.AVI
45 >>> -rw-r--r-- 1 dale users 50843576 May  6  2018
46 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0824.AVI
47 >>> -rw-r--r-- 1 dale users 53137560 May  6  2018
48 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0825.AVI
49 >>> -rw-r--r-- 1 dale users 18398504 May  6  2018
50 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0826.AVI
51 >>> -rw-r--r-- 1 dale users 18922808 May  6  2018
52 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0827.AVI
53 >>> -rw-r--r-- 1 dale users 18332888 May  6  2018
54 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0828.AVI
55 >>> -rw-r--r-- 1 dale users 18726200 May  6  2018
56 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0829.AVI
57 >>> -rw-r--r-- 1 dale users 18332920 May  6  2018
58 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0830.AVI
59 >>> -rw-r--r-- 1 dale users 18005288 May  6  2018
60 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0831.AVI
61 >>> -rw-r--r-- 1 dale users 17612088 May  6  2018
62 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0832.AVI
63 >>> -rw-r--r-- 1 dale users 17153336 May  6  2018
64 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0833.AVI
65 >>> -rw-r--r-- 1 dale users 16694584 May  6  2018
66 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0834.AVI
67 >>> -rw-r--r-- 1 dale users        0 May  6  2018
68 >>> /run/media/dale/2140-2E00/DCIM/100MEDIA/WGI_0835.AVI
69 >>> root@fireball / #
70 >>>
71 >>>
72 >>>
73 >>> The zero byte files are broken, my first clue way back that the card
74 >>> needed replacing.  I see no errors in dmesg or messages.  Usually the
75 >>> cards produce errors and it remounts read only.  Not in this case tho.
76 >>> Mount info:
77 >>>
78 >>>
79 >>> root@fireball / # mount | grep sdh
80 >>> /dev/sdh1 on /run/media/dale/2140-2E00 type vfat
81 >>> (rw,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0022,dmask=0022,codepage=43
82 >>>
83 >>> 7,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,
84 >>>
85 >>> uhelper=udisks2) root@fireball / #
86 >>>
87 >>>
88 >>>
89 >>> In the past, I've at times been able to copy the files off other cards
90 >>> going bad but it stays read only.  Reformating fails etc etc.
91 >>> Sometimes, it just plain doesn't work.  Almost always tho I get a error
92 >>> of some kind in messages or dmesg if not both.  This one tho, it's just
93 >>> plain weird.  No errors but nothing removes the files either.  Oh, I've
94 >>> checked the lock button.  It's not locked.  It is shown that way in
95 >>> dmesg as well.
96 >>>
97 >>>
98 >>> [2592841.808336] sd 10:0:0:2: [sdh] Write Protect is off
99 >>>
100 >>>
101 >>>
102 >>> Obviously I'm not going to trust this thing.  It will end up in the
103 >>> trash but, does this make sense to anyone else?  Of all the ones I've
104 >>> worn out, this is the only one that behaves this way.  I'd at least
105 >>> expect the format to fail or it only mount read only.  At least some
106 >>> sort of error anyway.
107 >>>
108 >>> Thoughts?
109 >>>
110 >>> Dale
111 >>>
112 >>> :-)  :-)
113 >> I don't think I've come across something like this before.  In my
114 >> case data is
115 >> lost, occasionally irretrievably.
116 >>
117 >> I suppose something has switched blocks on the SD as immutable,
118 >> probably a
119 >> controller having a hiccup.
120 >>
121 >> You could try blkdiscard to erase blocks directly - but I haven't
122 >> tried this
123 >> on an SD.  I also haven't tried to know if it will work at all
124 >> hdparm's secure
125 >> deletion.
126 >>
127 >> However, the best option is to see if the OEM offers a reset app for
128 >> this
129 >> particular card and use that.
130 >
131 > I have a few SD cards as OS disks on raspberry pi, odroids etc. One
132 > has your symptoms like yours - read only when it says its in write
133 > mode.  Took two days after the last write to syslog to drop dead -
134 > just before Christmas too, luckily it was part of a moosefs cluster so
135 > I could leave it in maintenance mode without affecting service -
136 > replaced today.  No salvaging it unfortunately - also not the first
137 > one that I have had die like this.  I tested some others and have one
138 > thats really slow when dd'ing zeros to clear vacant space (I think
139 > that's redundant for SD cards, better to trim it?) before making a
140 > compressable backup image.  It also drops to RO with no errors in
141 > syslog before completing.  So I am down 2 cards and need to order some
142 > more spares before another fails :(
143 >
144 > BillK
145 >
146 >
147 >
148 >
149
150
151 So while rare, it's not just me.  ;-)  I've had cards fail by just plain
152 refusing not to mount at all, mounting read only and such.  I've never
153 had one to fail like this tho.  I guess if this was some sort of
154 sensitive files, I'd have to put it in a shredder or take a pair of
155 scissors to it.  LOL 
156
157 I ordered 6 new cards as replacements.  They came in yesterday.  Like I
158 said, I wouldn't trust that card even if it started working again.  So,
159 off to the trash the weird card goes.  Now I just have to wonder why dd
160 and such didn't report problems.  :/ 
161
162 Thanks to all for the info.  Interesting. 
163
164 Dale
165
166 :-)  :-) 

Replies

Subject Author
Re: [gentoo-user] SD memory card not erasing, even with dd. Mark Knecht <markknecht@×××××.com>