0

In Linux kernel, are USBs, MMCs,SDcards considered as block device? If so, how does it realize if it is mounting/accessing a hard disk or another one? Because the physical organisation would be different, right?

1 Answer 1

1

In Linux kernel, are USBs, MMCs,SDcards considered as block device

The simple answer is yes. USB drives will show up as the normal /dev/sdb, /dev/sdc, etc. MMC/SDcards may show up this way if the card reader is a USB-connected one (some internal card readers are actually USB under the hood) or show up as /dev/mmcblk0, /dev/mmcblk1 (if you have more than one card reader) - partitions will be /dev/mmcblk0p1, /dev/mmcblk0p2 etc.

You can use the lsblk command to get an easy quick view of all the block devices on your system at a given moment.

As far as telling the device type, Linux doesn't care what a block device actually is. A block device is a block device to Linux and it's only different in respect to size, whether it's physically read only or not, and whether it accepts extra commands such as TRIM for an SSD.

3
  • Thank you for the answer. So it is all implemented by files in /block in the source code? Does that also mean if we disable BLOCK in configuration, it will disable all these memories as well? Jun 21, 2017 at 18:47
  • You haven't been able to disable the block layer in make menuconfig (which controls options for building a Linux kernel) for a long time. I think the only non-block-device file system is the virtual ones like /proc and /sys. So you could only meaningfully have no block layer if you did something to mount /proc at boot (which I don't know if the kernel supports) and you had something there that would make an executable (like a custom device driver). So really it's safe to assume you will always have block devices in a Linux system.
    – LawrenceC
    Jun 21, 2017 at 18:57
  • As mentioned in Kconfig available in /block, we disable block in case of some embedded systems. so how is that possible? Jun 22, 2017 at 7:38

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.