The officially official Devuan Forum!

You are not logged in.

#1 2022-01-25 15:38:53

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Micro SD card problem, cannot fix errors.

This PC with Devuan is a lenovo W520, I have a Lexar workflow SR2, a Sandisk adapter and a Samsung 8 GB micro SD.

In devuan it has been mounting read only, It has about 500 mostly PDf's on it. As it was coming up read only and the files are mostly copied elsewhere too I used Gparted to delete the single main partition. It tells me that the operation worke ok, and it shows as empty, then when I try to add a partition it comes up with the preexisting fat 32 partition and shows the 30 or so percent full.

I have now tried to wipe it with gparted at least 10 times, gsdisk at least twice and also tried to zap it with dd.

I take it back to a Windows PC and all the files are still there, I can copy in and out as well as rename all ok from windows.

Repeatedly read only in Devuan, and also in Linux mint it fails to delete the partition, but still gives me sucess messages??

In Linux mint I can delete files from the microsd, which is more than I am getting here at the moment.

Any ideas what I might do differently?

Offline

#2 2022-01-25 16:23:44

Altoid
Member
Registered: 2017-05-07
Posts: 1,429  

Re: Micro SD card problem, cannot fix errors.

Hello:

Would you please run fdisk /dev/sdx -l (as root or sudo) and post the printout?

Mike-thinky wrote:

... and also tried to zap it with dd.

Please post how* you did that, including the terminal printout.

* should be as explained here: https://dev1galaxy.org/viewtopic.php?pid=33887#p33887

Best,

A.

Offline

#3 2022-01-25 16:41:28

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Hi,

Last time I id this:

sudo dd if=/dev/zero of=/dev/sdc bs=1k count=2048000
2048000+0 records in
2048000+0 records out
2097152000 bytes (2.1 GB, 2.0 GiB) copied, 2618.76 s, 801 kB/s

that apparently worked, but still the files were visible on a Windows PC.

But this time using your version:

sudo dd if=/dev/zero of=/dev/sdc bs=4096
[sudo] password for mike: 
dd: error writing '/dev/sdc': No space left on device
1926913+0 records in
1926912+0 records out
7892631552 bytes (7.9 GB, 7.4 GiB) copied, 364.007 s, 21.7 MB/s

And Gparted still thinks it has a FAT32 partition on it. And from windows I can still see the files, and it is not write protected either.

Offline

#4 2022-01-25 17:22:56

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Micro SD card problem, cannot fix errors.

Did you reboot after using dd?

This command should make the kernel aware of the new (lack of) partition table on the device without needing to reboot:

# partprobe /dev/sdc

The partprobe command is supplied by the parted package.

If that still doesn't work then try clearing any magic strings with

# wipefs --all --backup /dev/sdc

If you accidentally target the wrong drive the strings can be restored by referring to the EXAMPLES section of man wipefs.

And if the device still seems to have files on it even after using wipefs then please share the fdisk output requested above and also the content of dmesg after plugging in the device.


Brianna Ghey — Rest In Power

Offline

#5 2022-01-25 18:57:12

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

I am finally getting a few steps forward, I have 6 microsd's all done at about the same time, formatted on the same windows PC.

Several of them now seem to have many issues on them. I think the safest thing to do would be just to start afresh, there were differences in the copies of the FAT and partition tables that crept in somewhere along the way,

No I did not reboot after running dd, is that an issue for a removable disk? I took it out, waited a bit then plugged it in again, is that not enough?

I also asked gparted to read the devices again, it still came up with the Fat32 partition.

I will try those after supper that is now imminent.

Offline

#6 2022-01-25 20:42:11

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Micro SD card problem, cannot fix errors.

Mike-thinky wrote:

Last time I id this:

sudo dd if=/dev/zero of=/dev/sdc bs=1k count=2048000

that apparently worked, but still the files were visible on a Windows PC.

didn't really work. you only wrote 2G on sdc with that ("count=").

Mike-thinky wrote:

But this time using your version:

