[SOLVED] How to extract HDD block device from partition dev

Programming languages, Coding, executables, and scripting.
Message
Author
User avatar
cpoakes
Posts: 99
Joined: 2015-03-29 04:54

Re: [SOLVED] How to extract HDD block device from partition

#21 Post by cpoakes »

Since mapping between device names and device major:minor numbers is a convention not inherent to the kernel (e.g. mknod /dev/anythingIwant b 8 2), a general solution would simply ignore the string value.
  • Map the given partition device name (/dev/sda3, /dev/hda7, /dev/mtdblock0p1, /dev/anythingIwant) to the major:minor device number
  • Use those to create a temporary root device for major:0
  • Perform actions on the temporary root device, and
  • Delete the temporary root device.
The task can be completed in C or in the shell without understanding the underlying conventions, save for one applicable to all *nix: the minor number 0 is used for the whole device on partitionable devices. Saves the programmer from needing to understand all the naming conventions employed by device drivers (Curse you mtdblock driver with your stupid names!).

Hypex
Posts: 25
Joined: 2016-09-23 04:39
Location: Southern Aussieland

Re: [SOLVED] How to extract HDD block device from partition

#22 Post by Hypex »

Thanks cpoakes. That sheds some more light on the process. And what steps are needed to be performed. Which work for both conventional device nodes and mtb block naming schemes.

Post Reply