I’m running a Pi2 within a Western Digital PiDrive connected over USB 2 booting into buster. So I boot off a hard drive not the SD card.
The drive appears to have corrupted itself. The box boots fine, but after a while it throws an error and sets the file system to read only. I can read the file system fine, just can’t write to it.
I would like to create an image of the drive contents, which are less than 1Gb in total, while the box is up and running, avoiding the bad sectors, and then reinstall the image having reformatted or replaced the faulty 256Gb WD hard drive. I’ve run fsck numerous times to no avail, so more drastic action seems to be required.
I suspect dd or something similar would suffice, but my UNIX sys admin skills don’t run that far. Is it possible? Could I halt the box into single user mode and image the system on to a USB stick, boot off the stick, reformat the drive, reinstall buster, boot to the new install, set the file system to read only, and then re image the old drive on the usb back to the original drive? All without writing to the faulty drive, of course.