How can I tell linux kernel to completely ignore a disk as if it was not even connected?

Two solutions here: one is fast to apply, although solves the problem only partially, the other one is the complete one but requires you to compile your own kernel.

The correct answer is a kernel patch.

Robin H. Johnson wrote a patch for the SATA kernel driver (find it in Unix/Linux stack exchange site) which hides completely the drive.

Update 1 The patch is now upstream (at least in 3.12.7 stable kernel), see the git repository. I asked for backport in the Ubuntu launchpad.

Update 2 The patch is in the standard kernel for Ubuntu Trusty Thar 14.04; so now only the following addition to boot parameter is needed.

Once the patch is installed, adding

 libata.force=2.00:disable

to the kernel boot parameters will hide the disk from the Linux kernel. Double check that the number is correct; searching for the device name can help:

(0)samsung-romano:~% dmesg | grep iSSD
[    1.493279] ata2.00: ATA-8: SanDisk iSSD P4 8GB, SSD 9.14, max UDMA/133
[    1.494236] scsi 1:0:0:0: Direct-Access     ATA      SanDisk iSSD P4  SSD  PQ: 0 ANSI: 5

To add a kernel parameter (bot temporarily and permanently) you can check this Q&A: How do I add a kernel boot parameter?

Workaround

At least the problem of enabling suspend-resume has been solved by by Unix StackExchange user Emmanuel in https://unix.stackexchange.com/a/103742/52205. As root, issue the command:

echo 1 > /sys/block/sdb/device/delete

before suspend.

To make it permanent, add the following file in /etc/pm/sleep.d/ and make it executable:

-rwxr-xr-x 1 root root 204 Dec  6 16:03 99_delete_sdb

with content:

#!/bin/sh

# Delete the failing disk so that it will not block suspend

case "$1" in
    suspend|hibernate)
        if [ -d /sys/block/sdb ]; then
            echo 1 > /sys/block/sdb/device/delete       
        fi
        ;;
esac

...and now the system suspends (and resume) correctly.


You can try to create the udev rule with the following information (output of udevadm info -a -n /dev/sdb).

INFO:

looking at parent device '/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0':
    KERNELS=="1:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{rev}=="SSD "
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="6"
    ATTRS{model}=="SanDisk iSSD P4 "
    ATTRS{state}=="running"
    ATTRS{queue_type}=="none"
    ATTRS{iodone_cnt}=="0x309"
    ATTRS{iorequest_cnt}=="0x30a"
    ATTRS{queue_ramp_up_period}=="120000"
    ATTRS{timeout}=="30"
    ATTRS{evt_media_change}=="0"
    ATTRS{ioerr_cnt}=="0x1d6"
    ATTRS{queue_depth}=="1"
    ATTRS{vendor}=="ATA     "
    ATTRS{device_blocked}=="0"
    ATTRS{iocounterbits}=="32"

1) Create the udev rule.

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

You can try to match the "SUBSYSTEMS" &"DRIVERS" keys, and "ATTRS{rev}" & ATTRS{model} attributes, then assign the "UDISKS" variable to ignore it.

The content of the 99-hide-ssd.rules file would be:

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

To save the changes in nano... Ctrl+O, then Enter and finally Ctrl+X.

2) Finally refresh the udev rules with:

  • sudo udevadm trigger

NOTE: With the ENV{UDISKS_IGNORE}="1" it will ignore the disk for Ubuntu 12.10 & 13.04.
For Ubuntu 12.04 the variable would be ENV{UDISKS_PRESENTATION_HIDE}="1".

Hope this helps.