sudo dd if=/dev/zero of=/dev/sdc bs=4096
7892631552 bytes (7.9 GB, 7.4 GiB) copied, 364.007 s, 21.7 MB/s

this version correctly writes the whole disk (8G, till no space left...).
---
had similar trouble with a samsung micro sd + 2 different sd adapters (samsung/sandisk).
i could wipe/fix from another system (eg. mobian), and it would work on all systems. but if i tried that on devuan and partner's lmde, it would produce many dmesg errors (fs/io/disk/driver), and make the card unreadable/unrecognisable after a while. (note, all 3 OS's are debian based, so i'm not sure it's the utilities fault. maybe driver?). and it was never stable, had to format from other systems quite a few times.
a 2nd older kingston micro sd card, never had similar trouble.

so i'm not sure where's the issue. could be micro sd issue, could be adapter issue, could be desktop issue, could be kernel/driver issue...
not really an expert, just similar experience.

Offline

#7 2022-01-25 21:15:25

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Hi,

I agree that the first one did not wipe the whole disk, but as it only had about 1G of data on it I would have expected it to be empty!

I have also found that I cannot correct the errors by writing an NTFS partition from windows, even diskpart would not do it.

Offline

#8 2022-01-25 23:43:30

Altoid
Member
Registered: 2017-05-07
Posts: 1,429  

Re: Micro SD card problem, cannot fix errors.

Hello:

Mike-thinky wrote:

... all done at about the same time, formatted on the same windows PC.
Several of them now seem to have many issues ...
---
... found that I cannot correct the errors by writing an NTFS partition from windows ...

Please *stop* with all the Windows stuff ...
It's probably what screwed up the Micro SDs in the first place.

Now, did you follow Head_on_a_Stick's instructions?

ie:

As root do:
# wipefs --all --backup /dev/sdx

--> Make sure you do this with the proper drive letter and omit the --backup bit<--
There's no turning back from wipefs

After you have done that, do # partprobe /dev/sdx

The OS will know what the drive is now all about.

Then do sudo fdisk -l /dev/sdx

Please post the terminal output of the whole process.

Best,

A.

Last edited by Altoid (2022-01-25 23:49:38)

Offline

#9 2022-01-26 06:25:46

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Micro SD card problem, cannot fix errors.

Altoid wrote:

There's no turning back from wipefs.

Yes there is — that's what the --backup option is for. The man page explains what it does and how to use the backup file to restore the magic strings to a device.


Brianna Ghey — Rest In Power

Offline

#10 2022-01-26 07:19:23

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Hi Altoid,

There are many many cases on the web of this ame issue occurring on Linux systems, I tried winows again merely because Devuan was saying yep, the wipe succeeeded, but gparted was lying to me, the partition was NOT wiped. It is not clear if it is the OS or caused by bad hardware,
Trouble is the hardware is all respectable brands.

I am going to spend a few days looking into the MBR and see if that is borked, then manually repair them, it seems winows and linux are both flaky at doing this right always.

Offline

#11 2022-01-26 09:59:55

Camtaf
Member
Registered: 2019-11-19
Posts: 408  

Re: Micro SD card problem, cannot fix errors.

First, make sure it is not mounted.
Then, give it a new MBR.
Next partition it.
Finally, put a new file system on it.

(I use fdisk.)

Offline

#12 2022-01-26 10:20:47

Altoid
Member
Registered: 2017-05-07
Posts: 1,429  

Re: Micro SD card problem, cannot fix errors.

Hello:

Head_on_a_Stick wrote:

Yes there is — that's what the --backup option ...

Yes, that is what it is there for.

But (in my opinion) wipefs is a very powerfool tool and --backup gives the user a false sense of security by presenting a remedy/insurance of sorts to not having been thorough enough.

To me (again, my opinion) the only way is to do it right, from the start.
ie: check the drive letter assignment twice or more before you hit Enter, knowing that if you screw it up its contents is all but done for.

It does not make things any harder and keeps you on your toes when using such tools. 

