Gentoo Archives: gentoo-user

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

Replies

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