Salvage and replicate a KUKA robot system drive
When a KUKA robot's original IDE hard drive started failing, the safest recovery path was to pull a raw image with ddrescue, write it to an industrial Compact Flash (CF) card, repair the filesystems damaged by hard power cycles, and capture a clean master image for future swaps. Here are all the commands I used, kept for reference.
Capture the raw disk image
First, use ddrescue to read every readable sector off the failing IDE drive. Unlike dd, ddrescue handles read errors gracefully and logs progress so you can resume if the drive drops out.
sudo ddrescue -d -r3 /dev/sdb ~/kuka_master.img ~/kuka.logfile
-d: uses direct disk access, bypassing the kernel cache.-r3: retries bad sectors up to three times to recover as much data as possible.~/kuka.logfile: saves progress so interrupted runs pick up right where they left off.
Write the image to a new CF card
Verify that /dev/sdb is the target industrial CF card (via lsblk) before running dd. Writing to the wrong device will destroy its contents.
Once kuka_master.img is saved, clone it onto the replacement industrial CF card:
sudo dd if=~/kuka_master.img of=/dev/sdb bs=4M status=progress conv=fsync
if: input file (kuka_master.img).of: target CF card device (/dev/sdb).conv=fsync: flushes all buffered writes to the card beforeddexits.
Repair damaged filesystems
Because the failing drive went through unclean power cycles, its partitions may carry dirty flags or metadata errors. Repair them on the new CF card before putting it in the robot cabinet.
Fix the NTFS Windows partition
sudo ntfsfix /dev/sdb1
Fix the data and recovery partitions
sudo fsck -y /dev/sdb5
sudo fsck -y /dev/sdb6
These commands clear dirty bits and repair filesystem metadata left behind by improper shutdowns.
Verify the bootable partition flag
For the KUKA controller to boot from the CF card, Partition 1 must be marked as Active / Bootable.

Open the Disks utility (gnome-disks), select the CF card, and confirm that Partition 1 lists Bootable under Partition Type. Without the bootable flag, the controller will skip the drive on startup.
Save a clean master backup image
After verifying the repairs, capture a final clean image from the working CF card so you have a ready-to-flash backup for the future:
sudo dd if=/dev/sdb of=~/Documents/kuka_fixed.img bs=4M status=progress conv=fsync
With kuka_fixed.img stored safely on an external backup drive or server, you can flash a replacement CF card in about five minutes if a robot drive ever fails again.
Copy large images with a progress bar
Copying multi-gigabyte disk images on an older workshop PC can take a while. Using rsync gives you live transfer speeds and ETA:
rsync -ah --progress SOURCE TARGET
Shoutout to Linux Mint
Ubuntu refused to install on the older PC I used for this recovery, while Linux Mint booted and installed without a single complaint.
