Cloning a damaged disk to a bigger one [solved]

Topics about disk partitioning (fdisk, parted, gparted, partimage), Volumes Management (lvm, evms, dmraid), Storage, file systems, ...
uyuarasy
Posts: 5
Joined: 03 May 2016, 17:14

Cloning a damaged disk to a bigger one [solved]

Postby uyuarasy » 03 May 2016, 17:37

Hi all,

I have a NAS pc what served me since 2014 humbly and silently 24/7 until a few power failure. I bought a new power supply then I realised this:

Code: Select all

  -- Physical Disk Information - Disk: #0: WDC WD10EARS-00Y5B1 --

    Hard Disk Summary
    -----------------
    Hard Disk Number. . . . . . . . . . . . . . . . .  0
    Hard Disk Device. . . . . . . . . . . . . . . . .  /dev/sda
    Interface . . . . . . . . . . . . . . . . . . . .  S-ATA II
    Hard Disk Model ID. . . . . . . . . . . . . . . .  WDC WD10EARS-00Y5B1
    Hard Disk Revision. . . . . . . . . . . . . . . .  80.00A80
    Hard Disk Serial Number . . . . . . . . . . . . .  WD-WCAV5J619786
    Hard Disk Total Size. . . . . . . . . . . . . . .  953870 MB
    Current Temperature . . . . . . . . . . . . . . .  48 °C (118 °F)
    Power On Time . . . . . . . . . . . . . . . . . .  1836 days, 3 hours
    Estimated Remaining Lifetime. . . . . . . . . . .  16 days
    Health. . . . . . . . . . . . . . . . . . . . . .  ###----------------- 16 % (Poor)
    Performance . . . . . . . . . . . . . . . . . . .  #################### 100 % (Excellent)

    The drive found 533 bad sectors during its self test.
    There are 537 weak sectors found on the disk surface. They may be remapped any time in the later use of the disk.
      It is recommended to backup often to prevent data loss.

    ATA Information
    ---------------
    Hard Disk Cylinders . . . . . . . . . . . . . . .  1938021
    Hard Disk Heads . . . . . . . . . . . . . . . . .  16
    Hard Disk Sectors . . . . . . . . . . . . . . . .  63
    Total Sectors . . . . . . . . . . . . . . . . . .  1953525168
    ATA Revision. . . . . . . . . . . . . . . . . . .  7
    Bytes Per Sector. . . . . . . . . . . . . . . . .  512
    Buffer Size . . . . . . . . . . . . . . . . . . .  0 KB
    Multiple Sectors. . . . . . . . . . . . . . . . .  16
    Error Correction Bytes. . . . . . . . . . . . . .  50
    Unformatted Capacity. . . . . . . . . . . . . . .  953870 MB
    Maximum PIO Mode. . . . . . . . . . . . . . . . .  1
    Maximum Multiword DMA Mode. . . . . . . . . . . .  2
    Maximum UDMA Mode . . . . . . . . . . . . . . . .  150 MB/s (6)
    Active UDMA Mode. . . . . . . . . . . . . . . . .  150 MB/s (6)
    Minimum Multiword DMA Transfer Time . . . . . . .  120 ns
    Recommended Multiword DMA Transfer Time . . . . .  120 ns
    Minimum PIO Transfer Time Without IORDY . . . . .  120 ns
    Minimum PIO Transfer Time With IORDY. . . . . . .  120 ns
    ATA Control Byte. . . . . . . . . . . . . . . . .  Valid
    ATA Checksum Value. . . . . . . . . . . . . . . .  Valid

    Acoustic Management Configuration
    ---------------------------------
    Acoustic Management . . . . . . . . . . . . . . .  Supported
    Acoustic Management . . . . . . . . . . . . . . .  Enabled
    Current Acoustic Level. . . . . . . . . . . . . .  Min performance and volume (80h)
    Recommended Acoustic Level. . . . . . . . . . . .  Min performance and volume (80h)

    EIDE Properties
    ---------------
    Read Ahead Buffer . . . . . . . . . . . . . . . .  Not supported
    DMA . . . . . . . . . . . . . . . . . . . . . . .  Supported
    Ultra DMA . . . . . . . . . . . . . . . . . . . .  Supported
    S.M.A.R.T.. . . . . . . . . . . . . . . . . . . .  Supported
    Power Management. . . . . . . . . . . . . . . . .  Supported
    Write Cache . . . . . . . . . . . . . . . . . . .  Supported
    Host Protected Area . . . . . . . . . . . . . . .  Supported
    Advanced Power Management . . . . . . . . . . . .  Not supported
    Power Up In Standby . . . . . . . . . . . . . . .  Supported
    48-bit LBA Addressing . . . . . . . . . . . . . .  Supported
    Device Configuration Overlay. . . . . . . . . . .  Supported
    IORDY Support . . . . . . . . . . . . . . . . . .  Supported
    Read/Write DMA Queue. . . . . . . . . . . . . . .  Not supported
    NOP Command . . . . . . . . . . . . . . . . . . .  Supported
    Trusted Computing . . . . . . . . . . . . . . . .  Not supported
    64-bit World Wide ID. . . . . . . . . . . . . . .  0150E24E785AACA7
    Streaming . . . . . . . . . . . . . . . . . . . .  Not supported
    Media Card Pass Through . . . . . . . . . . . . .  Not supported
    General Purpose Logging . . . . . . . . . . . . .  Supported
    Error Logging . . . . . . . . . . . . . . . . . .  Supported
    CFA Feature Set . . . . . . . . . . . . . . . . .  Not supported
    Long Physical Sectors (1) . . . . . . . . . . . .  Not supported
    Long Logical Sectors. . . . . . . . . . . . . . .  Not supported
    Write-Read-Verify . . . . . . . . . . . . . . . .  Not supported
    NV Cache Feature. . . . . . . . . . . . . . . . .  Not supported
    NV Cache Power Mode . . . . . . . . . . . . . . .  Not supported
    NV Cache Size . . . . . . . . . . . . . . . . . .  Not supported
    Free-fall Control . . . . . . . . . . . . . . . .  Not supported
    Free-fall Control Sensitivity . . . . . . . . . .  Not supported

    SSD Features
    ------------
    Data Set Management . . . . . . . . . . . . . . .  Not supported
    TRIM Command. . . . . . . . . . . . . . . . . . .  Not supported
    Deterministic Read After TRIM . . . . . . . . . .  Not supported

    S.M.A.R.T. Details
    ------------------
    Off-line Data Collection Status . . . . . . . . .  Suspended By Interrupting Command From Host
    Self Test Execution Status. . . . . . . . . . . .  Successfully Completed
    Total Time To Complete Off-line Data Collection .  20460 seconds
    Execute Off-line Immediate. . . . . . . . . . . .  Supported
    Abort/restart Off-line By Host. . . . . . . . . .  Not supported
    Off-line Read Scanning. . . . . . . . . . . . . .  Supported
    Short Self-test . . . . . . . . . . . . . . . . .  Supported
    Extended Self-test. . . . . . . . . . . . . . . .  Supported
    Conveyance Self-test. . . . . . . . . . . . . . .  Supported
    Selective Self-Test . . . . . . . . . . . . . . .  Supported
    Save Data Before/After Power Saving Mode. . . . .  Supported
    Enable/Disable Attribute Autosave . . . . . . . .  Supported
    Error Logging Capability. . . . . . . . . . . . .  Supported
    Short Self-test Estimated Time. . . . . . . . . .  2 minutes
    Extended Self-test Estimated Time . . . . . . . .  236 minutes
    Conveyance Self-test Estimated Time . . . . . . .  5 minutes

    Security Mode
    -------------
    Security Mode . . . . . . . . . . . . . . . . . .  Supported
    Security Erase. . . . . . . . . . . . . . . . . .  Supported
    Security Erase Time . . . . . . . . . . . . . . .  104 minutes
    Security Enhanced Erase Feature . . . . . . . . .  Supported
    Security Enhanced Erase Time. . . . . . . . . . .  104 minutes
    Security Enabled. . . . . . . . . . . . . . . . .  No
    Security Locked . . . . . . . . . . . . . . . . .  No
    Security Frozen . . . . . . . . . . . . . . . . .  Yes
    Security Counter Expired. . . . . . . . . . . . .  No
    Security Level. . . . . . . . . . . . . . . . . .  High

    Serial ATA Features
    -------------------
    S-ATA Compliance. . . . . . . . . . . . . . . . .  Yes
    S-ATA I Signaling Speed (1.5 Gps) . . . . . . . .  Supported
    S-ATA II Signaling Speed (3 Gps). . . . . . . . .  Supported
    Receipt Of Power Management Requests From Host. .  Supported
    PHY Event Counters. . . . . . . . . . . . . . . .  Supported
    Non-Zero Buffer Offsets In DMA Setup FIS. . . . .  Not supported
    DMA Setup Auto-Activate Optimization. . . . . . .  Supported, Enabled
    Device Initiating Interface Power Management. . .  Not supported
    In-Order Data Delivery. . . . . . . . . . . . . .  Not supported
    Asynchronous Notification . . . . . . . . . . . .  Not supported
    Software Settings Preservation. . . . . . . . . .  Supported, Enabled
    Native Command Queuing (NCQ). . . . . . . . . . .  Supported
    Queue Length. . . . . . . . . . . . . . . . . . .  32

    S.M.A.R.T.
    ----------
