Software & AppsOperating SystemLinux

How To Ignore a Failing Disk in Linux Kernel

Ubuntu 8

In this article, we will explore how to ignore a failing disk in the Linux kernel. This can be useful in scenarios where a disk is failing but you do not want the system to be disrupted by the failing disk. We will discuss three methods: using a kernel patch, creating a udev rule, and using modprobe to blacklist the driver.

Quick Answer

It is possible to ignore a failing disk in the Linux kernel using three methods: using a kernel patch, creating a udev rule, or using modprobe to blacklist the driver. Each method has its own advantages and considerations, but all aim to prevent the failing disk from disrupting the system.

Method 1: Using a Kernel Patch

The first method involves using a kernel patch written by Robin H. Johnson. This patch hides the failing disk completely from the Linux kernel, making it as if it was not even connected. The patch has been upstreamed in the Linux kernel version 3.12.7 and later. You can check the git repository for the patch.

To apply this patch, you need to compile your own kernel. This is a complex process and should only be undertaken if you are comfortable with Linux system administration. If you are not familiar with this process, you can follow this guide to learn how to compile a kernel on Ubuntu.

Method 2: Creating a Udev Rule

The second method involves creating a udev rule to ignore the disk. Udev is a device manager for the Linux kernel. It manages device nodes in the /dev directory.

First, you need to gather the necessary information about the disk. You can do this by running the following command:

udevadm info -a -n /dev/sdb

This command will output a lot of information about the disk. You need to look for the SUBSYSTEMS, DRIVERS, ATTRS{rev}, and ATTRS{model} attributes.

Next, create a udev rule file with the following command:

sudo nano /etc/udev/rules.d/99-hide-ssd.rules

In this file, add the following line:

SUBSYSTEMS=="scsi", DRIVERS=="sd", ATTRS{rev}=="SSD ", ATTRS{model}=="SanDisk iSSD P4 ", ENV{UDISKS_IGNORE}="1"

This line matches the disk attributes and assigns the UDISKS_IGNORE variable to ignore the disk. Replace "SSD " and "SanDisk iSSD P4 " with the actual rev and model of your disk.

Save the file and refresh the udev rules with the following command:

sudo udevadm trigger

This will hide the disk from the Linux kernel.

Method 3: Using Modprobe to Blacklist the Driver

The third method involves using modprobe to blacklist the driver. This method is useful if the other disks are not using the AHCI driver or are not SSDs.

First, remove the driver for the current session with the following command:

sudo rmmod ahci

To reload the driver, run the following command:

sudo modprobe ahci

If everything works fine, you can blacklist the driver to prevent it from loading in future boots. Open the /etc/modprobe.d/blacklist.conf file and add the following line:

blacklist ahci

This will prevent the AHCI driver from loading and effectively ignore the disk.

Note: These methods may require administrative privileges and should be used with caution. Make sure to double-check the disk attributes and test the changes before making them permanent.

In conclusion, ignoring a failing disk in the Linux kernel can be achieved through several methods. Whether you choose to use a kernel patch, create a udev rule, or blacklist the driver, each method has its own advantages and considerations. Always remember to backup your data and test your changes before making them permanent.

What is a failing disk in the Linux kernel?

A failing disk in the Linux kernel refers to a disk that is experiencing hardware issues or errors, making it unreliable or unstable for data storage and retrieval.

Why would I want to ignore a failing disk in the Linux kernel?

Ignoring a failing disk can be useful when you want to prevent system disruptions caused by the failing disk. By ignoring the disk, you can continue using the system without being affected by the disk’s errors or failures.

How does using a kernel patch hide the failing disk?

The kernel patch mentioned in the article hides the failing disk completely from the Linux kernel. It modifies the kernel’s behavior to make it as if the failing disk was not even connected to the system. This prevents the kernel from accessing or interacting with the failing disk.

Can I apply the kernel patch without compiling my own kernel?

No, applying the kernel patch requires compiling your own kernel. It is a complex process and should only be undertaken if you are comfortable with Linux system administration. If you are not familiar with compiling a kernel, it is recommended to seek assistance or follow a comprehensive guide.

What is udev and why do I need to create a udev rule?

Udev is a device manager for the Linux kernel. It manages device nodes in the /dev directory. Creating a udev rule allows you to specify certain attributes of a disk and define actions to be taken by the system when the disk is detected. In this case, we create a udev rule to ignore the failing disk.

How do I gather the necessary information about the disk for creating a udev rule?

You can use the udevadm info -a -n /dev/sdb command to gather the necessary information about the disk. This command provides detailed information about the disk, including its subsystems, drivers, revision, and model attributes.

Can I use the provided udev rule example as it is?

No, you need to modify the provided udev rule example according to the attributes of your failing disk. Replace the "SSD " and "SanDisk iSSD P4 " in the example with the actual rev and model of your disk.

How do I test if the udev rule is working?

After creating the udev rule, you can test if it is working by refreshing the udev rules with the sudo udevadm trigger command. This will apply the new rule and hide the failing disk from the Linux kernel. You can verify the disk is ignored by checking if it is still visible in the system.

What is modprobe and how does it help in ignoring a failing disk?

Modprobe is a Linux command used to add or remove kernel modules/drivers. By using modprobe to blacklist the driver associated with the failing disk, you prevent the driver from loading and effectively ignore the disk. This method is suitable if the other disks are not using the AHCI driver or are not SSDs.

Is it necessary to backup my data before ignoring a failing disk?

Yes, it is highly recommended to backup your data before attempting to ignore a failing disk. Ignoring the disk may result in data loss or further damage to the disk. It is always better to have a backup to ensure the safety of your important files and information.

Leave a Comment

Your email address will not be published. Required fields are marked *