Tiny Core Linux

General TC => General TC Talk => Topic started by: MTCAT on September 06, 2022, 04:40:38 PM

Title: Data Recovery from bad SSD
Post by: MTCAT on September 06, 2022, 04:40:38 PM
Hello, I'm sorry it's been such a long time since my last visit here, has been a crazy year. I'm still working on my new receivers with VortexDX3 and 24DSI12 with TinyCore kernel 2.6.33.3, just need to incorporate the output of "digitemp" into the acquisition C code and modify as well to report GPS+Glonass+Galileo satellites and that should be it software wise! Thank you very much to Rich, Curaga, patrickg, and many others who have helped so much.

I did an experiment this past long weekend in the extreme heat with my old gear (650 MHz Celeron, Slackware Linux) and it seems that the base station SSD has become damaged (heat stressed ?).

I've attached the output of "fdisk -l" here done on both the rover receiver (which is currently working just fine), and for the base station receiver, which will not boot up at all, I get a bunch of "9A" characters echoed to screen when trying to boot up the base station off the main SSD. The base station and rover receivers were identical, the output of "fdisk -l" should be the same in both cases. Both receivers have 64 GByte SSD's which are reported as PATA on boot up on the rover receiver.

So I booted the base station receiver with one of my old TC sticks (3.8.4, kernel 2.6.33.3, no real time patch) and was able to get an "fdisk -l" output that way on the base station receiver, but I'm not able to mount the (apparently) damaged drive, which is now being reported as ~ 32 GBytes ? (supposed to be 64 GBytes).

There's some data on the base station receiver I would like to recover, but I don't know if this is even possible without being able to mount the drive ?

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 06, 2022, 05:32:51 PM
Hi MTCAT
Do not mount or attempt to write to the disk. You want to try to copy the entire drive and
then work from the copy. This should provide a good starting point:
https://www.linux.com/topic/desktop/gnu-ddrescue-best-damaged-drive-rescue/

Its possible just the partition table got corrupted. Create an image copy of the drive:
Code: [Select]
dd if=/dev/sdb of=base.imgwhere  /dev/sdb  is the damaged drive. Google how to fix partition table and attempt
the fix on the file you created.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 06, 2022, 09:46:42 PM
Hi Rich,

Thanks a lot for the help!, and the link, I'll use dd to make an image of the drive, and then see if I can find any problems with the partition table.

Thanks again,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 06, 2022, 10:51:01 PM
Hi MTCAT
A couple of things. It looks like you used the busybox version of  fdisk  for  base.txt.
Install  util-linux-ng.tcz  and run  fdisk  on the corrupt drive again.

Code: [Select]
tc@E310:~/part$ dd if=/dev/sdg of=base.img
962560+0 records in
962560+0 records out
492830720 bytes (493 MB, 470 MiB) copied, 47.0264 s, 10.5 MB/s
The  dd  command defaults to copying  512  byte blocks so it will take some time to
create the image file. Do not attempt to speed it up by increasing the block size.
Once you've created the image file, you can copy it using the  cp  command to create
additional copies to experiment on.

If  dd  errors out on you, look into  ddrescue.

To use the image file, you need to assign a device to it. You will need  util-linux-ng.tcz
installed for this.
Code: [Select]
tc@E310:~/part$ sudo losetup --show --find --partscan base.img
/dev/loop241
The image file has been assigned to  /dev/loop241.  You can use that anywhere you
would use something like  /dev/sdb.

Code: [Select]
tc@E310:~/part$ fdisk -l /dev/loop241
Disk /dev/loop241: 470 MiB, 492830720 bytes, 962560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2feba4f6

Device         Boot  Start    End Sectors  Size Id Type
/dev/loop241p1        2048 206847  204800  100M 83 Linux
/dev/loop241p2      206848 309247  102400   50M 83 Linux
/dev/loop241p3      309248 923647  614400  300M 83 Linux
And  /dev/loop241  has 3 partitions,  /dev/loop241p1, /dev/loop241p2, and /dev/loop241p3.

When you are done, free up the device:
Code: [Select]
sudo losetup -d /dev/loop241
Title: Re: Data Recovery from bad SSD
Post by: curaga on September 07, 2022, 10:32:46 AM
Just a warning, when SSDs fail, there's a high chance the data is not recoverable at all. That's unlike the old spinning rust, where a data recovery service can usually get most of it back for a fee.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 08, 2022, 09:27:06 PM
Hi Rich and curaga,

Thanks a lot for the help, I still need to get an ethernet connection on my base station receiver when booted with Tinycore, so hopefully I'll have that done soon so I can install util-linux-ng.tcz and maybe ddrescue as well if need be.

So tonight I thought I would just try using dd on /dev/hda3 where all the data is (I think).

I tried making an image of /dev/hda3 with;

