Error in brand new External Hard Drive: "ls: reading directory '.': Input/output error"

11,102

This is old enough that the original poster has probably moved on but maybe this will help someone. I had a very similar problem that I was able to 'fix'. It was on the internal hard drive of a fairly new machine so I really didn't think it was hardware related. It's a Windows 10 PC with the Ubuntu Linux app. I had one folder (~40 files, 3 Gb) that became unreadable under Linux; same error ls: reading directory '.': Input/output error. I couldn't ls, mv, rm, rename, tar, etc. that one directory but all else seemed fine. I wasn't sure how it got that way, but turning the machine off when things were open may have been it (I swap a large monitor between a couple machines and don't always recall what state things are in for the monitor-less one). And, like the OP, I even had a file Notes.txt that I knew had been there and could no longer list but I could open it in vi!

The original post did help me (thanks) because I hadn't yet thought of going to look at the same place from the Windows file explorer. When I did, everything I expected was there and looked okay except I noticed one file not intentionally created by me called .~lock.hways_us.dbf#

I had been massaging/extracting some highway lat/longs from a shapefile/database set with my own code. So I just deleted the .~lock... file above with Windows and then the Linux side started working again just fine. I know this may be tougher to do with thousands files and it sounds like the OP may have had some file loss too, but perhaps there was some weird orphan file or file fragments like this that caused the problem.

Share:
11,102

Related videos on Youtube

Mario Rodríguez
Author by

Mario Rodríguez

Updated on September 18, 2022

Comments

  • Mario Rodríguez
    Mario Rodríguez over 1 year

    This morning I was downloading some files directly to an EXTERNAL Hard Drive (1TB Seagate Hard Drive, bought a week ago) and I had to shut down the PC without unmounting the disk and while it was downloading. Now I'm trying to list all the files within the folder where I was downloading and I get this error when I ls on it:

    ls: reading directory '.': Input/output error
    

    Aparently, the folder seems to be empty but it should have 200GB of files (around 160000 files). If I access it on Windows I can only see around 30000 files, but I can't see anything on Ubuntu, where I was performing the download.

    I have some other folders in the same Disk and none of them gives me the same error.

    I tried fsck and it doesn't seem to render any error:

    mario@mario-desktop:~$ sudo fsck /dev/sdc1
    fsck from util-linux 2.30.1
    

    Also, I know that there is a file called links.txt within this folder. I can access it by doing gedit links.txt and I can even copy it, but I can't see it on Windows nor Ubuntu. So it's seems that my files are there but there is some problems reading them. I think that I could manually copy them if I could remember the name of all of them.

    I installed today the GNOME-tweaks-tool, some GNOME extensions and some themes. I don't know it this can be related to the failure. I'm running Ubuntu 17.10 and Windows 10 on separate disks.

    Thank you so much in advance

    • Byte Commander
      Byte Commander about 6 years
      So, I/O error generally refers to hardware problems. Best case, it could be a lose cable, worst case the hdd is dying already. Try and unplug all cables of the disk, wiggle them around a bit, clean the plugs and sockets and reconnect the stuff. Then I'd check the SMART status of the disk, e.g. from Ubuntu's "Disks" application. You can also run a disk self-test from there. If that doesn't indicate any disk failure, probably "just" the file system got somehow corrupted during the power cut you mentioned. What file system is it? As you also use it on Windows, I guess NTFS or FAT32?
    • Mario Rodríguez
      Mario Rodríguez about 6 years
      Yes, I tried everything related to wires and connections. I tested it on another laptop running Ubuntu and in the same conditions (same apps and tools installed) and I get the same error. The thing is that I only get the I/O error with this folder, the rest of the disk seems to be OK. I can even create a file on this folder and access it, but as soon as I reload f5 it disapears and it is not listable (still vieweable and copyable). The shutdown wasn't manual, I just's pressed "shut down" on the upper right corner. It is NTFS
    • ender.qa
      ender.qa over 5 years