A recent example is the JWT launch.
There was no fall back if the 25 year/US$ 10+ billion state of the art telescope's launch went south.
So everything was checked, re-checked and re-checked again.

There are many other albeit less extreme examples.

I've screwed up, by various means, more than a drive in my time.
I eventually learnt what to do and how to do it as well as what not to do.

Of course, YMMV.  8^D

Best,

A.

Last edited by Altoid (2022-01-26 10:42:43)

Offline

#13 2022-01-26 10:40:27

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Hi Camtaf,

The problem I am having is that the two MBR's are out of sync, as well as the tqo partition maps, and fdisk is refusing to fix it for me...

So I am now trying to have a look at the mbr and partitiion table settings in detail to try and work out what went wrong. It seems many others on the web have been bitten by this.

Offline

#14 2022-01-26 10:41:49

Altoid
Member
Registered: 2017-05-07
Posts: 1,429  

Re: Micro SD card problem, cannot fix errors.

Hello:

Mike-thinky wrote:

... many cases on the web of this <s>ame issue occurring on Linux ...
... gparted was lying to me ...

MS software is and has been for the longest time notorious for not adhering to established standards/rules.
To MS, if it works with their software and the drivers hardware OEMs write for their OSs, it is good enough.

The web is full of examples, the most annoying one being all the horribly written BIOSs Linux OSs have had to deal with for ages.
As long any crap ridden BIOS worked with a MS OS, it was Windows XX Certified.

Obviously, it was not an issue if it did not work with any other OS.
eg: a Linux based OS.

All PCs were/are still sold with a MS OS, whether you want/ed it or not, so what problem could there possibly be?

I doubt that gparted is lying to you.
It does not have a will of its own.  8^D

What is most probably happening is that the data gparted is reading from the drive does not conform to the established standard.
ie: whatever the MS software wrote on the drive is not written in such a way that gparted can understand it correctly.

Like they say: rubbish in, rubbish out.

Best,

A.

Offline

#15 2022-01-26 11:29:20

rolfie
Member
Registered: 2017-11-25
Posts: 1,055  

Re: Micro SD card problem, cannot fix errors.

Some thoughts to the issues:

When plugging in the SD card reader and the card itself: inspect dmesg for hints if the device is write protected.

To gparted: I am using gparted for many years and never had it fail. I started of with gparted life versions, still use them every now and then.

There may be a trap for the unexperienced user: you can prepare a lot of operations, but these are not executed on the real HW before you don't tick the apply button. Are you aware of this?

In addition I suggest to tick the Device Information box in the View menu. Gives you confirmation that you are working on the right device.

If that does not work the card may be defective.

rolfie

Offline

#16 2022-01-26 14:05:20

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

It is definitely not write protected, when I flicked the switch on the side gparted correctly told me it was unable to write.

The bit I have a problem with is that gparted tells me it had success in deleting the partition, when it clearly didnt, if I unplug and then plug it in again, I can read the files straight away, no windows involved. Gparted ought to be looking deeper into whether the files are gone. I agree it was MS that started the mess with straying from the original standard. Since then the software ought to be able to look at both mbr tables as well as both partition tables and at least warn you in advance that things are not straightforward.

I have successfully used gparted quite a lot at home and at work, but this batch of sd cards is giving me problems, it might have been the cheap no-name card reader I had at the time of creating them? it could be the usb funnies that people have noted with the string usbc plastered into the mbr and partition tables.

Last edited by Mike-thinky (2022-01-26 14:05:47)

Offline

#17 2022-01-26 15:04:17

rolfie
Member
Registered: 2017-11-25
Posts: 1,055  

Re: Micro SD card problem, cannot fix errors.

I am not 100% sure what you try to tell us. You say are aware of the bit that only on "Apply" the actual changes are written to the SD cards. Ok, another bit: gparted is a tool that works on partition information and everything around that, not on file systems directly. Its basically a graphical interface for fdisk and mkfs.

