Input/output error is a general error message that happens all the time under different situation. It indicates a problem in filesystem level, more specifically, the operating system cannot access a certain part of the disk drive (or virtual disk drive).
In this article, we will explain the possible reasons why the “errno 5 input/output error” message happens and a few solutions that might help solving it.
“[Errno 5] Input/output error” causes
Before we get into any further, let’s make it clear that the error indicates a problem happens with the disk while the operating system is writing or reading from it. The error is specific to Linux machines.
Sometimes, especially in situation where you’re running Linux as a virtual machine, the cause of “[Errno 5] Input/output error” might be related to the hypervisor. Try updating VMware or VirtualBox to see if the problem goes away.
Windows is currently under heavy development with changes are made every few months, that makes running a virtual machine more complex than ever. On Windows machines, you have to pay attention to Hyper-V to see if it plays nicely with VirtualBox or VMware. If Hyper-V causes the problem, you would have no choice but update VMware or VirtualBox (or reinstall Windows, of course).
“errno 5 input/output error” when trying to install Ubuntu/Debian
The error might look like the image above.
Not only happens on Ubuntu/Debian, the identical error message can also be displayed in Linux Mint (as it is a Ubuntu derivative).
Now there are several things you can try :
- Make sure your CD/DVD or flash drive contents are not corrupted. Usually the only thing you need to do is verifying MD5 hash of the ISO file you’ve downloaded against the official value from Ubuntu/Debian/Linux Mint website.
- Backup the existing disk (the whole HDD, not only the important partition) then delete all of them to reformat the whole disk. Or you could choose “Erase disk and install Ubuntu” to avoid manually deleting partitions.
- Test your RAM for defects. You can use MemTest86 to conduct this type of test. If you have a defect RAM, remove or replace it.
- Last resort : Replace the HDD to see if the error message goes away.
“errno 5 input/output error” when using Google Colab
Colaboratory, also known as Google Colab, is a product from Google Research, it allows running Python code through the browser, especially suitable for data analysis, machine learning and education. Colab also allows running terminal commands prefix with the exclamation mark.
Sometimes, running terminal commands in Colab returns “”[Errno 5] Input/output error”. Another form of this error is “OSError: [Errno 5] Input/output error” when you try to run Python code that access the filesystem.
Google Drive integration in Colab is handy, but since these are 2 different services running in a cloud of thousands of servers, sometimes it performs not as well as if it is a physical server. If you’re connecting to Google Drive and mounted it to Colab, remember these rules of thumb to avoid input/output error :
- Number of files or subfolders in a folder should not be too large. We recommend keeping them under 50 subfolders/files.
- Try not to perform too many read/write operations to mounted Google Drive folder. Instead of that, write to the virtual environment disk, then move all of them to Google Drive mounted folder. The moving data functionality must have been thoroughly coded and tested before they launch Google Colab.
- Try not to run any snippet of code for too long since it may cause Colab to raise timeout error.
- Try not to move too much data at a short period of time. There are quota set by Google which are not necessary shown while using Colab. Basically, once the limit is passed you get the [Errno 5] Input/output error independent on the file or the operation you were doing.
- When in doubt, move files and folders out of
/content/drivebefore manipulating them might solve your problem.
“OSError: errno 5 input/output error” with Python
It doesn’t really matter that you are using Django, Odoo, PyTorch or low-level libraries like pexpect or shutil, if there’s something wrong while reading/writing data to the disk, “OSError: errno 5 input/output error” might be the first error you will see.
There’s a couple of things you can try, depends on your specific scenario :
- Check the disk for errors. On Windows, you can run
chkdsk. On Linux, there is
fsck. If there are recoverable errors, they’ll be fixed. After that, your Python program may run without any issue.
- Carefully inspect the permissions of the folder/directory you’re working in. It should include appropriate read/write permission.
- Replace the disk drive to see if the problem goes away. If it does, then your disk drive is faulty.
We hope that the solutions above help you solve your problem and learn something along the way. If you’re new to Linux, you might want to checkout our guide on common error messages such as “ifconfig: command not found” and “cannot stat”. Backing up is important to avoid losing data, too, so we conducted 10+ practical Rclone examples – Rclone tutorial for beginners to get you started quicker.