No.  Attribute                Thre.. Value  Worst  Data                Status                   Flags                                                 
1    Raw Read Error Rate      51     200    200    000000000000        OK                       Self Preserving, Error-Rate, Performance, Statistica..
3    Spin Up Time             21     172    132    000000001117        OK                       Self Preserving, Performance, Statistical, Critical   
4    Start/Stop Count         0      92     92     0000000020CB        OK (Always passing)      Self Preserving, Event Count, Statistical             
5    Reallocated Sectors Co.. 140    200    200    000000000000        OK                       Self Preserving, Event Count, Statistical, Critical   
7    Seek Error Rate          0      199    199    000000000028        OK (Always passing)      Self Preserving, Error-Rate, Performance, Statistical 
9    Power-On Time Count      0      40     40     00000000AC23        OK (Always passing)      Self Preserving, Event Count, Statistical             
10   Spin Retry Count         0      100    100    000000000000        OK (Always passing)      Self Preserving, Event Count, Statistical             
11   Drive Calibration Retr.. 0      100    100    000000000000        OK (Always passing)      Self Preserving, Event Count, Statistical             
12   Drive Power Cycle Count  0      100    100    000000000087        OK (Always passing)      Self Preserving, Event Count, Statistical             
192  Power off Retract Cycle  0      200    200    00000000005E        OK (Always passing)      Self Preserving, Event Count, Statistical             
193  Load/Unload Cycle Count  0      174    174    000000013B7F        OK (Always passing)      Self Preserving, Event Count, Statistical             
194  HDD Temperature          0      99     98     000000000030        OK (Always passing)      Self Preserving, Statistical                           
196  Reallocation Event Count 0      200    200    000000000000        OK (Always passing)      Self Preserving, Event Count, Statistical             
197  Current Pending Sector.. 0      197    196    000000000219        OK (Always passing)      Self Preserving, Event Count, Statistical             
198  Off-Line Uncorrectable.. 0      197    195    000000000215        OK (Always passing)      Self Preserving, Event Count                           
199  Ultra ATA CRC Error Co.. 0      200    200    000000000000        OK (Always passing)      Self Preserving, Event Count, Statistical             
200  Write Error Rate         0      198    196    00000000021A        OK (Always passing)      Error-Rate                                             