Well, after the "Apply" has finished gparted re-reads the partitioning information for all the devices that are available. If then the same structures are presented for the SD card, then obviously the write operation wasn't successful. I would claim that gparted works quite well. And I would conclude that the involved HW isn't working correctly. If gparted displays that the SD card now is empty, then that is the information that came back from the HW.

What exactly means:

The bit I have a problem with is that gparted tells me it had success in deleting the partition, when it clearly didnt, if I unplug and then plug it in again, I can read the files straight away, no windows involved.

This would be some sort of miracle. Maybe SD card and reader are not compatible, or some sort of buffer is involved, or the SD cards are simply crap.

You seem to have tried dd also, also with no result.

If you sum up all these bits and bytes, what do you think about cards and reader?

rolfie

Offline

#18 2022-01-26 15:28:30

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Micro SD card problem, cannot fix errors.

Altoid wrote:

But (in my opinion) wipefs is a very powerfool tool and --backup gives the user a false sense of security by presenting a remedy/insurance of sorts to not having been thorough enough.

But it's not a "false" sense of security because the remedy actually works.

Mike-thinky wrote:

[wall of meaningless text]

Why are you not providing the requested fdisk and dmesg output? Is this a wind-up? It's certainly winding me up...

Anyway good luck. I'm out.


Brianna Ghey — Rest In Power

Offline

#19 2022-01-26 15:32:10

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

They are Samsung cards, I have used the internal card reader in the Lenovo, as well as two external readers, one of which is a lexor device that had good reviews at the time I bought it. The adaptors for the micro/SD conversion are samsung or sandisk.

Part of the problem may be that they were partitioned on Windows, but gparted is supposed to be able to cope.

I have tried dd, gparted and wipefs:

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0   1.8T  0 disk 
├─sda1        8:1    0  23.3G  0 part /
├─sda2        8:2    0     1K  0 part 
├─sda5        8:5    0   9.3G  0 part /var
├─sda6        8:6    0   976M  0 part [SWAP]
├─sda7        8:7    0  18.6G  0 part /tmp
└─sda8        8:8    0   1.8T  0 part /home
sdb           8:16   0 931.5G  0 disk 
├─sdb1        8:17   0   128M  0 part 
└─sdb2        8:18   0 931.4G  0 part /data
sdd           8:48   1   7.4G  0 disk 
└─sdd1        8:49   1   7.3G  0 part 
sr0          11:0    1  1024M  0 rom  
mmcblk0     179:0    0   7.4G  0 disk 
└─mmcblk0p1 179:1    0   7.3G  0 part 
mike:~$ sudo wipefs --all --backup /dev/sdd
wipefs: error: /dev/sdd: probing initialization failed: Device or resource busy
mike:~$ sudo wipefs --all --backup /dev/sdd
/dev/sdd: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdd: calling ioctl to re-read partition table: Success
mike:~$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0   1.8T  0 disk 
├─sda1        8:1    0  23.3G  0 part /
├─sda2        8:2    0     1K  0 part 
├─sda5        8:5    0   9.3G  0 part /var
├─sda6        8:6    0   976M  0 part [SWAP]
├─sda7        8:7    0  18.6G  0 part /tmp
└─sda8        8:8    0   1.8T  0 part /home
sdb           8:16   0 931.5G  0 disk 
├─sdb1        8:17   0   128M  0 part 
└─sdb2        8:18   0 931.4G  0 part /data
sdd           8:48   1   7.4G  0 disk 
└─sdd1        8:49   1   7.3G  0 part 
sr0          11:0    1  1024M  0 rom  
mmcblk0     179:0    0   7.4G  0 disk 
└─mmcblk0p1 179:1    0   7.3G  0 part 

So is read the blocks, sdd is the one I want to clear, I run wipefs, and it still reports a partition and gparted then also reports a fat32 partition on it, am I missing something?

Last edited by Mike-thinky (2022-01-26 15:32:47)

Offline

#20 2022-01-26 15:53:28

rolfie
Member
Registered: 2017-11-25
Posts: 1,055  

