Using ddrescue to Replace Failing Hard Drive with External Drive in Kubuntu


I had the main system drive on my 5 year old Kubuntu machine start having read errors in the syslog reported by logcheck. I had the system up and running straight for those 5 years and it was likely nearing the drives lifetime. I didn't want to have to rebuild the system from scratch, since it had served me well -just wanted to get a little more reliable disk drive in place (with a minimal amount of hassle).

The drive I was replacing was a  250GB 7200 rpm SATA drive. I had an extra 500GB 7200 rpm Western Digital Black drive that had been a warranty repair. It had been gently used in a machine that needed more space. It was a perfect donor for the Kubuntu machine. It was currently mounted in a Rosewill USB external hard drive enclosure (http://www.amazon.com/gp/product/B005KGNXTE/).


Here's an example of the errors in the syslog:
ata5: EH in SWNCQ mode,QC:qc_active 0x1000 sactive 0x1000ata5: SWNCQ:qc_active 0x1000 defer_bits 0x0 last_issue_tag 0xcata5: ATA_REG 0x41 ERR_REG 0x84ata5: tag : dhfis dmafis sdbfis sactiveata5: tag 0xc: 1 1 0 1  ata5.00: exception Emask 0x1 SAct 0x1000 SErr 0x300000 action 0x6 frozenata5.00: Ata error. fis:0x21ata5: SError: { Dispar BadCRC }ata5.00: failed command: READ FPDMA QUEUEData5.00: cmd 60/00:60:27:ea:bc/01:00:12:00:00/40 tag 12 ncq 131072 inata5.00: status: { DRDY ERR }ata5.00: error: { ICRC ABRT }ata5: hard resetting linkata5: nv: skipping hardreset on occupied portata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300)ata5.00: configured for UDMA/133ata5: EH complete
dmesg|awk '/ATA-|ATAPI/' show me that ata5 was my 250GB drive.

ls -l /dev/disk/by-id showed me that my 250GB drive was mounted as sdb.
lrwxrwxrwx 1 root root  9 May  6 20:09 ata-ST3250310AS_6RY1EWXJ -> ../../sdblrwxrwxrwx 1 root root 10 May  6 20:09 ata-ST3250310AS_6RY1EWXJ-part1 -> ../../sdb1lrwxrwxrwx 1 root root 10 May  6 20:09 ata-ST3250310AS_6RY1EWXJ-part2 -> ../../sdb2lrwxrwxrwx 1 root root 10 May  6 20:09 ata-ST3250310AS_6RY1EWXJ-part5 -> ../../sdb5
sudo smartctl --test=short /dev/sdb started a smart tools self test on the drive.

sudo smartctl -a /dev/sdb showed there were lots of read errors.
Error 4248 occurred at disk power-on lifetime: 46974 hours (1957 days + 6 hours)  When the command that caused the error occurred, the device was active or idle.
  After command completion occurred, registers were:  ER ST SC SN CL CH DH  -- -- -- -- -- -- --  84 51 00 c1 16 68 ed  Error: ABRT at LBA = 0x0d6816c1 = 224925377
  Commands leading to the command that caused the error were:  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name  -- -- -- -- -- -- -- --  ----------------  --------------------  c4 00 c0 af 1d 29 e3 00      01:15:30.448  READ MULTIPLE  29 00 40 a8 48 6d e0 00      01:15:30.412  READ MULTIPLE EXT  c4 00 08 47 64 0c e3 00      01:15:30.401  READ MULTIPLE  29 00 40 28 48 6d e0 00      01:15:30.389  READ MULTIPLE EXT  29 00 40 28 47 6d e0 00      01:15:30.378  READ MULTIPLE EXT
It was time to replace the drive and hopefully do this with minimal fuss and data loss.

  1. First I booted up the machine using the live CD and run Kubuntu from the live CD.
  2. sudo apt-get install gddrescue - To install ddrescue onto the live CD instance of Kubuntu your running (I never knew you could do this on a virtual system) 
  3. Plug in USB to SATA external drive
  4. ls -l /dev/disk/by-id to list out the disk drives to make sure you clone the right one 
  5. sudo ddrescue -v --force /dev/sdb /dev/sdc to clone the old smaller disk to the new similar or larger disk. This step takes awhile depending on your disk size.
  6. fsck.ext3 -f /dev/sdc to check the new file system to make sure you haven't copied any failing file system errors in the duplication process.
  7. sudo apt-get install gparted to upsize using partition using KDE Partition Manager
  8. Shutdown the machine and physically swap out the drive. Exchange the internal drive for the drive in the external exclosure.
  9. Remove the Live CD and restart the system.
For me that's all it took and was much less painful than I expected. Hopefully this will help you if you run into the same situation.


References:
http://radu.cotescu.com/migrating-your-ubuntu-machine-to-a-ssd-drive/
http://www.linux.com/learn/tutorials/8225-clone-your-ubuntu-installation-onto-a-new-hard-disk

Comments

  1. I just had my WD external hard-drive stop working. Basically it hummed but no icon appeared. WD My Passport for Mac 2TB No amount of Disk Utility repair would work. I called the experts and they said since I was using Apple Time Machine as my backup method there was pretty much no way of recovering the information.

    ReplyDelete

Post a Comment

Popular posts from this blog

Moen 1225 Kitchen Faucet Cartridge Repair or Replacement

Outdoor Temperature - Waiting for Update Honeywell WiFI Thermostat (RTH9580WF)

Comcast Xfinity HD uDTA Pace DC60Xu Unboxing and Setup Instructions