boatcoder
boatcoder

Reputation: 18107

How do you find the major and minor numbers for devices in linux

Trying to get access to a partially rooted Galaxy S2 external sd card.

The problem is that /dev/block/mmcblk1p1 does not exist on the phone. This is the device name that should allow me to put the "recovery" image onto the sdcard so that the unit will be a phone again.

Problem is, I don't know where to find the magic Major and Minor numbers for this device and I'm trying to figure out where in the kernel source I should be looking for them.

Could someone point me at the right kernel files to find this information?

Upvotes: 1

Views: 8208

Answers (2)

Benjamin Leinweber
Benjamin Leinweber

Reputation: 2954

According to hotplug.txt

Entries for block devices are found at the following locations:

/sys/block/*/dev /sys/block/*/*/dev

So try looking in /sys/block/mmcblk1p1/dev.

EDIT: Looking at it again I actually think that it will be in /sys/block/mmcblk1/mmcblk1p1/dev

Upvotes: 1

Ashwin
Ashwin

Reputation: 270

Standard devices use predefined major numbers and minor numbers starting from 0 for the first instance and upward depending on how many instances there are going to be.

Look at the Linux Documentation file(devices.txt) to see the full list but the section of interest to you is:

179 block       MMC block devices
          0 = /dev/mmcblk0      First SD/MMC card
          1 = /dev/mmcblk0p1    First partition on first MMC card
          8 = /dev/mmcblk1      Second SD/MMC card
            ...

        The start of next SD/MMC card can be configured with
        CONFIG_MMC_BLOCK_MINORS, or overridden at boot/modprobe
        time using the mmcblk.perdev_minors option. That would
        bump the offset between each card to be the configured
        value instead of the default 8.

So /dev/block/mmcblk1p1 would be major 179, minor 9.

Upvotes: 1

Related Questions