Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to list and remove the content of a directory on a removable hard drive. But I have experienced "Input/output error":

$ rm  pic -R
rm: cannot remove `pic/60.jpg': Input/output error
rm: cannot remove `pic/006.jpg': Input/output error
rm: cannot remove `pic/008.jpg': Input/output error
rm: cannot remove `pic/011.jpg': Input/output error

$ ls -la pic
ls: cannot access pic/60.jpg: Input/output error
-????????? ? ?    ?         ?            ? 006.jpg
-????????? ? ?    ?         ?            ? 006.jpg
-????????? ? ?    ?         ?            ? 011.jpg

I was wondering what the problem is?

How can I recover or remove the directory pic and all of its content?

My OS is Ubuntu 12.04, and the removable hard drive has ntfs filesystem. Other directories not containing or inside pic on the removable hard drive are working fine.

Thanks and regards!


Added:

Last part of output of dmesg after I tried to list the content of the directory:

[19000.712070] usb 1-1: new high-speed USB device number 2 using ehci_hcd
[19000.853167] usb-storage 1-1:1.0: Quirks match for vid 05e3 pid 0702: 520
[19000.853195] scsi5 : usb-storage 1-1:1.0
[19001.856687] scsi 5:0:0:0: Direct-Access     ST316002 1A               0811 PQ: 0 ANSI: 0
[19001.858821] sd 5:0:0:0: Attached scsi generic sg2 type 0
[19001.861733] sd 5:0:0:0: [sdb] 312581808 512-byte logical blocks: (160 GB/149 GiB)
[19001.862969] sd 5:0:0:0: [sdb] Test WP failed, assume Write Enabled
[19001.865223] sd 5:0:0:0: [sdb] Cache data unavailable
[19001.865232] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[19001.867597] sd 5:0:0:0: [sdb] Test WP failed, assume Write Enabled
[19001.869214] sd 5:0:0:0: [sdb] Cache data unavailable
[19001.869218] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[19001.891946]  sdb: sdb1
[19001.894713] sd 5:0:0:0: [sdb] Test WP failed, assume Write Enabled
[19001.895950] sd 5:0:0:0: [sdb] Cache data unavailable
[19001.895953] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[19001.895958] sd 5:0:0:0: [sdb] Attached SCSI disk
[19113.024123] usb 2-1: new high-speed USB device number 3 using ehci_hcd
[19113.218157] scsi6 : usb-storage 2-1:1.0
[19114.232249] scsi 6:0:0:0: Direct-Access     USB 2.0  Storage Device   0100 PQ: 0 ANSI: 0 CCS
[19114.233992] sd 6:0:0:0: Attached scsi generic sg3 type 0
[19114.242547] sd 6:0:0:0: [sdc] 312581808 512-byte logical blocks: (160 GB/149 GiB)
[19114.243144] sd 6:0:0:0: [sdc] Write Protect is off
[19114.243154] sd 6:0:0:0: [sdc] Mode Sense: 08 00 00 00
[19114.243770] sd 6:0:0:0: [sdc] No Caching mode page present
[19114.243778] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[19114.252797] sd 6:0:0:0: [sdc] No Caching mode page present
[19114.252807] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[19114.280407]  sdc: sdc1 < sdc5 >
[19114.289774] sd 6:0:0:0: [sdc] No Caching mode page present
[19114.289779] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[19114.289783] sd 6:0:0:0: [sdc] Attached SCSI disk
share|improve this question
    
An I/O error can be a hardware issue (damaged RAM or hard disk). It can also mean a damaged filesystem or a driver bug; since this is NTFS I wouldn't rule this out. –  Gilles Jun 2 '12 at 23:45
add comment

4 Answers

Input/Output errors during filesystem access attempts generally mean hardware issues.

Type dmesg and check the last few lines of output. If the disc or the connection to it is failing, it'll be noted there.

EDIT Are you mounting it via ntfs or ntfs-3g ? As I recall, the legacy ntfs driver had no stable write support and was largely abandoned when it turned out ntfs-3g was significantly more stable and secure.

share|improve this answer
    
I connect the removable hard drive to my Ubuntu 12.04, and it is automatically mounted. So I guess ntfs-3g? –  Tim Jun 2 '12 at 23:31
1  
Don't "guess". Check -- you can see how everything is mounted by typing the mount command and looking at the output. –  Shadur Jun 2 '12 at 23:33
    
(1) I have added the last part of output of dmesg after I tried to list the content of the directory. I don't know how it helps. (2) I can't see if it is mounted by nfts-3g or ntfs, by looking at the output of mount: /dev/sdb1 on /media/removable_drive type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096) –  Tim Jun 2 '12 at 23:40
    
fuseblk means it's using the fuser filesystem-in-userspace method which is what ntfs-3g uses. So you're good in that regard. –  Shadur Jun 3 '12 at 0:31
add comment

As Sadhur states this is probably caused by disk hardware issues and the dmesg output is the right place to check this.

You can issue a surface scan of your disk from Linux /sbin/badblocks /dev/sda.

Check the manual page for more thorough tests an basic fixes (block relocation). This is all filesystem-agnostic, so it is safe even with an NTFS filesystem as it operates on the 'disk surface' level.

I personally made this to run on a monthly basis from cron. Of course you need to check if you receive the cron mails in your mailbox (which is often not the case by default). These mails end up in /var/mail/$USER or similar.

I created /etc/cron.d/badblocks:

30 4 * * 3 root [ -x /sbin/badblocks ] && [ $(date +\%d) -le 7 ] && /sbin/badblocks /dev/sda
share|improve this answer
    
Thanks! To run the command you suggested, is it /sbin/badblocks /media/removable_drive in my case? –  Tim Jun 3 '12 at 13:11
    
No. According to the dmesg output you have to use sdb: /sbin/badblocks /dev/sdb or sdc. I can't really figure out what happend / you did from dmesg –  jippie Jun 3 '12 at 13:20
add comment

Your filesystem is damaged , for NTFS volumes you should run a chkdsk under windows system , but it's nearly impossible to recover. Sometimes you might need to format the disk.

share|improve this answer
    
Thanks! My other directories are fine. Can I not format the whole drive, just reclaim the space from the directory in question? –  Tim Jun 3 '12 at 1:12
    
@Tim , you had to copy all of the rest out , format and copy them back ... i don't know if one can remove a single node ... not familiar with NTFS structure –  warl0ck Jun 3 '12 at 1:14
    
Before formatting, try the badblocks commmand on Linux. –  jippie Jun 3 '12 at 7:47
add comment

Its very easy with "UNLINK" command. You can't use any other removing method in linux for it.

unlink "file name"

share|improve this answer
    
That is nonsense. –  Hauke Laging Feb 24 at 7:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.