You are on page 1of 5

CANNOT ACCESS INPUT/OUTPUT 

ERROR IN LINUX

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


total 0

The above error indicate that i cannot access to the specific file on Linux, Delete not working.
with root user as well.
so the error is not a problem to delete files, it’s a problem about the file system itself and/or an

hardware problem, but before announce that it’s hardware issue   try the below solution :-

 Option #1:-

use command dmesg.

(display message or driver message) is a command on most Linux- and Unix-based operating
systems that prints the message buffer of the kernel. Read about that command here

Option #2 ( worked for me)

Use Fsck command to detect filesystem error and fix it.

How !!!

1.  First Umount File system ( that file located ). Using Umount command if it’s not able to
un mount the file system use lsof command or fuser to check which user using this
filesystem.
2. run the fsck -y /dev/…………….. 
3. mount file system again.

Fsck Command here
Cheers
Osama …

Symptom
When you delete or modify a file on a Linux ECS, the message Read-only file system is displayed.
Possible Causes
The possible causes are as follows:

 The file system goes into the read-only mode.

 The file system is mounted as read-only.

 The hardware is faulty, for example, there are bad sectors in the disk or the RAID controller card is
faulty.

Precautions
 Repairing file systems may cause data loss. Back up data in advance.

 If the issue you encounter does not fall into either of the following scenarios, check whether a
hardware fault occurs.

Scenario 1: File System Mounted as Read-only


1. Run the following command to check how the directory containing the deleted file is mounted:

# mount |grep Mount point


If ro is displayed in the output, the directory is mounted as read-only, and go to step 2.

If rw is displayed in the output, the directory is mounted as read/write, and perform procedures
described in Scenario 2.

2. Run the following command to remount the file system as read/write without restarting the system:

# mount -o remount,rw Mount point

NOTE:

To mount the file system as read/write upon the next startup, modify the parameters in the fourth
column in the /etc/fstab file.
Scenario 2: File System Error Occurred
1. Run the following command to check the file system information in the kernel:

# dmesg |egrep "ext[2..4]|xfs"


If the output contains "I/O error... inode", the file system goes into the read-only mode due to an
error.

As shown in the preceding figure, the file system needs to be repaired. Back up data before
repairing the file system. Since file systems cannot be repaired while in use, switch to the single-user
mode, in which all file systems are unmounted, to repair the file system.

2. Restart the system and switch to the single-user mode.


3. Query the all available devices and file systems.

# blkid
4. Check the files systems on device vdb1. For ext file systems, run the following command:

# fsck -n /dev/vdb1

NOTE:

If the output indicates that the file systems are mounted, unmount these file systems.

1. Run the following command to query the file systems mounted on the device:

# mount
2. Run the following command to unmount these file systems:

# Umount Mount point
5. Repair the file systems on device vdb1.

o For Ext file systems, run the following command:

# fsck /dev/vdb1
o For XFS file systems, run the following command:

# xfs_repair /dev/vdb1
xfs_repair an LVM on centos or other distros
September 23, 2016

For the first time I have started using LVM on my home server and things have been alright for
an year. I am able to resize, replace disks , expand size of my mount points or move mount to a
new disk without any trouble at all.

While its not relevant I am using CentOS 7.

I have had to force reboot the server a couple of times over the year and woefully XFS
complained of corruption 24 hours ago and it was time to figure this out. I kept dropping into
emergency mode upon reboot. There is also another reason for this problem. I have bad memory,
I bought some refurbished FB-DIMM DDR2 with ECC and ironically not all of it is good.

Anyway TL;DR

Filesystem : XFS

Boot with rescue CD/USB whatever and don’t mount anything

Are you using LVM? yes: Try with lvscan to confirm. The output will show you your lvm
volumes but they might be INACTIVE which is ok, we will fix it later.

Then if I run xfs_repair /dev/sdx1 on the failed disk it complains of bad superblock and it
also fails to find a good secondary superblock. Something like `Sorry, could not find valid
secondary superblock Exiting now.` Ofcourse I am using the wrong method which I am familiar
with because of the old non-LVM way of doing things to repair a drive because the drive was the
volume itself.

Wait! I need to repair from the Virtual Volume created by LVM.

start with

vgscan -v --mknodes

This will find and create /dev/xxx/ nodes for the lvm. But it is not mounted so it’s good.

Now activate the volumes, it still does not actually mount them, so still good.

vgchange -a y

Now see what volumes are active with another lvscan

I have /dev/centos/root which is what I need to fix. It is an XFS volume so this time I do


xfs_repair /dev/centos/root

bunch of output follows… repair is done. Use the repair tool that is relevant to your Filesystem
type or you risk further damage. Repeat the repair for other volumes as needed.

Lets finally mount and test

mkdir /mnt/test && mount /dev/centos/root /mnt/test

Looks good?

Unmount and reboot without rescue CD. You should try to verify the LVM once again in rescue
mode for all the volumes since multiple drives can span a volume.

Update 2018: Tested on CentOS and Ubuntu, including failed drives from another system
attached as external drive for recovery.

You might also like