Partial restore from ddrescue image to SSD - Page 1
Forum section: electronics / general

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: October 27, 2022, 11:34:30 am
content: Work laptop went wonky with rolling release update. Everything's fine. Don't panic. I had brought a towel.I've got a full disk image (120gb, uncompressed) saved a few months ago for this kind of issue but was really saved in case of SDD failure.In an attempt to roll back the system to discover how it went wayward, I'm trying to elegantly restore blocks of data that have been changed without blasting the whole 120gb SSD. If it were a magnetic drive, I'd just go dd..Not worried too much about trampling the target drive data since laptop is not required for service currently. This is just an experiment.Yes, I -could- mount the image and extract data from the FSs within. Not what I want.Would like to explore some of the best ways to roll back the drive, with an emphasis on having as minimal SSD drive-wear as possible when blasting at the low level. Call me crazy.How would you go about it?

author: alm
author_rank: Super Contributor
timestamp: October 27, 2022, 11:58:49 am
content: I wouldn't bother and just overwrite the SSD. But if given the challenge, I'd make an image of the target SSD, then generate a binary patch from the image of the target SSD to the source image using a tool like xdelta, and apply this patch to the SSD. I have no idea how this performs with a 120 GB image or patching a block device instead of a regular file, but it seems the simplest solution to me.Second option would be doing a comparison using cmp to give all the different blocks, and have a script write just those blocks using dd.

author: RoGeorge
author_rank: Super Contributor
timestamp: October 27, 2022, 12:02:31 pm
content: No idea what OS you might have, what file system, or what errors do you see after upgrade.My crystal globe is broken, and the Eye of Sauron is in maintenance shutdown until Halloween.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: October 27, 2022, 12:17:08 pm
content: Quote from: RoGeorge on October 27, 2022, 12:02:31 pmAnswer is many to all three of your no ideas.QuoteMission is spelled out in the OP.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 27, 2022, 12:23:52 pm
content: Why? Another overthinking thread.Just write the whole thing.If the SSD is gone, nothing to do about it.

author: RoGeorge
author_rank: Super Contributor
timestamp: October 27, 2022, 12:58:48 pm
content: Quote from: Ed.Kloonk on October 27, 2022, 12:17:08 pmSpelled or misspelled?Quote from: Ed.Kloonk on October 27, 2022, 11:34:30 amJust dd the whole damn thing from the backup, then if after upgrade it fails again, try to fix the already upgraded OS.I don't know any ready made tool that can diff two images then dd only the changed blocks. You can try to write some scripts to do that. If you do so, beware some SSD have flash blocks different than 512B, mine is 4MiB IIRC, so physically it flushes 4MiB even if only one 512B sector has changed.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: October 27, 2022, 01:18:39 pm
content: Quote from: RoGeorge on October 27, 2022, 12:58:48 pmDo you know how to make a drive cough up it's flush block size?

author: RoGeorge
author_rank: Super Contributor
timestamp: October 27, 2022, 01:34:03 pm
content: Depends on the SSD type. For some models is top secret.https://www.reddit.com/r/techsupport/comments/ai1qrz/nand_erase_block_size_for_samsung_970_pro_is_top/Found about about mine accidentally, from reading about that model before buying it. Don't know if the info is correct.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: October 27, 2022, 01:40:21 pm
content: Quote from: RoGeorge on October 27, 2022, 01:34:03 pmThanks.

author: ejeffrey
author_rank: Super Contributor
timestamp: October 27, 2022, 01:59:43 pm
content: SSD wear is irrelevant. Just write the whole thing. The cost of those writes is at most about $.20 and much more likely $0.00. If you are going to micromanage wear just go back to mechanical drives. Your total system efficiency will be much higher when including the time you spend fing around with stuff that doesn't matter.Mounting the disk image and doing a file restore would also be a fine way to go but since you have rejected that for being, I guess too obvious?

author: RoGeorge
author_rank: Super Contributor
timestamp: October 27, 2022, 02:09:12 pm
content: https://superuser.com/questions/728858/how-to-determine-ssds-nand-erase-block-size

author: BradC
author_rank: Super Contributor
timestamp: October 27, 2022, 02:15:24 pm
content: Mount the image loopback and just use rsync —delete

author: Monkeh
author_rank: Super Contributor
timestamp: October 27, 2022, 02:18:15 pm
content: Just do it. If you're writing the same data to the same place the SSD won't write - it's a no-op. At least on any properly implemented controller.

author: rdl
author_rank: Super Contributor
timestamp: October 27, 2022, 02:25:07 pm
content: I understand doing things "the hard way" just because, or out of curiosity, but keep in mind that 120 GB SSDs are less than $20.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 27, 2022, 02:59:15 pm
content: SSDs wear leveling algorithm is constantly remapping the actual sectors, when you write to sector 0, the flash area won't be the same the next time you write that same sector.If your SSD is dead, nothing to do about it, try to image it, but solid drives are really bad at it when damaged.