Input/Output Error : Bad Blocks - How to Restart Linux

input output errors

This article I am trying to explain how to deal with "Input/output error " when you initiate any commands in Linux. I have pointed out some examples that report a similar error.

# du
-bash: /usr/bin/du: Input/output error
# mkdir sampledir
mkdir: cannot create directory `sampledir': Input/output error

Input/output error while running the command mostly due to two reason. Either it could be bad blocks on the disk or someone hacked your machine. In this situation first suggestion would be to check /var/log/messages for any disk related alerts (might see some sense key alerts).

tail -n 100 /var/log/messages
tail -f /var/log/messages

If you notice any disk issues, try any disk utility to confirm this. One option would be to use smarttools. You can check smartool option to fix bad blocks. If you already installed it you can take advantage of that.

The next immediate action would take a backup of your system. Good if you already have it :-). If you have a good backup it's safe to reboot. If your system was hacked there are chances they might mess up your files and system would not work after reboot.

You can also try fsck but it really doesn't fix most time if it bad block issue. Fsck can fix only if it related to any filesystem related issues.

Usually, fsck will fail in between as when it try to read the file at bad block.

Now if try to reboot, it can also give the same output. You can try init 6.

# reboot
bash: /sbin/reboot: Input/output error
# shutdown -r now
bash: /sbin/shutdown: Input/output error

If the above reboot commands doesn't work try either forced reboot or shutdown

Forced Reboot

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

Forced Shutdown

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger

Thanks for reading the article and let me know your comments.

Read Also:

5 Comments... add one

  1. I have the same problem but I may not execute the forced reboot:
    $ echo 1 > /proc/sys/kernel/sysrq
    -bash: /proc/sys/kernel/sysrq: Permission denied
    [fabrizio@taxiprofessional ~]$ echo b > /proc/sysrq-trigger
    -bash: /proc/sysrq-trigger: Permission denied
    I also tried prefixing with su to no avail.

    • You are not root.
      As can be seen by the "$" in the prompt rather than the "#" symbol.

      You can become the root user by issuing "$ su -" providing the root password.

      If you have the "sudo" command installed, and you are among "sudoers" (as is usual with Ubuntu) you can do this with:

      $ sudo bash -c "echo 1 > /proc/sys/kernel/sysrq"

      and providing the user password.


      $ sudo echo 1 > /proc/sys/kernel/sysrq

      will not work because the output redirection is applied with your non privileged user

  2. I copied/paste the two commands.
    The first command seemed to have been executed.
    But the second command could not be entered, because no more input could be done.
    So I think the (remote) system has been halted by the first command (I can't ping it anymore)
    I will check that tomorrow when back at work


Leave a Comment