Probably due to a power outage, I suddenly lost access to a connected USB HDD yesterday. According to parted, I get the message “unknown partition table,” and gdisk says the GPT is corrupted. Using testdisk, I was able to copy the files to another drive and restore the partition table and mount the HDD.

Is it possible that the partition table was damaged by the power outage, or does this point to a different problem? Can I safely store data on such an HDD again, or should I replace it?

  • yuman@programming.dev
    link
    fedilink
    English
    arrow-up
    11
    ·
    2 months ago

    can’t help you with your conundrum, but I’d like to point out there are so many potential issues in the chain regarding a drive in a USB enclosure that you’re unwise to treat it as an always-on connected device. any number of those things can go wrong and net you what you had, and worse.

  • muhyb@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 months ago

    Install smartmontools package for your distro, if it’s not already installed. Then

    Check your disk’s name with sudo lsblk. After that, replace your_disk with your disk’s name (sda, nvme0n1 etc.) in the command below.

    sudo smartctl -x /dev/your_disk

    If the results say PASSED, you’re probably good. You can also pass the output to an LLM by the way. At least they are good at these kind of things.

      • muhyb@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        I agree though I use them as TLDR in this context and they’re generally fine with that as far as I can tell. Otherwise it’s a long output to check but I usually check the entire output anyway.

  • neidu3@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 months ago

    Which filesystem are you using? Some filesystems are better at handling power failure than others, and some write a backup partition table to the disk in other locations. It could be that you were just really really unlucky, but the partition table just needs to be restored. Hard to say for sure without examining your filesystem.

    • MoLoPoLY@discuss.tchncs.deOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 months ago

      I thought it was ext4, but it seems to be ext3. A standard file system check didn’t find any errors after I restored the partition table.

  • Brickfrog@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 months ago

    Adding on to the earlier comments you can run tests against the drive with smarctl e.g.

    smartctl --scan (scans and lists all drives connected to your system)

    smartctl -t short /YOUR/DRIVE (short non-destructive drive test, usually takes 3 minutes or so, afterwards run smartctl -a again to view test results towards the bottom of the output)

    smartctl -t long /YOUR/DRIVE (this is a long more thorough test, non-destructive, this can easily take a few hours or even days depending on the size of your drive and whatnot)

    smartctl -a or smartctl -x will give you testing progress in its output.

    Or another option, if you can’t run smartctl for some reason, and you’re just testing a regular HDD not SSD, look into running a badblocks non-destructive scan.

  • Lee Duna@lemmy.nz
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 months ago

    In many cases, there’s no file system can withstand from power outages.

    While the risk of data loss can be mitigated by disabling or limiting amount of write cache. Still there’s no guarantee that will prevent corruption of the file system.