Re: Micro SD card problem, cannot fix errors.

From man wipefs:

wipefs allows to erase filesystem or raid signatures (magic strings) from the device to make the filesystem invisible for libblkid. wipefs does not erase the whole filesystem or any other data from the device. When used without options -a or -o, it lists all visible filesystems and offsets of their signatures.

Offline

#21 2022-01-26 19:57:05

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Micro SD card problem, cannot fix errors.

sd cards are usually /dev/mmcblk0. what's the /dev/sdd then? is it another adapter with a different sd card?
when you get device busy or similar, try restarting and redoing whatever you were trying.  maybe better to add `sync` after any dd command also..
if you want to try another gui, gnome-disk-utility might come in handy.

and please provide dmesg and fdisk output as already requested.. probably crap cards/adapters/driver, but without logs, noone can tell for sure.

rolfie, not a miracle (who believes in miracles anyway?). if you read my previous comment, i had similar experience without windoze.
another kingston micro sd still works fine, so i just sent samsung one to recycle bin.. but yes, gparted/dd/utilities and/or sd card and/or adapter and/or driver is buggy. no miracle involved whatsover.

Offline

#22 2022-01-26 21:52:53

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Well I dug around all the spare computer stuff around the house and discovered 11 other sd cards of various sizes that all work, I can add and delete files, I could reformat 2 of them (empty already).
I have these 5 with zombie file systems on them, all Samsung.
On the reading side I have the built in SD reader (it never used to stay working under windows), a usb3 Lexar SD reader, and a no name items that all work with the good cards,
The adaptors are a selection of Samsung, SanDisk and 2 PNY brand micro-SD adaptors. Two of them only work as read only, so have been marked as such.

The dmesg dump is quite large, how much of it is needed? last 20 lines? last 50 or 100?

I now have a handle on which bits of other kit seem to be functional, when it was 5 faulty and 1 good sd card I could not be sure where the fault lay.

Offline

#23 2022-01-27 06:23:59

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Micro SD card problem, cannot fix errors.

Mike-thinky wrote:

The dmesg dump is quite large, how much of it is needed? last 20 lines? last 50 or 100?

Remove the SD card then open a terminal and run this command (as root):

dmesg -w

Then insert the SD card and only post any new output that appears in the terminal after you insert the card.

Last edited by Head_on_a_Stick (2022-01-27 07:16:16)


Brianna Ghey — Rest In Power

Offline

#24 2022-01-27 18:49:55

Mike-thinky
Member
Registered: 2021-10-28
Posts: 62  

Re: Micro SD card problem, cannot fix errors.

Hi,

This is the dmesg output:

[1257191.630039] mmc0: new high speed SDHC card at address 59b4
[1257191.630340] mmcblk0: mmc0:59b4 00000 7.35 GiB 
[1257191.649111]  mmcblk0: p1
[1257192.028782] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

At this stage I know I cannot trust the data on there, but I still do not unerstand why I cannot force a full redo of the mbr and partitions. I think I am sending commands to do that, gparted reports that it has not failed. But the card is not cleared down, I feel I need to understand this better otherwise I would just let it go and throw the cards away.
But before I come to that point I would like to understand what is and is not happening under the hood.

Offline

#25 2022-01-28 08:54:06

FM81
Member
Registered: 2017-09-16
Posts: 30  

Re: Micro SD card problem, cannot fix errors.

Mike-thinky wrote:

... but I still do not unerstand why I cannot force a full redo of the mbr and partitions. I think I am sending commands to do that, gparted reports that it has not failed. But the card is not cleared down ...

May be, the card has reached "end of life"? At this point the internal controller (inside the card) goes to "read-only" (this has nothing to do with any kind of mechanical switch on side of the card) and may be, he gives no information back about doing so. So the underlying operation-system oder any kind of software (like GParted) thinks, everything is fine and you'll get no errors here.

Best Regards, FM_81


The most brilliant role in comedy is that of a fool, he must not be in order to make it seem. (Miguel de Cervantes)

Offline

Board footer