Hardware
Check disk I/O speed
sudo dd if=/dev/zero of=/testfile bs=1G count=1 oflag=direct
sudo dd if=/testfile of=/dev/null bs=1G count=1 iflag=direct
sudo rm /testfile
sudo apt update && sudo apt install hdparm
sudo hdparm -Tt /dev/sda
sudo apt install sysstat
iostat -xz 2
Clone damaged disk
Reallocated Sectors: 90 suddenly increase and gives errors I/O input error. I wish to backup data to another disk any change to lost data?
Yes, there is a strong chance that some data is already lost or at immediate risk.
A sudden spike in reallocated sectors accompanied by I/O errors indicates active physical degradation on the disk media. Standard file copiers (like Windows Explorer or basic cp) will hang, freeze, or fail completely when encountering these sectors, worsening drive health in the process.
What Is Happening to Your Disk
Critical Next Steps (Do Not Use Standard Copying)
Do not run chkdsk, fsck, or drive diagnostic tools like S.M.A.R.T. extended self-tests. These perform heavy read/write operations that can destroy a failing drive.
1. Prioritize Crucial Files First If the drive is still mounted, manually copy your absolute highest-value files (documents, personal records) individually to a healthy drive before doing anything else.
2. Clone the Drive with a Fault-Tolerant Tool To rescue the maximum amount of data without hanging your system on bad blocks, clone the entire drive to a healthy disk of equal or larger size using a tool designed to skip bad sectors:
3. Unmount and Replace Once the clone completes, disconnect the failing drive immediately. Perform any file system repair or data recovery operations on the cloned copy, never the original failing drive.
If the drive begins making clicking noises or ceases to mount entirely during this process, power it off immediately; at that point, only a professional data recovery lab with cleanroom facilities can safely extract the remaining magnetic data.
oh my os is ubunut and Can I clone my data to another machine using tailscale?
Yes, you can clone the drive over Tailscale, but because of the failing state of the drive (I/O errors), you must use a tool that streams block-level data while skipping bad sectors over an SSH tunnel. Standard network copy tools (scp, rsync) will freeze or fail when they hit bad blocks.
Step-by-Step Recovery over Tailscale
1. Install GNU ddrescue on the Local Machine
Install the fault-tolerant recovery tool on the Ubuntu machine with the dying drive:
sudo apt update && sudo apt install gddrescue -y
2. Identify Drive Device Names
Find the device node for your failing drive (e.g., /dev/sdb or /dev/nvme0n1):
lsblk
(Verify carefully—do not mistake your system root drive for the dying drive).
3. Stream ddrescue to the Remote Machine over Tailscale
Run ddrescue on the local machine and pipe its output through SSH to write directly into an image file on the remote machine across your Tailnet:
sudo ddrescue -d -r1 /dev/sdX - remote_user@REMOTE-TAILSCALE-IP:/path/to/backup/drive_rescue.img mapfile.log
Important Considerations for Network Recovery
ssh port is 2010
To use port 2010, pass the -P parameter (capital P) inside the sshfs mount command or the -p parameter (lowercase p) if piping directly through ssh.
Using the SSHFS method is strongly recommended here—it keeps your rescue.log mapfile local so you can safely stop and resume the clone if your Tailscale connection drops.
Method 1: Recommended (SSHFS Mount on Port 2010)
1. Create a local mount point and mount the target machine:
mkdir -p /mnt/remote_backup
sshfs -p 2010 remote_user@REMOTE-TAILSCALE-IP:/path/to/backup /mnt/remote_backup
2. Start ddrescue writing directly into the mount:
sudo ddrescue -d -r1 /dev/sdX /mnt/remote_backup/drive_rescue.img /var/log/rescue.log
(Replace /dev/sdX with your failing drive, and update remote_user and REMOTE-TAILSCALE-IP accordingly).
Method 2: Direct SSH Stream on Port 2010
If you prefer streaming directly without mounting SSHFS, pass -p 2010 to the ssh command:
sudo ddrescue -d -r1 /dev/sdX - | ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "cat > /path/to/backup/drive_rescue.img"
Unmounting When Finished
When the cloning process completes, clean up the mount with:
sudo umount /mnt/remote_backup
img is how big ?
The .img file will be the exact total capacity of the dying source disk, not just the size of the files currently stored on it.
Because ddrescue creates a raw, sector-by-sector clone of the underlying physical storage, it copies every byte on the drive—including empty space and corrupted sectors.
Disk Capacity vs. File Size
Example: If you have a 1 TB hard drive that only contains 50 GB of personal photos and documents, the resulting drive_rescue.img file will still be 1 TB.
Crucial Pre-Flight Check
Before starting the transfer, verify that the storage drive on your remote machine has more free space available than the total size of your failing disk.
1. Check source drive size (local machine):
lsblk -b /dev/sdX | grep disk
(Look at the total size in bytes/gigabytes).
2. Check destination free space (remote machine over SSH port 2010):
ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "df -h /path/to/backup"
(Ensure the Avail column is larger than the total size of your source drive).
What to Do After the .img File Is Created
Once the clone finishes, do not try to open the .img file like a standard archive. You can mount it directly on the remote Linux machine to browse and copy your healthy files out:
sudo loopsetup=$(sudo losetup -fP --show /path/to/backup/drive_rescue.img)
sudo mount ${loopsetup}p1 /mnt/restored_files
(Replace p1 with the specific partition number you want to access).
Can I just clone one drive to another drive?
Yes, absolutely. Cloning directly from disk to disk (e.g., from /dev/sdX to /dev/sdY) is actually simpler and much faster because it avoids network bottlenecks, SSH overhead, and intermediate image files.
Prerequisites
Step-by-Step Disk-to-Disk Rescue
1. Identify your drives:
lsblk -o NAME,SIZE,MODEL,SERIAL
2. Run ddrescue directly between the drives:
sudo ddrescue -d -r1 /dev/sdX /dev/sdY /var/log/rescue.log
What Happens Next?
Once ddrescue finishes:
Target disk sde 931.5G Tech K94PT9325BHV
Source disk sda 931.5G D HTS541010A9E63 000000004BA8
Your drive sizes match (both 931.5 GB), so a direct disk-to-disk clone will work.
Step 1: Run ddrescue
Execute the following command to begin copying data directly from sda to sde:
sudo ddrescue -d -r1 /dev/sda /dev/sde /var/log/sda_rescue.log
Step 2: What to Expect During the Run
Step 3: Post-Rescue Cleanup
Once ddrescue reports finished:
IS this work can be done via tailscale?
Yes, absolutely. You can execute this disk-to-disk clone across machines connected via Tailscale.
However, because you are cloning a whole 931.5 GB drive directly over the network, there are critical speed and command adjustments to keep in mind.
Step-by-Step: Disk-to-Disk Clone Over Tailscale
Assuming /dev/sda is on your Local Machine (with the dying drive) and /dev/sde is physically attached to the Remote Machine on your Tailnet.
1. Command to Run on Local Machine (Port 2010)
Pipe ddrescue directly through SSH to write onto /dev/sde on the remote side:
sudo ddrescue -d -r1 /dev/sda - | ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "sudo dd of=/dev/sde status=progress bs=64k"
Critical Considerations Before You Start
1. Transfer Time (Network Bottleneck)
Over a local disk bus (SATA/USB 3), cloning 931.5 GB takes roughly 2 to 3 hours. Over a Tailscale network connection, your speed will be limited by your upload speed:
If both machines are on the same physical local network (e.g., same router/switch), use the destination machine's local LAN IP inside the SSH command instead of the Tailscale IP to get full gigabit speeds.
2. Risk of Network Dropouts
Piping ddrescue directly over SSH standard output does not allow saving a detailed bad-sector mapfile across the network connection. If your network hiccups or SSH drops mid-transfer, you cannot resume from where you left off; you would have to start from the beginning.
Recommendation: Run the command inside a tmux or screen session on your local terminal so that a closed SSH/terminal session won't kill the running process:
tmux new -s rescue
(If disconnected, re-attach later using tmux a -t rescue)
need to format for target disk ?
No, you do not need to format the target disk (/dev/sde).
In fact, formatting it beforehand would be a wasted step. ddrescue performs a low-level, sector-by-sector copy—meaning it will overwrite every single byte on the target disk, including its partition table, file system headers, and formatting data.
What Will Happen to the Target Disk (/dev/sde)
One Important Prerequisite
While you don't need to format /dev/sde, you must ensure that none of its partitions are mounted before running the recovery command:
sudo umount /dev/sde* 2>/dev/null
This prevents the Linux kernel on the receiving machine from writing to /dev/sde while ddrescue is actively overwriting the raw drive blocks over your network stream.
41250 bytes (41 kB, 40 KiB) copied, 76 s, 0.5 kB/sddrescue: /dev/sda: Fatal error reading the input file: No such device
41720 bytes (42 kB, 41 KiB) copied, 77 s, 0.5 kB/s
0+78 records in
0+78 records out
41720 bytes (42 kB, 41 KiB) copied, 76.9141 s, 0.5 kB/s
Fatal error reading the input file: No such device means your dying hard drive (/dev/sda) has physically disconnected from the machine.
When a drive with severe bad sectors suffers repeated read failures, its internal controller crashes, or the Linux kernel resets the SATA/USB bus to prevent system lockup. As a result, the hardware completely disappears from /dev/sda. Notice how it only managed to copy ~41 kB before disconnecting.
Step 1: Check if the Drive Is Still Detected
Run this command to see if the system can still see the hardware:
lsblk
Or check kernel logs to see the drop event:
dmesg -T | grep -i "ata\|sd\|error" | tail -n 20
Step 2: How to Re-identify or Reset the Drive
If lsblk no longer lists /dev/sda:
Step 3: Crucial Strategy Adjustment for ddrescue
Your drive crashed because ddrescue attempted direct access (-d) on a severely degraded sector right at the beginning of the disk.
When you restart ddrescue, remove the -d (direct I/O) flag initially and add --scrape-members / --no-scrape options to skip damaged areas instantly without hanging the drive controller:
sudo ddrescue -n -b 4096 /dev/sdX - | ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "sudo dd of=/dev/sde status=progress bs=64k"
Warning Signs of Permanent Hardware Failure
If the drive disconnects again almost immediately after starting (within seconds or after copying just a few kilobytes):
disk is still connected and
[Mon Aug 3 13:08:38 2026] I/O error, dev sda, sector 0 op 0x0:(READ) flags 0x800 phys_seg 16 prio class 2
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] tag#1 uas_zap_pending 0 uas-tag 1 inflight: CMD
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] tag#1 CDB: Read(10) 28 00 00 b8 70 80 00 00 80 00
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] tag#1 FAILED Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK cmd_age=0s
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] tag#1 CDB: Read(10) 28 00 00 b8 70 80 00 00 80 00
[Mon Aug 3 13:21:05 2026] I/O error, dev sda, sector 12087424 op 0x0:(READ) flags 0x800 phys_seg 16 prio class 2
[Mon Aug 3 13:21:05 2026] device offline error, dev sda, sector 12107136 op 0x0:(READ) flags 0x800 phys_seg 16 prio class 2
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] Synchronizing SCSI cache
[Mon Aug 3 13:21:05 2026] sd 1:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[Mon Aug 3 13:21:06 2026] EXT4-fs (sda): unmounting filesystem dc434a0a-8500-41a2-9fd3-37b3adef0cc5.
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: Attached scsi generic sg0 type 0
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] 4096-byte physical blocks
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Write Protect is off
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Mode Sense: 53 00 00 08
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Disabling FUA
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes)
[Mon Aug 3 13:21:09 2026] sd 1:0:0:0: [sda] Attached SCSI disk
The logs show two very important things:
To fix this, you must disable UAS for this drive so it falls back to the legacy, rock-solid usb-storage protocol. The standard usb-storage driver handles read errors gracefully without dropping the entire device.
Step 1: Disable UAS and Force usb-storage
1. Find your USB enclosure's Vendor and Product ID:
lsusb | grep -i "terramaster\|orico\|sabrent\|enclosure\|drive"
(Or simply run lsusb to see all USB devices). Look for a string like ID 152d:0578 (where 152d is Vendor ID and 0578 is Product ID).
2. Unbind UAS temporarily using modprobe: Run this command (replace 152d:0578 with your actual IDs):
sudo modprobe -r uas
sudo modprobe usb-storage quirks=152d:0578:u
(The :u flag forces Linux to ignore UAS and use standard usb-storage for this device).
3. Unplug and replug the USB cable. Verify it dropped UAS by checking dmesg:
dmesg | tail -n 15
You should see USB Mass Storage device detected instead of UAS driver.
Step 2: Disable Automatic Mounting
Notice line 13:21:06 in your log showing EXT4-fs (sda): unmounting. Ubuntu tried to automount the file system, which triggers immediate background reads on corrupted sectors.
Prevent Ubuntu from automounting or touching the partition structure while cloning:
gsettings set org.gnome.desktop.media-handling automount false
Step 3: Run ddrescue with Gentle Flags
Now that UAS is disabled, retry cloning over Tailscale. Use the -n (--no-scrape) option and a 4096-byte block size so ddrescue quickly skips bad blocks instead of getting stuck:
sudo ddrescue -n -b 4096 /dev/sda - | ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "sudo dd of=/dev/sde status=progress bs=64k"
us 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 002 Device 003: ID 13d3:5741 IMC Networks Lenovo EasyCamera
Bus 002 Device 004: ID 105b:e065 Foxconn International, Inc. BCM43142A0 Bluetooth module
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 003 Device 004: ID 2537:1068 Norelsys NS1068/NS1068X SATA Bridge Controller
Bus 003 Device 005: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 003 Device 006: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS578 SATA 6Gb/s
You have two external SATA adapters connected. The one causing the UAS crash is the JMicron JMS578 (152d:0578) controller on Bus 003.
Step 1: Force usb-storage Driver for JMicron (152d:0578)
Unload the crashing uas module and reload usb-storage with the quirk flag for 152d:0578:
sudo modprobe -r uas
sudo modprobe usb-storage quirks=152d:0578:u
Step 2: Cycle the Connection
Step 3: Check Drive Assignment & Disable Auto-Mount
Step 4: Resume ddrescue
Run ddrescue with --no-scrape (-n) and a 4KiB block size (-b 4096). It will now report read errors to ddrescue instantly and skip ahead without crashing the USB adapter:
sudo ddrescue -n -b 4096 /dev/sda - | ssh -p 2010 remote_user@REMOTE-TAILSCALE-IP "sudo dd of=/dev/sde status=progress bs=64k"
(Replace /dev/sda if lsblk shows a different letter after re-plugging).
after dd is finished, how to know ?which files are damaged
To identify which specific files are damaged, you need a map of where the bad sectors are located on the disk, and then you cross-reference those bad sector addresses with your filesystem's inode table using testdisk or debugfs.
Because you piped ddrescue directly into dd over SSH, no local rescue.log mapfile was generated. However, you can still pinpoint corrupt files directly on the cloned target disk (/dev/sde).
Step 1: Scan the Target Disk for Bad Sectors
Run badblocks on the cloned target drive /dev/sde. Since /dev/sde now contains an exact sector-by-sector copy of /dev/sda, reading /dev/sde will reveal where unreadable/skipped zeros were written:
sudo badblocks -v -b 4096 /dev/sde > bad_sectors.txt
(Save the list of bad sector block addresses to bad_sectors.txt).
Step 2: Map Bad Sectors to Corrupted Files
Depending on your file system type (e.g., ext4 or NTFS), use the appropriate tool below to match those sector numbers to actual file paths.
Option A: For EXT4 Filesystems (Using debugfs)
Option B: Automated GUI Recovery (Using TestDisk)
TestDisk is much easier if you prefer an automated tool to scan and list damaged files across ext4, NTFS, or FAT32 filesystems:
Step 3: Run Filesystem Repair (e2fsck)
Before mounting /dev/sde for normal use, repair any filesystem metadata inconsistencies caused by bad sectors:
sudo e2fsck -f -y /dev/sde1
Basically , target disk has no bad sector physically, then badsector information from source disk affects on target disk ?
No, the target disk will not gain physical bad sectors.
Because /dev/sde is a healthy physical drive, its physical platters or NAND flash cells remain 100% fine. However, logical/file system corruption will be copied over.
Physical vs. Logical Bad Sectors
What Actually Happens to Target Disk (/dev/sde)
How to Fix the File System on Target Disk
Once ddrescue completes, run a file system check on /dev/sde. This cleans up the logical errors so the operating system can safely use the drive:
sudo e2fsck -f -y /dev/sde1
Can I know the list of damaged files?
Yes, you can generate a complete list of damaged files directly from the target disk (/dev/sde), even though it has no physical bad sectors of its own.
Because ddrescue writes all zeros to the target disk whenever it encounters an unreadable sector on the source drive, any file containing those zeroed-out blocks is corrupted.
Method 1: The Automated Way (Using ddrescue-tools)
If you want a direct list of damaged file paths, use ddrescue-view or ddrescue-tools to parse the cloned partition:
Method 2: Finding Corrupted Files manually on EXT4 (debugfs)
If you don't have a mapfile from ddrescue, you can scan /dev/sde1 for filesystem blocks that contain unreadable metadata or lost inodes:
Method 3: Finding Zeroed / Damaged Files by Checksum Verification
If you have a previous backup or known checksums (like .md5 or .sha256 files) for your media, run a verification scan over your mounted files:
find /mnt/target -type f -exec md5sum {} + > /tmp/checksums.txt 2> /tmp/corrupted_files.txt
Any file that fails to read or produces an error will be logged into /tmp/corrupted_files.txt.