How to avoid any type of partition probes when a HDD is detected by a booted up system, in a way that it only detects basic drive features as model, sector size and capacity, consequently creating just one device file as /dev/sda? Is it a libata/kernel issue?

It's about a data recovery experience with a damaged HDD that sectors corresponding to partition table should not being read. I'm not talking about auto-mount, it's already disabled.

The sectors linked to partitions are on a scratched area. When heads pass over there, drive crashes.

This is what happens when a healthy HDD is attached:

Dmesg Output

Oct 13 16:21:42 wks-01 kernel: [ 906.796660] sd 8:0:0:0: [sdb] 1953525167 512-byte logical blocks: (1.00 TB/931 GiB)...
Oct 13 16:21:42 wks-01 kernel: [ 906.915646] sdb: sdb1

(I need to disable that last routine)

Udev Output

KERNEL[906.915935] add /devices/pci0000:00/0000:00:1d.7/usb8/8-3/8-3:1.0/host8/target8:0:0/8:0:0:0/block/sdb (block)<br>
KERNEL[906.915999] add /devices/pci0000:00/0000:00:1d.7/usb8/8-3/8-3:1.0/host8/target8:0:0/8:0:0:0/block/sdb/**sdb1** (block)  (**I need to disable this routine)** ... <br>
UDEV [907.392087] add /devices/pci0000:00/0000:00:1d.7/usb8/8-3/8-3:1.0/host8/target8:0:0/8:0:0:0/block/sdb/sdb1 (block)
  • 1
    Why don't you want to read the partition table? The kernel will not write anything to the disk until you issue some command from userspace. – grochmal Oct 12 '16 at 21:10
  • Because those sectors shouldn't even be read. They're on a scratched area. When heads pass over there, drive crashes. Thanks for your reply. – William Oct 13 '16 at 16:29
  • Hm... interesting, to not read the drive you would need to disable the right kernel modules. My take on it would be to rmmod sd_mod scsi_mod. But you can't do it if your system is booted from a scsi disk (e.g. a USB stick or CD drive, or an actual disk), which isn't really feasible (maybe a network boot?). A better approach may be to let the disk crash an then power it back with hdparm. What happens when it crashes? – grochmal Oct 13 '16 at 16:56
  • I need to disable probing for partitions, not hdd detection. Thanks. – William Oct 13 '16 at 20:00
  • I think you're on the right path with udev, i forgot udev. On the kernel side libata and ata_generic should deal with the disk and the scsi stuff with the partitions, but I'm not that confident in that. Nevertheless I've edited your question to look a little better and tagged with udev since we want to attract people that are good with udev config. – grochmal Oct 14 '16 at 0:31

There isn't a way.

From the UDEV perspective the partition uevents are sent directly from the kernel, there is no indirection.

From the kernel side things happen from __blkdev_get() which will always read at least some of the partition table with disk_get_part(). That will read enough of the partition table to understand what kind of partition table it is.

As far as you can go is to unset CONFIG_MSDOS_PARTITION during kernel compilation so that msdos_partition() it will not be used inside check_partition(). I'm not sure how much of the partition it reads more compared to disk_get_part() though.


  • This is assuming that your disk uses an MSDOS partition. There are several other CONFIG_*_PARTIOTION parameters in /block/partitions/check.c.
  • You would need to boot this kernel from a drive that uses a different partition type than the one you want to backup. This may or may not be troublesome (GPT partitions are quite viable today).
  • Another way is that, maybe, you could rmmod scsi. But that would require you to not need the SCSI subsystem for anything. The only way I can think you can achieve that is through a network boot. You could then connect the damaged disk, use modprobe scsi to get the subsystem back, and make the node (mknod) by hand. This is hypothetical (I have not tried this), I'm not sure if mknod will not trigger __blkdev_get() screwing all the effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.