Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When a usb Hard Drive is attached I guess that (basically) kernel detects drive features (size, model, etc.), then it starts partitions table detection. After that udev creates correspondent block devices in /dev/ directory. Am I right?
How to prevent any kind 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 block device as /dev/sda?
It's about a data recovery experience with a damaged HDD that sectors corresponding to partition table should not being read.
Depends on OS you're using, but most will NOT mount the drive automatically. When you attach the disk, it will create the /dev/sdX and nothing else.
If your OS does mount the drive automatically, you can always get into init 3 (no GUI) and work there. Typically all the auto-mount features are only present in init 5.
I'm not talking about auto-mount, it's already disabled. The sectors linked to partitions table shouldn't even be read. They're on a scratched area. When heads pass over there, drive crashes. I need to disable partitons detection. Look...
Dmesg Output
Oct 13 16:21:42 wks-01 kernel: [ 904.788084] ...ready
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.796670] sd 8:0:0:0: [sdb] 2048-byte physical blocks
Oct 13 16:21:42 wks-01 kernel: [ 906.862030] sd 8:0:0:0: [sdb] Write Protect is off
Oct 13 16:21:42 wks-01 kernel: [ 906.862036] sd 8:0:0:0: [sdb] Mode Sense: 4f 00 00 00
Oct 13 16:21:42 wks-01 kernel: [ 906.862752] sd 8:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA Oct 13 16:21:42 wks-01 kernel: [ 906.915646] sdb: sdb1
I think you are out of luck.
The driver for that device will be issuing the ioctls to create the base device nodes - including for partition(s). Without the driver you can't talk to the device at all. udev merely reacts to the kernel uevents.
Then again, reading the partition table does not necessarily mean the rest of the disk is read. At least in case of MBR.
True, at least for primary partitions, but the nodes in /dev/disk/by-{id,label,uuid} require probing the content of the partition to get the needed parameters. I can see where udev rules use the parameters, but I don't see what establishes the values.
Trashing udev and switching to static /dev would help. There is even a tutorial how to do it in Gentoo.
I guess kernel recognizes partitions as soon as a drive is plugged in, so after that udev creates /dev/* files... I mean partition table is read by kernel and HDD heads runs over the damaged area. I don't think udev can stop that kernel routine.
You can build partition table support as module, then kernel can't load it at boot time and won't scan the drives. You have to figure out from what media to boot it that does not require MBR/GPT support in kernel. CD/DVD would work, I guess. My 2¢.
While grub2 will load up with sufficient support to detect and load the initrd etc from a local hard drive partition, it's not necessary for the loaded kernel to have any support for partitions at all. It only needs the nfs client.
Note that you don't need to mess around with your DHCP server or settings to do this. You just need to set up any computer on the same LAN with an nfs share.
Or you could even leave out the support for HDD controller(s) and boot the kernel from USB. Just thinking, I haven't tested such a setup. You still need SCSI layer enabled, even USB block device access goes thru it nowadays.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.