dd if=/dev/hda3 of=/dev/sda1/base.img

But I got an error

dd: "Can't open /dev/sda1/base.img' :Not a directory

Seems I need to mount sda1 first ? (sda is a 64 GByte pen drive). So I typed;

mount /dev/sda1
dd if=/dev/hda3 of=/mnt/sda1/base.img

This seems to be running now, hopefully my 12V battery will last long enough for the process to complete with USB1.0 ports, should have ~ 24 hrs run time, hopefully will be enough!

Hope mounting sda1 was correct, I recall when making duplicate boot TC drives that I did not mount either the source or destination pen drive.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 08, 2022, 09:38:37 PM
Hi MTCAT
No, no, no.

Code: [Select]
dd if=/dev/hda of=base.imgYou want to copy  /dev/hda  which is not mounted to an actual file located on another drive.

Connect the damaged drive to another machine that has a drive with plenty of free space.
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 08, 2022, 11:57:40 PM
Hi MTCAT
You want to image the entire drive. Don't try to image a partition. Connect the
damaged SSD to a Linux machine that has a large drive. Also, make sure the
machine does not auto mount every drive it finds.

Create a directory to work in:
Code: [Select]
mkdir Recovery
cd Recovery

Find out which device the SSD was assigned to.
Now create an image of the SSD:
Code: [Select]
dd if=/dev/sdb of=master.img
sync

Shut down the machine, disconnect the SSD and put it someplace safe.
Power up the machine and:
Code: [Select]
cd Recovery
cp master.img base.img

You can now work on  base.img.  If you mess it up, just copy  master.img  again.
Assign a device to the image file:
Code: [Select]
sudo losetup --show --find --partscan base.img
/dev/loop241
In this example the operating system returned  /dev/loop241  for the image file.

Use fdisk to get a partition list:
Code: [Select]
fdisk -l /dev/loop241
 ----- Snip -----
Device         Boot  Start    End Sectors  Size Id Type
/dev/loop241p1        2048 206847  204800  100M 83 Linux
/dev/loop241p2      206848 309247  102400   50M 83 Linux
/dev/loop241p3      309248 923647  614400  300M 83 Linux
In this example there are 3 partitions.

If you want to try looking at partition 3:
Code: [Select]
mkdir P3
sudo mount /dev/loop241p3 P3
cd P3
ls -l

If the contents appear messed up, you might have to try to repair the partition table.
That would require working on  /dev/loop241  because that's where the partition table
is located.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 09, 2022, 08:12:26 AM
Hi Rich,

Oh, okay, thanks for the help, I will try that tonight/this weekend, I don't think I can remove the SSD and connect up to a normal Linux desktop though, hmm, not sure, the SSD in the base station is on a card carrier that connects right into the PCI bus, but the hard drive itself is an IDE interface, which is why it was so expensive, I don't think I have an external IDE hard drive enclosure anymore (with a USB external connection),threw it out I think, maybe could get one off Ebay or something, or connect up the SSD internally inside my old AMD Phenom Linux box, I'm pretty sure even that guy uses SATA hard drives though.

Another wrinkle perhaps, I do have a clone of the rover receiver (made with Clonezilla) put on an old external (regular platter spinner) hard-drive, as a backup of sorts, I have booted off that in the past and it "worked" in so far as booting up the system, was very slow to boot, but it did boot.

Not sure if that might help in some way.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 09, 2022, 08:36:13 AM
Hi MTCAT
... or connect up the SSD internally inside my old AMD Phenom Linux box, I'm pretty sure even that guy uses SATA hard drives though. ...
If that machine has CD/DVD drives, they might be controlled by an IDE interface.

An external drive would work, but might be slower than an internal drive.
Title: Re: Data Recovery from bad SSD
Post by: curaga on September 09, 2022, 10:32:15 AM
IDE SSDs are expensive, but there's a cheaper way: Compact Flash cards are IDE compatible. May need a physical adapter, but those are cheap too, being just wires.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 10, 2022, 12:16:12 PM
Hi Rich and Curaga,

Since I started my dd command I let that run (to make an image of hda3), it took about 25 hours, finished last night around 7 PM, but when complete I got an error;

dd: writing '/mnt/sda1/base.img': File too large
8388609+0 records in
8388607+1 records out

The pen drive to which I was writing too was 64 GByte (FAT32), the total size of the (damaged) SSD size is also 64 GByte but I thought I would be okay since I'm not writing out hda1 (boot partition) or hda2 (root partition), so the size for dd to write out should be less than 64 GByte?

But, when I take the pen drive over to my old Slackware box, it shows base.img as being only 4 GByte ? A 32 bit thing ? (FAT32? - need to reformat the pen drive first ?)

I made a directory in /home/dave on my Slackware bix called recovery, and with base.img in /home/dave, typed (as root) "mount -o ro base.img /home/dave/recovery" but I got an error for that as well

mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error

I also tried the mount command without the "ro" option and then got an error;
mount: can't find /home/dave/recovery in /etc/fstab or /etc/mtab

Thanks for the idea to "poach" off a CD/DVD IDE interface Rich, I'll check to see if the CD/DVD on my Slackware box is IDE, that could work, but otherwise, looks like I will have to order an external IDE enclosure off Amazon and work off my Slackware box that way, as Rich has been suggesting all along.

I guess if one good thing comes out of this is that it pushes my VortexDX3/TInyCore 3.8.4 system into use, and forces me to finish that and get it going 100 percent, and move on from this power hungry Celeron and old/expensive SSD.

Thankfully, the new VortexDX3 setup does indeed use CF-card as the "hard-drive", so that will be another step forward I think.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: curaga on September 10, 2022, 12:51:45 PM
FAT32 has a 4gb file size limit. Your error message says it wrote 4gb. Use a Linux filesystem to use larger files.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 10, 2022, 01:39:06 PM
Okay, thanks Curaga, if I try that again I'll format the pen drive to ext4 first.

Some good news though, my old Phenom Slackware box does indeed use an IDE interface for the CD/DVD!, and there's even an extra pigtail in there, so, I should be be able to hook up the damaged SSD right into my old desktop, thanks for that suggestion Rich, just have to take the PC104 stack all apart, the SSD is right on the bottom....

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 11, 2022, 12:33:19 PM
Hi Rich and curaga,

I took the base station receiver all apart but now have found that the SSD (64 GByte Innodisk, part number D2D6-64GD11W11) uses a 44 pin IDE connector, the extra pigtails inside my Linux box are 40 pin IDE connectors, so..., not sure now, maybe I do need to get an external 2.5 inch IDE enclosure to get this hooked up to my Slackware box. Inside the base station receiver, the SSD plugs into a Real-Time-Devices carrier board, part number CMT36106HR.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 11, 2022, 03:41:25 PM
Hi MTCAT
The difference between 40 and 44 pins is the latter also brings in power on the IDE connector.
Adapters are available. It's just a small board with a 44 pin connector on one end and two
connectors at the other end, one 40 pin and a 4 pin power connector. Or the power connection
might be a pigtail that hangs off of the board.

Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 13, 2022, 07:27:02 AM
Hi Rich,

Thanks, I slowly clued into that as well, I have one of those adapters coming, but it won't be here until Thursday, the 2.5 inch external enclosure I got yesterday was just for 40 pin IDE...sigh, so, have to wait to Thursday now before I can try imaging the entire SSD with my Slackware desktop...

For my own education, can you tell me why we can't make an image of a single partition by itself ?, i.e., just hda3 as I was attempting before. I read online that it's actually easier to do that since when mounting the image of a single partition you don't need to worry about block offsets when mounting.

I do understand that if we want to try to repair the disk that we need to image the whole drive, to be able to possibly repair the partition table, but otherwise, is it possible to just mount an image of one partition by itself ?

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 13, 2022, 09:11:37 AM
Hi MTCAT
... For my own education, can you tell me why we can't make an image of a single partition by itself ?, ...
You can, but what you get will be based on how big the partition table says that partition is. If the table says
your 300 Meg partition is only 17 Megs, thats all you'll get.

Quote
... I read online that it's actually easier to do that since when mounting the image of a single partition you don't need to worry about block offsets when mounting.
I read online that it's easy to do without worrying about block offsets. I saw it in reply #7:
... Assign a device to the image file:
Code: [Select]
sudo losetup --show --find --partscan base.img
/dev/loop241
In this example the operating system returned  /dev/loop241  for the image file.

Use fdisk to get a partition list:
Code: [Select]
fdisk -l /dev/loop241
 ----- Snip -----
Device         Boot  Start    End Sectors  Size Id Type
/dev/loop241p1        2048 206847  204800  100M 83 Linux
/dev/loop241p2      206848 309247  102400   50M 83 Linux
/dev/loop241p3      309248 923647  614400  300M 83 Linux
In this example there are 3 partitions.

If you want to try looking at partition 3:
Code: [Select]
mkdir P3
sudo mount /dev/loop241p3 P3
cd P3
ls -l
...
All you need to do is create a mount point (subdirectory) and mount it:
Code: [Select]
mkdir PickAnyName
sudo mount /dev/loop241p1 PickAnyName
Title: Re: Data Recovery from bad SSD
Post by: patrikg on September 13, 2022, 12:17:51 PM
And as default, Linux mounts partitions with write permissions.
And don't write any data to some bad ssd/hd.

So if you try to mount the partition you should just mount it as read only.

And many Linux systems also auto mount, that rely bad.
Because when mounting a ssd/hd it's also write's some data to it. 
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 13, 2022, 09:29:28 PM
Hi Rich, curaga and patrikg,

