dannyman.toldme.com


Linux, Technical

How To Blacklist a Disk on Linux

Full disclosure: I got this from Claude after a bunch of more traditional research didn’t get me there.

Use case:

  1. you have a server with a bad disk
  2. and low urgency to replace the disk
  3. automation which detects and uses available disks
  4. also, the drive numbering is non-deterministic at boot
  5. so you want that disk to not be used until you get around to replacing it

The basic workaround to disable a disk, for example:

echo offline > /sys/block/sdd/device/state

That is fine until you reboot. You need something more robust.

Above, I suggested you had “automation which detects and uses available disks” so you could implement a blacklist mechanism in your automation. I thought I would mention that.

Okay, so, here’s the solution that Claude gave me. It works for me so now share with you.

First, get the serial number that udev sees. For example:

> udevadm info --query=property --name=/dev/sdd | grep ID_SERIAL_SHORT=
ID_SERIAL_SHORT=abc123

And tell udev to … I think this means “when you add it, delete it”

> cat /etc/udev/rules.d/99-blacklist-baddisk.rules
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?", ENV{ID_SERIAL_SHORT}=="abc123", ATTR{device/delete}="1"

Okay, so, why am I posting some AI slop? Well, because I like the idea that if you search for an answer on the Internet it ought to be out there somewhere. And whatever advice you find on online, in a blog, in a forum, or from an LLM, you need to test that out yourself. I found a solution that works for me, so I am posting it online for others to find, and test, and use.

I don’t reckon anyone is going to get on my case, but I figured I would offer that description and the caveat up top just so we’re all on the same page.

Read More


Previous:
Categories: Linux, Technical
Possibly-Related Posts

Comment

Leave a comment . . .

Tiny Print:

  1. For private messages, e-mail me: dannyman@toldme.com.
  2. You must provide an e-mail address.
  3. You can use a bogus e-mail address, but I like to know who you are.
  4. I will not spam you. I will not publish or share your e-mail address.
  5. First-time commenters will be held for review.
  6. You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>