Reading anything from the drive
In Ubuntu (Linux) you couldn't mount the drive, but it sounds like you gave up too easily, there's a world of difference between "filesystem inconsistencies / wasn't cleanly unmounted" that won't let an automatic mount, and "not recognized as a device, can't read a single sector" that you can read data & work with. Mounting can fail if windows is in "fast shutdown" mode, or there's filesystem errors, so it's definitely not a show stopper that it couldn't mount.
If a new
/dev/sdX appears then you can read (or at least attempt to read) the drive, and read SMART info & attempt tests. Since it's a USB drive, after connecting it a new device
/dev/sdX (X could be any letter) should show up, see
dmesg & /var/log/syslog for info (especially errors if there's no new device - without a device it might not be possible to read anything, or even harder to try).
If you can read anything from the
/dev/sdd device then it's looking much better that
ddrescue (in package named gddrescue) or
photorec or something can get some data. Probably need root rights too, with
sudo testdisk /dev/sdd or
sudo photorec /dev/sdd.
A very basic "read a little" with
dd would be:
sudo dd if=/dev/sdd of=output-file bs=1M count=1
reading the first M (=1024*1024 bytes) from the drive, and
bs= is how many bytes to read/write in each "block"
count= is the number of "blocks" to take
skip=N skip N ibs-sized blocks at start of input
- Just don't mix up the
of=, it will overwrite almost anything!
To skip 1000M's and then read 1M, use:
sudo dd if=/dev/sdd of=output-file bs=1M skip=1000 count=1
See https://wiki.archlinux.org/index.php/file_recovery and/or https://help.ubuntu.com/community/DataRecovery for more info, it can be involved. gddrescue has a great (but dry) GNU ddrescue Manual too, and search the web for lots more info.
photorec are the easiest to use IMO, I don't even bother with foremost or scalpel. Their homepages have good guides, see TestDisk's & TestDisk Step By Step and PhotoRec's & PhotoRec Step By Step. If testdisk can read the existing files, then copying them might be fairly easy, photorec doesn't save original filenames or directory structure.
Sometimes errors will show up when attempting reads & they might fail, error messages will probably flood
dmesg & /var/log/syslog then, I like to keep a terminal open running
dmesg -w &/or
tail -f /var/log/syslog to see new errors as they arrive. If you've got the space on another device, making a whole copy with gddrescue might be a good idea, it tries to skip over error sectors and read all the "good stuff" first, then try errors again later (or read "backwards", jump around, etc).
You could use
smartctl (in the smartmontools package) to read the SMART data & find out what it's errors are, even run new tests (but if the drive is failing, more tests could run down the clock on it's remaining life, so a backup first might be prudent). Here's my "notes" on
Commands to generate reports:
sudo smartctl --all /dev/sdX - prints all SMART info
sudo smartctl --xall /dev/sdX - prints all SMART and non-SMART info
If you're tracking changes, you could run a test every so often, saving it to a date-named file with:
sudo smartctl --xall /dev/sdX > $(date +"%Y-%m-%d_%H.%M")-sdX-smart-xall
To just get the "stats":
sudo smartctl -A /dev/sdX > $(date +"%Y-%m-%d_%H.%M")-sdX-smart-A
Use the option
-t TYPE where TYPE is one of:
short maybe ~2min
conveyance maybe ~5m
long maybe ~55m
offline maybe ~73m (4380s)
[times are examples from an old drive]
But not all drives support all tests.
-c option has a "Self-test execution status:" line that tells the current test's % remaining (if a test is running).
To see status could use:
sudo smartctl -c /dev/sda | grep "^Self" -A1