Okay, thanks for the explanation with the single partition image...sorry for not realizing what you were showing me there Rich, I just haven't got that far yet, I will definitely follow along your post 7 if I can get an image made of the entire disk.

I managed to get an external enclosure today that fits the 44 pin 2.5 inch SSD (with a USB connection to the desktop) but neither one of my Slackware desktops can see the external drive, when I type "fdisk -l" all the devices get listed as usual but at the end the terminal prompt hangs (with just a blinking cursor) until I unplug the USB cable for the external hard-drive enclosure, then I get the command prompt back.

This happened on both 2.6.37.4 and 4.4.14.

I do have an 44 pin to 40 pin adapter coming as well, which would allow me to hook up to my older desktop internally, with the extra CD/DVD pigtail as Rich suggested, but it won't be here until Thursday.

So not sure, maybe could try booting up TInyCore 3.0 on one of the desktops as well ? TC 3.0 was able to see hda at least (when booting the PC104 stack), but so far I've had no luck with Slackware.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: curaga on September 14, 2022, 05:29:32 AM
USB adapters use different drivers, so older Linux probably won't affect anything.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 17, 2022, 09:41:46 AM
Hi everyone,

Having problems posting, long story short, can't get Slackware to recognize the external 2.5 inch drive. I did make a 21.7 GByte image of hda3 (user partition), which I still have, on a pen drive, but I wasn't able to mount the image file, getting the following error in dmesg,

[1810.399627] EXT4-fs [loop 0]: failed to parse options in superblock: y?
[1810.399652] EXT4-fs [loop0]: bad geometry: block count 13565696 exceeds size of device (5701216 blocks)

Any ideas what I can do to try to mount this 21.7 GByte image file ?

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: Rich on September 17, 2022, 08:40:39 PM
Hi MTCAT
First make a copy of your image file to experiment on:
Code: [Select]
cp hda3Data.img hda3Test.imgThis way if something goes wrong, you can just copy it again.

Next you want to get a list of backup superblocks:
Code: [Select]
sudo mke2fs -n hda3Test.imgWhen it asks:
Code: [Select]
Proceed anyway? (y,N)just hit  y  then  Enter.

It should look similar to this:
Code: [Select]
tc@E310:~/DD$ sudo mke2fs -n /dev/sda2
mke2fs 1.44.4 (18-Aug-2018)
/dev/sda2 contains a ext4 file system
        last mounted on /mnt/sda2 on Mon Jul  4 20:32:05 2022
Proceed anyway? (y,N) y
Creating filesystem with 3840000 4k blocks and 960992 inodes
Filesystem UUID: f6a323d6-9619-454f-aaeb-09a8a1b00d26
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

tc@E310:~/DD$

Pick the first superblock backup listed and try to restore the superblock.
For example:
Code: [Select]
sudo e2fsck -b 32768 hda3Test.img
Now try mounting it again:
Code: [Select]
mkdir PickAnyName
sudo mount hda3Test.img PickAnyName

If it fails, pick the next superblock backup listed and try to restore the superblock.
Then try mounting again. Work your way through the superblock backups as required.
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 19, 2022, 07:35:59 AM
Thanks for the help Rich, I'll give that a try this week.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 20, 2022, 07:46:15 AM
Hi Rich,

I went through all the super-blocks as instructed but I still get the same error as in post 21 when trying to mount. Need to run resize2fs somehow?, without it complaining that I need to run e2fsck first.

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: patrikg on September 20, 2022, 08:17:40 AM
I think you can also use some tools for your image, for carving out the files.
I think of one program called scalpel, that uses the magic descriptor of files.
But if the blockchain is lost there no easy solution, i think.
You can visit the arch wiki if you like to spend little more time about Data/File recovery.
https://wiki.archlinux.org/title/file_recovery
Title: Re: Data Recovery from bad SSD
Post by: MTCAT on September 21, 2022, 09:14:34 PM
Hi everyone,

Thanks for all the help, I sent the SSD off to a recovery firm, they've examined it and said there was "firmware corruption" and that data would need to be restored "off-chip", apparently there are many individual flash drives within the SSD that act as a RAID array?, so it sounds like the individual flash drives (if that's the right word) need to be pulled out and data pulled off each sub-drive individually, will be no charge if they can't recover any data and I won't tell how much it will cost if they are successful!

Suffice to say it's almost as much as a whole new SSD!

At least it forces me to get to get the VortexDX3 setup going 100 percent asap!

Thanks,

David
Title: Re: Data Recovery from bad SSD
Post by: neonix on March 30, 2024, 05:30:07 AM
Could you guys create a SystemRescueCd type flavor of TinyCore (gui) and Microcore (cli) that will be designed to recover or fix HDDs.

The best version will be 2 file version, kernel + core.gz, easy to install and easy to remaster.