[SOLVED] seeking how to keep a "media device" without media present
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.
seeking how to keep a "media device" without media present
My laptop SD-card reader is built-in. When I insert a media card, I get /dev/mmc0, /dev/mmcblk0, and /dev/mmcblk0p1 created based on the report from '/var/log/syslog'. When there is no media present, there is no device. Specificially,
Code:
prompt$ sudo ls /dev/mm*
password: **********
ls: cannot access /dev/mm*: No such file or directory
prompt$
When there is media present, even when not mounted, the device exists.
Code:
prompt$ mount | grep mmc
/dev/mmcblk0p1 on /media/user/MY-MEDIA type vfat (rw,nosuid,nodev,uid=6000,gid=6000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
prompt$ sudo ls /dev/mm*
password: **********
/dev/mmcblk0 /dev/mmcblk0p1
prompt$ sudo umount /dev/mmcblk0p1
prompt$ sudo ls /dev/mm*
/dev/mmcblk0 /dev/mmcblk0p1
Can I configure, and if so, how, such that the device is always present but I still get media "inserted" automatic processing?
udev was invented just for the opposite: make devices "on the fly" when they are needed instead on creating a lot static devices of which most aren't actually used on any given system.
That said you can still use the mknod command to create static devices, but why would you need that?
Well, now I have read you blog post on a similar topic and can tell you that doing that would in no way help to know in advance if your system has the ability to read and write SD cards. This ability depends on two things:
a hardware part: the SD card reader
a software part: a kernel driver (be it built in the kernel or provided as a module).
Making permanent (static) device in the /dev tree won't help you in any way to check that these conditions are fulfilled.
But was that really your question?
PS let's take a practical example.
I do have a SD card reader and when I plug a SD card, the same devices are created, and a kernel module called mmc_block is loaded. But please note that this kernel module is very generic as tells us the help message associated to it in the kernel configuration:
Code:
MMC block device driver (MMC_BLOCK)
CONFIG_MMC_BLOCK:
Say Y here to enable the MMC block device driver support.
This provides a block device driver, which you can use to
mount the filesystem. Almost everyone wishing MMC support
should say Y or M here.
Symbol: MMC_BLOCK [=m]
Type : tristate
Prompt: MMC block device driver
Location:
-> Device Drivers
-> MMC/SD/SDIO card support (MMC [=m])
Defined at drivers/mmc/card/Kconfig:7
Depends on: MMC [=m] && BLOCK [=y]
Anyway AFAIK even in a more specific case (a video or network adapter, for instance), to know in advance if a hardware part is supported we would need to:
know in advance the Vendor and Device IDs
scan the modules database with "modinfo <module_name>" to see if you have a proper module.
That is not realistic in my opinion. And knowing the device name won't help us at all anyway.
Last edited by Didier Spaier; 03-11-2015 at 05:07 PM.
udev was invented just for the opposite: make devices "on the fly" when they are needed instead on creating a lot static devices of which most aren't actually used on any given system.
That said you can still use the mknod command to create static devices, but why would you need that?
With a typical hard drive /dev/sdx, I can issue commands like:
trying to discover what, if anything, that I can from the attached partitions and file systems. Also, there is some dance so that I can use 'testDisk' against the drive.
In the case of media-card devices, there is nothing of the form /dev/????? to try and analyze. Thus my desire to make the device exists regardless of present media.
Thanks for your comments,
~~~ 0;-Dan
Last edited by SaintDanBert; 03-11-2015 at 05:25 PM.
In your examples you use gparted or fsck to deal with a disk drive or partition of a disk drive of a fixed device, that is listed in /etc/fstab.
You could use also these programs for disk drive or partitions of a removable device, as for instance an USB HDD. But of course the device should exist before you run fsck or gparted. That will be the case because when you plug in the USB HDD a device is created, exactly as with the SD card.
I don't see a problem in running fsck on /dev/mmcblk0p1 instead of /dev/sda2 for instance: that command will fail anyway if there is no SD card in the card reader, regardless of the existence of the device, so sorry, I still fail to see an issue here.
In other words, even if you create a static device in the /dev tree, you won't be able to run a command against it if a corresponding physical device is not attached to it.
Last edited by Didier Spaier; 03-11-2015 at 05:48 PM.
I know see this other thread of yours. Please open only one thread per issue, else you won't give relevant answers as people who try to help you miss important information.
To make a long story short: if a device is not created when you insert your card, that means that not only there isn't a good file system on it, but it's completely unusable: a usable SD card, even without any file system on it or a wrong partition table, would show. To confirm that, you can run "blkid": if the SD card doesn't show, just throw it away as you won't be able to repair it.
Last edited by Didier Spaier; 03-12-2015 at 06:02 AM.
...
You could use also these programs for disk drive or partitions of a removable device, as for instance an USB HDD. But of course the device should exist before you run fsck or gparted. That will be the case because when you plug in the USB HDD a device is created, exactly as with the SD card.
...
When I insert the SD-card into the card reader NOTHING HAPPENS based on what appears in /var/log/syslog. Therefore, I do not get the linux kernel "automatic" device detection and creation processing.
When I insert the SD-card into the card reader NOTHING HAPPENS based on what appears in /var/log/syslog. Therefore, I do not get the linux kernel "automatic" device detection and creation processing.
That means that your SD card is unusable (electrically broken) so the system has no way to communicate with it.
PS You could confirm that in trying it in another device, like a camera.
Last edited by Didier Spaier; 03-13-2015 at 11:57 AM.
Reason: PS added
I know see this other thread of yours. Please open only one thread per issue, else you won't give relevant answers as people who try to help you miss important information.
While both questions pertain to my SD-card reader, I see them as two separate issues.
effort trying to recover an SD-card
effort working with dynamic device creation and maintenance
Quote:
Originally Posted by Didier Spaier
To make a long story short: if a device is not created when you insert your card, that means that not only there isn't a good file system on it, but it's completely unusable: a usable SD card, even without any file system on it or a wrong partition table, would show. To confirm that, you can run "blkid": if the SD card doesn't show, just throw it away as you won't be able to repair it.
With a known, good SD-card in the reader, 'blkid' does not report anything about /dev/mmc. All that appears are the several file systems from my system HDD.
It does not matter if the SD-card is mounted or not mounted. I get nothing from 'blkid'.
With a known, good SD-card in the reader, 'blkid' does not report anything about /dev/mmc. All that appears are the several file systems from my system HDD.
It does not matter if the SD-card is mounted or not mounted. I get nothing from 'blkid'.
Usage of blkid or lsblk do not need partitions be mounted. Here is an example of commands and their output, could you please provide the same information on your system (with a good SD card inserted, of course):
When I repeat this sequence with the probably-dead uSD card, /dev/mmc* does not appear at all.
This was expected, see my post #8
Quote:
I still think there is some way to cause the device to exist all the time regardless of media.
Yes, you can get this behavior with following commands, typed as root:
Code:
mknod -m 660 mmcblk0 b 179 0
mknod -m 660 mmcblk0p1 b 179 1
But what is it worth?
You won't be able to do anything with these device nodes if you don't have a good media inserted anyway: if you issue the same commands (blkid and lsblk), of course the devices nodes won't show in the output, although the device exist as shows "ls -l /dev/mmcblk*":
Code:
~$ ls -l /dev/mmcblk*
brw-rw---- 1 root disk 179, 0 mars 20 17:07 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 mars 20 17:07 /dev/mmcblk0p1
~$
On the other hand if you don't issue these commands the same device nodes will be automatically created as soon as a good media is inserted, and then the device will be actually usable.
So yes, you can do that, but as far as I know this is completely useless.
But maybe I miss something? Then please tell me what.
Last edited by Didier Spaier; 03-24-2015 at 03:53 PM.
Reason: typo fixed
Yes, you can get this behavior with following commands, typed as root:
Code:
mknod -m 660 mmcblk0 b 179 0
mknod -m 660 mmcblk0p1 b 179 1
But what is it worth?
Thanks for these commands. I supposed that I'll need to run them on each system boot.
Is that correct? If so, do I put them into an /etc/rc.local file or has all that changed?
Quote:
Originally Posted by Didier Spaier
...
So yes, you can do that, but as far as I know this is completely useless.
But maybe I miss something? Then please tell me what.
It appears to me that a known good (electrically & mechanically) media card with a blown partition table or format or similar will not cause all of the detection and device creation dance. However, it would be possible to remake the partition table and then re-format ... but you need all of the device parts to exist. Your commands let me force a device so that gparted /dev/mmcblk0 and similar commands are possible.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.