I'm going to buy a new HDD and I'm not sure about a few things. My linux is running on a different drive and as far as I remember the damaged disk was mounted as /home. Is it possible to clone all of my data to the new (and bigger) disk, "attach" the remaining space, than use it just like nothing happend? I feel I have only one shot to save everything and I didn't find answers for my specific problem, so I'm depending on your skills.

I recovered/preserved things in the past with the sysrescuetools, but now I have to do it nice (eg. I don't understand fully the linux mounting parameters, like UUID, probably I have to preserve the old one to work fluently with the Debian).

Thank you in advance!

uyuarasy

gernot
Posts: 1127
Joined: 07 Apr 2010, 16:19

Re: Cloning a damaged disk to a bigger one

Postby gernot » 04 May 2016, 06:16

Yes, you can clone the HD to a bigger one.
It depends the structures (RAID,LVM) how to grow the partitions.
On a plain Partition table use gparted to grow the partition size.

After the SMART info there are actual no unreadable but 140 relocated sectors on the bad device.
I dont know why "The drive found 533 bad sectors during its self test" is shown.

Use ddrescue if you find unreadable sectors while cloning.

Gernot

uyuarasy
Posts: 5
Joined: 03 May 2016, 17:14

Re: Cloning a damaged disk to a bigger one

Postby uyuarasy » 04 May 2016, 22:04

Thank for the reply.

So if I execute the command below, the data from the old drive (sda) will be written to the new, raw HDD (sdb) with the partition table and other stuff? And after that, I can expand the partition freely? Or should I format the new disk first?

Code: Select all

dd if=/dev/sda bs=128K | pv -s 3000G | sudo dd of=/dev/sdb bs=128K


I'd like to save as much as possible first, there should not be system files on the disk. But if there will be a few corrupted file, I can still try to save them with ddrescue, am I right?

Cheers,
uyuarasy

gernot
Posts: 1127
Joined: 07 Apr 2010, 16:19

Re: Cloning a damaged disk to a bigger one

Postby gernot » 05 May 2016, 06:10

yes that work but why the complicated command?

first get root if you are a "user":
sudo bash
then make sure you copy the right drive:
fdisk -l

Use this to handle unreadable blocks and get actual statistics
ddrescue /dev/sdx /dev/sdy --force

or
dd if= of= bs=

to get the actual statistics send a SIGUSR1 from a other console to dd (killall -USR1 dd)

Gernot

uyuarasy
Posts: 5
Joined: 03 May 2016, 17:14

Re: Cloning a damaged disk to a bigger one

Postby uyuarasy » 05 May 2016, 10:48

I read a few topics about dd-ing, someone mentioned at stackexchange this command, because it's faster.

With the 'killall -USR1 dd' command I could get a human-readable statistic about the progress?

Edit: I understand the behavior between the kill and dd command. Anyway I forgot to mention that the filesystem is NTFS. The copying command still the same? Can I encounter error during the extension of the newly cloned drive?

gernot
Posts: 1127
Joined: 07 Apr 2010, 16:19

Re: Cloning a damaged disk to a bigger one

Postby gernot » 05 May 2016, 20:12

Yes you get a human readable statistic. In the dd manualpage is a example.

Make a filesystemcheck for the NTFS partition with windows before growing the filesystem.
Growing is the most time safe.There is only a small risk.

Gernot

uyuarasy
Posts: 5
Joined: 03 May 2016, 17:14

Re: Cloning a damaged disk to a bigger one

Postby uyuarasy » 07 May 2016, 11:35

I choosed the ddrescue over the dd as you recommended:

Code: Select all

ddrescue -d -f -r3 /dev/sda /dev/sdb /mnt/usb/rescue.logfile


The copying was done in 4-5 hours (1TB), and the ddrescue tried to recover 6MB damaged data for another 6-7 hours, then I interrupted the process. Everything seemed fine, I extended the partitions with Gparted and I can't find the lost few MB, so it's probably okay (only the /var and the /home was on the bad drive).

Now I have a minor problem (Partition 1 does not start on physical sector boundary) and the for Partition 5. /dev/sdb1 is the whole new disk as extended partiton, /dev/sdb5 is mounted as /var. Interestingly /dev/sdb6 is fine, what is the /home partition.

As I read about this issue, the problem could be the "Sector size (logical/physical): 512 bytes / 4096 bytes" line in fdisk -l. Should I bother this thing? I read if I don't face speed issues I can leave it alone. Or is there a safe way to repair without data loss, like gparted repair?

Oh and I was wrong, one of my previous HDD had NTFS partiton, it's ext4.

Thanks for your help! :)

gernot
Posts: 1127
Joined: 07 Apr 2010, 16:19

Re: Cloning a damaged disk to a bigger one

Postby gernot » 07 May 2016, 20:22

uyuarasy wrote:As I read about this issue, the problem could be the "Sector size (logical/physical): 512 bytes / 4096 bytes" line in fdisk -l. Should I bother this thing?

Don't bother. Tracks are a historic virtual emulated thing. No problem.
Some older BIOS cant boot from such a partition,

On some devices with 4K physical blocksize the 4K alignment is important. This devices write painful slow with wrong alignment. But this is an other thing

Gernot

uyuarasy
Posts: 5
Joined: 03 May 2016, 17:14

Re: Cloning a damaged disk to a bigger one

Postby uyuarasy » 08 May 2016, 10:49

Cool. I think than it's ok. Thanks for your guidance.

Code: Select all

hdparm -Tt /dev/sdb

/dev/sdb:
 Timing cached reads:   1178 MB in  2.00 seconds = 588.93 MB/sec
 Timing buffered disk reads: 350 MB in  3.01 seconds = 116.18 MB/sec


Cheers!


Return to “Hard-disk partitioning and storage”

Who is online

Users browsing this forum: No registered users and 3 guests