Backup data from corrupted (?) card

Hi all!
I think that the mysd got corrupted somehow. When it’s on my pi4 the green light flash a couple of times, then turned off, and i can’t use the raspberry.

I was trying to get a backup of the card via Win32DiskImager, but the process fails at 4%.
Is there any way to backup my dietpi and installed programs data, so i can format the card and trying to put everything back at it?

you could try to connect the SD card into another Linux box as USB device and run some file system checks.

If you have no other Linux box: Spinning up a DietPi VirtualBox or VMware image on Windows is done quite quickly.

I got Dietpi running on a virtula machine, what should i do next?

connect the SD card to your VM (don’t mount it actually) and check the device name

lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid

Once you know the device name, you could run some checks

fsck -a /dev/sdax

replace x with the correct number of your device

Ah, and easily this works only if you use a USB card reader instead of a native SD card slot. Because USB devices can be easily passed through to virtual machines. In VirtualBox there is a menu entry for this on the VMs window when started.

If you have a native SD card slot only, another hack is necessary to generate a fake image file which be attached to the VM.

Dunno how and why, but after plugging the card on my pc and the back on the Pi4, is working fine again.
Anyway, i would like to do a full back-up, what’s the best solution?

you could use dietpi-backup and use another / alternative USB pen stick as backup target.

Card stopped working again :face_with_head_bandage:

I’ve run your commands and this is what i have


you need to perform checking on a different system/installation where your disk is not mounted.

3

just to avoid a misunderstanding. Which of your drives has issues? I see two drives connected?

BTW: if possible try to copy information from SSH terminal directly and avoid doing screen prints.

I don’t know why it shows 2 drives, it’s a single microsd card.

Maybe sdb1 sdb2 are partitions?

I think the confusion was that you tried fsck /dev/sdaX as well as fsck /dev/sdbX, while the first is the rootfs of the external system where you are trying to repair the SD card, right? Try this:

apt install dosfstools
dosfsck -p /dev/sdb1
fsck -fp /dev/sdb2

I’m sorry for the image again, but i cannot find a way to copy text
1

Are you connected via SSH?

I’m using Terminal on a dietpi installation on a VmWare workstation player virtual machine

you could use SSH as well on this setup :slight_smile:
Might be easier to copy/past stuff

Back to your issue. Seems some errors are corrected. You could try to perform the check again. Hopefully no additional issues.

performed tests again and this is the result

dosfsck -p /dev/sdbl
fsck.fat 4.2 (2021-01-31)
/dev/sdb1: 388 files, 69144/258077 clusters
root@DietPi:"# fsck -fp /dev/sdb2
fsck from util-linux 2.36.1
[ 100.188195] sd 3:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_ag e=6s
e=6s
[ 100.189277] sd 3:0:0:0: [sdb] tag#0 Sense Key : Aborted Command [current]
[ 100.189740] sd 3:0:0:0: [sdb] tag#0 Add. Sense: Incompatible medium installed
[ 100.190188] sd 3:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 c5 3a dO 00 00 d8 00
[ 100.190633] blk_update_request: I/O error, dev sdb, sector 12925648 op OxO:(READ) flags 0x80700 p hys_seg 2 prio class 0
hys_seg 2 prio class 0

I’ve give up trying to recover this. I just formatted and reinstalled.
Thanks for you help!

If possible think of using a USB pen drive instead of SD card. Way more reliable as SD card not really designed for 24/7 operation.

2 Likes