Input / Output Error : Bad Blocks : How To Restart Linux

October 10, 2012 | By
| 2 Replies More

Bad Disk

This article I am trying to explain how to deal with " Input/output error " when you initiate any commands in Linux. I have pointed some examples that reports 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 use smarttools. You can check smartool option to fix bad blocks. If you already installed it you can take the advantage of that.

Next immediate action would be take backup of your system. Good if you already have it :-). If you have good backup its safe to reboot.If your system was hacked there are chances they might messed up your file and system would not work after reboot.

You can also try fsck but it really dont 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 doesnot 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

Filed Under : HARDWARE, HOWTOS, LINUX HOWTO

Tagged With : ,

Free Linux Ebook to Download

Comments (2)

Trackback URL | Comments RSS Feed

  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.

    • Luca Ferroni says:

      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.

      WARNING:

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

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

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.