LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-11-2015, 03:56 PM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
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?

Thanks in advance,
~~~ 0;-Dan
 
Old 03-11-2015, 04:32 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
I don't see what it would be useful for.

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?
 
1 members found this post helpful.
Old 03-11-2015, 04:49 PM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 03-11-2015, 05:23 PM   #4
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by Didier Spaier View Post
I don't see what it would be useful for.

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:
Code:
prompt$ sudo gparted /dev/sdx
...
prompt$ #--- or ---
prompt$ sudo fsck -t {something} /dev/sdxN
...
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.
 
Old 03-11-2015, 05:44 PM   #5
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
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.
 
Old 03-12-2015, 06:00 AM   #6
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
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.
 
Old 03-13-2015, 11:50 AM   #7
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by Didier Spaier View Post
...
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.

Thanks for your reply,
~~~ 0;-/ Dan
 
Old 03-13-2015, 11:52 AM   #8
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by SaintDanBert View Post
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
 
Old 03-13-2015, 11:59 AM   #9
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by Didier Spaier View Post
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.
  1. effort trying to recover an SD-card
  2. effort working with dynamic device creation and maintenance
Quote:
Originally Posted by Didier Spaier View Post
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'.

Thanks for your reply,
~~~ 0;-Dan
 
Old 03-13-2015, 12:28 PM   #10
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by SaintDanBert View Post
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):
Code:
bash-4.2# blkid
/dev/sda1: UUID="18daeb4e-de59-47c5-beea-4317d5659137" TYPE="ext4" 
/dev/sda2: UUID="cad3fb03-ebe8-4505-902c-d6d23e99bb54" TYPE="ext4" 
/dev/sdb1: LABEL="RM-CM-)servM-CM-) au systM-CM-(me" UUID="9C228B78228B5664" TYPE="ntfs" 
/dev/sdb2: UUID="186C8F406C8F1820" TYPE="ntfs" 
/dev/sdb3: UUID="8522fbc6-a468-4e4b-909b-026292a4df4a" TYPE="ext4" 
/dev/mmcblk0p1: UUID="F009-64A5" TYPE="vfat" 
bash-4.2# lsblk -o name,size,fstype,mountpoint,label,model
NAME          SIZE FSTYPE MOUNTPOINT LABEL              MODEL
sda         931,5G                                      WDC WD10JPVX-22J
sda1        800G ext4   /archives                     
sda2         25G ext4   /64-14.1                      
sdb         111,8G                                      KINGSTON SMS200S
sdb1        100M ntfs              Rserv_au_systme 
sdb2       43,3G ntfs                                 
sdb3       68,4G ext4   /                             
sr0          1024M                                      DVDRAM GT50N    
mmcblk0       3,7G                                      
mmcblk0p1   3,7G vfat                                 
bash-4.2#

Last edited by Didier Spaier; 03-13-2015 at 12:55 PM.
 
Old 03-19-2015, 08:35 PM   #11
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by Didier Spaier View Post
...
could you please provide the same information on your system (with a good SD card inserted, of course)
Here is the information that you asked for:
Code:
kaywine ~ # sudo -i
password: ********

kaywine ~ # blkid
/dev/sda1: LABEL="SYSTEM_DRV" UUID="FC58364758360146" TYPE="ntfs" 
/dev/sda2: LABEL="Windows7_OS" UUID="82863FB4863FA815" TYPE="ntfs" 
/dev/sda4: LABEL="Lenovo_Recovery" UUID="762E4A512E4A0B17" TYPE="ntfs" 
/dev/sda5: UUID="e13bd512-5b8b-4459-a4b1-a73963c44c6d" TYPE="ext4" 
/dev/sda6: UUID="2351227d-9464-4aac-b70f-3c6ae8b7a631" TYPE="swap" 
/dev/sda7: UUID="b624769c-7032-406a-8499-35f5bebe6cb6" TYPE="ext4" 
/dev/sda8: LABEL="MyHOME" UUID="ed00015a-2d5e-47c7-8bf3-533af5821d14" TYPE="ext4" 
/dev/sda9: LABEL="MyWORK" UUID="fa24b96d-38a2-4ded-ad41-206dfb42ef2d" TYPE="ext4" 
/dev/mmcblk0p1: LABEL="SD-KAYWINE" UUID="74B8-823E" TYPE="vfat"
kaywine ~ # 
kaywine ~ # 
kaywine ~ # lsblk -o name,size,fstype,mountpoint,label,model
NAME          SIZE FSTYPE MOUNTPOINT              LABEL           MODEL
sda         465.8G                                                WDC WD5000LPVT-7
├─sda1        1.5G ntfs                           SYSTEM_DRV      
├─sda2      162.9G ntfs                           Windows7_OS     
├─sda3          1K                                                
├─sda4       11.7G ntfs                           Lenovo_Recovery 
├─sda5        1.9G ext4   /boot                                   
├─sda6        8.6G swap   [SWAP]                                  
├─sda7       37.3G ext4   /                                       
├─sda8       74.4G ext4   /home                   MyHOME          
└─sda9      167.7G ext4   /wrk                    MyWORK          
mmcblk0      14.9G                                                
└─mmcblk0p1  14.9G vfat   /media/saint/SD-KAYWINE SD-KAYWINE
kaywine ~ #
{blushing}
It is amazing what happens when you read examples for that all important # (root shell) prompt.
{blushing}

When I repeat this sequence with the probably-dead uSD card, /dev/mmc* does not appear at all.

Taps and a stiff drink for a life well lived... dead chip.
~~~ 8d;-/ Dan

I still think there is some way to cause the device to exist all the time regardless of media.
 
Old 03-20-2015, 11:24 AM   #12
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by SaintDanBert View Post
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
 
Old 03-27-2015, 09:21 AM   #13
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by Didier Spaier View Post
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 View Post
...
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.

~~~ 0;-Dan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Why does /media/cdrecorder pop up with "cd /media/ + tab" when I have /media/usb too? SharpyWarpy Fedora 6 11-22-2012 01:05 AM
LQ search: "NO NAME" MEDIA interpreted as "NO NAME" OR MEDIA. [!] stf92 LQ Suggestions & Feedback 3 09-09-2011 06:20 PM
executing "DOS/Windows executable" files from "/media" Ruarscampbell Linux - Newbie 10 07-05-2011 05:48 PM
LXer: Aol's Linux-based "Smartscreen Media Device" flies in from left field LXer Syndicated Linux News 0 01-10-2007 09:33 PM
DVD wont mon't drive stays lit "no media present" aero402 Linux - Software 5 01-05-2005 09:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration