LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2017, 11:02 AM   #16
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,832

Rep: Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676

If you're sticjking with the sdcard, 'noatime' would be better than 'relatime.' Atime writes every 5 seconds; relatime writes every 15 seconds; noatime is best.
 
Old 08-16-2017, 01:26 AM   #17
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,231
Blog Entries: 10

Rep: Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160
i think you should delete your custom udev rules and stick with the shell script, and the advice given in post #2.

or, you should reformulate your problem from scratch.
here's a simple rule:
you never say "it doesn't work" without providing full disclosure about commands issued, output received (errors or not), general system information etc.
 
Old 08-20-2017, 03:39 AM   #18
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hello,

ok, I removed all and try this:
Code:
cat /etc/udev/rules.d/69-sdcard.rules
KERNEL=="mmcblk0", SYMLINK+="sdcard"

ACTION=="add", RUN+="/home/domo/sdcard_insertion.sh"
ACTION=="remove", RUN+="/home/domo/sdcard_removed.sh"
Code:
cat sdcard_insertion.sh
#! /bin/sh

/bin/mkdir /home/domo/sdcard_present
/bin/mount /dev/mmcblk0p1 /media/card/
Code:
cat sdcard_removed.sh
#! /bin/sh

/bin/rm -R /home/domo/sdcard_present
When I now put the sd_card in the beaglebone, the folder are created, when I remove the sdcard, it will be delete.

Now I want to mount over with the sh.script the sdcard. When I put the sdcard in the beaglebone, I get in the syslog:
Code:
Aug 20 10:35:23 foxc0a800bd kernel: [320476.390036] mmc0: host does not support reading read-only switch, assuming write-enable
Aug 20 10:35:23 c0a800bd kernel: [320476.395067] mmc0: new high speed SDHC card at address 0007
Aug 20 10:35:23 c0a800bd kernel: [320476.411492] mmcblk0: mmc0:0007 SD16G 14.4 GiB
Aug 20 10:35:23 c0a800bd kernel: [320476.419344]  mmcblk0: p1
but the folder in /media/card is empty

When I run after in den commandline:
/bin/mount /dev/mmcblk0p1 /media/card/

then it works.

But why not in the bash script?
 
Old 08-20-2017, 03:58 AM   #19
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hello,

I see now in the syslog:
Aug 20 10:53:49 c0a800bd systemd-udevd[20525]: Process '/home/domo/sdcard_insertion.sh' failed with exit code 32.
Aug 20 10:53:53 c0a800bd systemd-udevd[20525]: Process '/home/domo/sdcard_insertion.sh' failed with exit code 32.
Aug 20 10:53:56 c0a800bd systemd-udevd[20525]: Process '/home/domo/sdcard_insertion.sh' failed with exit code 32.

Error 32 means:
mount failure


Same when I remove the sdcard:
Aug 20 10:56:45 c0a800bd kernel: [321758.605831] mmc0: card 0007 removed
Aug 20 10:56:45 c0a800bd kernel: [321758.716607] FAT-fs (mmcblk0p1): FAT read failed (blocknr 802)
Aug 20 10:56:45 c0a800bd kernel: [321758.730084] FAT-fs (mmcblk0p1): unable to read boot sector to mark fs as dirty
Aug 20 10:56:45 c0a800bd systemd-udevd[20666]: Process '/bin/sh /home/domo/sdcard_removed.sh' failed with exit code 32.
Aug 20 10:56:45 c0a800bd systemd-udevd[20671]: Process '/bin/sh /home/domo/sdcard_removed.sh' failed with exit code 32.
Aug 20 10:56:45 c0a800bd systemd-udevd[20666]: Process '/bin/sh /home/domo/sdcard_removed.sh' failed with exit code 32.

But why 3-times?

Here the new scripts:
cat sdcard_insertion.sh
#! /bin/sh

/bin/mkdir /home/domo/sdcard_present
sleep 3s
fsck.vfat -v -a -w /dev/mmcblk0p1
/bin/mount /dev/mmcblk0p1 /media/card/


cat sdcard_removed.sh
#! /bin/sh

/bin/rm -R /home/domo/sdcard_present
/bin/umount /media/card/
 
Old 08-20-2017, 10:17 AM   #20
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,832

Rep: Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676
Code:
Aug 20 10:56:45 c0a800bd kernel: [321758.605831] mmc0: card 0007 removed
Aug 20 10:56:45 c0a800bd kernel: [321758.716607] FAT-fs (mmcblk0p1): FAT read failed (blocknr 802)
In the first line, why is it /dev/mmc0? Is your sdcard mounting sometimes as /dev/mmc0? It certainly would explain the FAT read fail.
Code:
grep mmc0 /var/log/messages
might clear this up.

Checking with 'grep -r', I have no mention of mmc0 in /lib/udev/ or /etc/udev, or of course in /dev, although I have /dev/mmcblk0, & /dev/mmcblk0p1.
 
Old 08-20-2017, 11:59 PM   #21
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hello,

I don´t know why there is mmc0.

Here are some informations:
cat /etc/udev/rules.d/69-sdcard.rules
Code:
KERNEL=="mmcblk0p1", SYMLINK+="sdcard", GOTO="sd_cards_auto_mount_end"

ACTION=="add", RUN+="/bin/sh /home/domo/sdcard_insertion.sh"
ACTION=="remove", RUN+="/bin/sh /home/domo/sdcard_removed.sh"

LABEL="sd_cards_auto_mount_end"
grep mmc0 /var/log/messages
Code:
Aug 21 06:48:48 foxc0a800bd kernel: [  332.849825] mmc0: host does not support reading read-only switch, assuming write-enable
Aug 21 06:48:48 foxc0a800bd kernel: [  332.855045] mmc0: new high speed SDHC card at address 0007
Aug 21 06:48:48 foxc0a800bd kernel: [  332.871791] mmcblk0: mmc0:0007 SD16G 14.4 GiB
dmesg
Code:
[  332.849825] mmc0: host does not support reading read-only switch, assuming write-enable
[  332.855045] mmc0: new high speed SDHC card at address 0007
[  332.871791] mmcblk0: mmc0:0007 SD16G 14.4 GiB
[  332.879312]  mmcblk0: p1
tail -f /var/log/syslog
Code:
Aug 21 06:48:48 c0a800bd kernel: [  332.849825] mmc0: host does not support reading read-only switch, assuming write-enable
Aug 21 06:48:48 c0a800bd rsyslogd-2007: action 'action 17' suspended, next retry is Mon Aug 21 06:49:18 2017 [try http://www.rsyslog.com/e/2007 ]
Aug 21 06:48:48 c0a800bd kernel: [  332.855045] mmc0: new high speed SDHC card at address 0007
Aug 21 06:48:48 c0a800bd kernel: [  332.871791] mmcblk0: mmc0:0007 SD16G 14.4 GiB
Aug 21 06:48:48 c0a800bd kernel: [  332.879312]  mmcblk0: p1
Aug 21 06:48:52 c0a800bd systemd-udevd[5459]: Process '/bin/sh /home/domo/sdcard_insertion.sh' failed with exit code 32.
Aug 21 06:48:55 c0a800bd systemd-udevd[5459]: Process '/bin/sh /home/domo/sdcard_insertion.sh' failed with exit code 32.
cat sdcard_insertion.sh
Code:
#! /bin/sh

/bin/mkdir /home/domo/sdcard_present
sleep 3s
fsck.vfat -v -a -w /dev/mmcblk0p1
/bin/mount /dev/mmcblk0p1 /media/card/
 
Old 08-21-2017, 03:41 AM   #22
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,832

Rep: Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676
Can we try a workaround? With the offending card out,
Code:
cd /dev
sudo ln - sf mmcblk0p1 mmc0
If that works, it's a gift, but I don't really expect it to. I did a basic grep in the kernel source, and mmc0 appears to be handed out by the kernel, and not udev, and seems to be part of various sdcard controllers and GPIO (General Purpose Input Output) stuff, as sdcards are not read by a bus. GPIO stuff is old, slow & clunky, implemented these days in a small corner of some asic. HP used to have a GPIO bus on their instruments to automate them (in the days before widespread automation), but nobody in their right mind outside of a factory environment ever used it :-/. I'm actually surprised to find it still alive.
 
Old 08-21-2017, 11:45 AM   #23
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hello,

I get:
Code:
ln: target ‘mmc0’ is not a directory
 
Old 08-21-2017, 11:54 AM   #24
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,832

Rep: Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676
Right. I hoped rather than expected that to work. Can you post the output of
Code:
ls -l /dev/mmc*
both with the sdcard in and out.
 
Old 08-21-2017, 12:00 PM   #25
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
with sdcard:
Code:
brw-rw---- 1 root disk 179, 24 Aug 21 18:58 /dev/mmcblk0
brw-rw---- 1 root disk 179, 25 Aug 21 18:58 /dev/mmcblk0p1
brw-rw---- 1 root disk 179,  0 Aug 21 13:36 /dev/mmcblk1
brw-rw---- 1 root disk 179,  8 Aug 21 13:36 /dev/mmcblk1boot0
brw-rw---- 1 root disk 179, 16 Aug 21 13:37 /dev/mmcblk1boot1
brw-rw---- 1 root disk 179,  1 Aug 21 13:37 /dev/mmcblk1p1
without sdcard:
Code:
brw-rw---- 1 root disk 179,  0 Aug 21 13:36 /dev/mmcblk1
brw-rw---- 1 root disk 179,  8 Aug 21 13:36 /dev/mmcblk1boot0
brw-rw---- 1 root disk 179, 16 Aug 21 13:37 /dev/mmcblk1boot1
brw-rw---- 1 root disk 179,  1 Aug 21 13:37 /dev/mmcblk1p1
Thanks for your help
 
Old 08-21-2017, 01:45 PM   #26
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,832

Rep: Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676Reputation: 1676
No mmc0? But it was there previously, and screwed things up.

I THINK what's going on is that mmc0 is some bit of the sdcard apparatus, which is mistaken by the kernel for the actual sdcard. Then the card is seen on mmc0, not mmcblk0. If that's right, you might solve it with one of the following bodges:

1. Put mmc0 in /etc/fstab with a 'noauto' option, (before mmcblk0p1) so it will not be mounted.

2. Copy the fstab line for mmcblk0p1, except make mmc0 the device node. This line should go after mmcblk0p1. Both should not exist at the same time. Scripts will have to be changed to use the mount directory instead of the device node.

For your script in post #1, you would have something like
Code:
if [ -b /dev/mmcblk0p1];
<syntax & stuff>
elif [ -b /dev/mmc0];
<syntax & stuff>
Otherwise, I'd look into whether you could cobble a kernel without mmc0. Distro kernels are inclined to have everything but the kitchen sink in them, but you mightn't need the offending stuff. What is /dev/mmcblk1 in your box?
 
Old 08-21-2017, 03:09 PM   #27
rypikashu90
LQ Newbie
 
Registered: Aug 2017
Posts: 2

Rep: Reputation: 0
forum site's accounts .research involves looking at not just one source/website but lots of sources and websites/videos to gather as much information as you can then come to a conclusion ahhaha [racism+personal attack].come at me i dare you-[WWII era racism, also seen earlier]
 
Old 08-21-2017, 03:09 PM   #28
rypikashu90
LQ Newbie
 
Registered: Aug 2017
Posts: 2

Rep: Reputation: 0
Note: Post very much edited by mod to remove harshest words and directed attacks against a member. It should seem clear that the OP here chose to go on the extreme offensive with the slightest provocation and this type of behavior is not acceptable within LQ ever.
 
Old 08-22-2017, 12:06 AM   #29
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Good morning,

ok, I can try ... but when I start the script at the commandline and not via udev, it works fine.

And this is my fstab:
Code:
cat /etc/fstab
# /etc/fstab: static file system information.
#
UUID=a26ac92c-c772-40fc-aa2e-0ccc87a4bb30  /  ext4  noatime,errors=remount-ro  0  1
debugfs  /sys/kernel/debug  debugfs  defaults  0  0
Quote:
Originally Posted by business_kid View Post
No mmc0? But it was there previously, and screwed things up.

I THINK what's going on is that mmc0 is some bit of the sdcard apparatus, which is mistaken by the kernel for the actual sdcard. Then the card is seen on mmc0, not mmcblk0. If that's right, you might solve it with one of the following bodges:

1. Put mmc0 in /etc/fstab with a 'noauto' option, (before mmcblk0p1) so it will not be mounted.

2. Copy the fstab line for mmcblk0p1, except make mmc0 the device node. This line should go after mmcblk0p1. Both should not exist at the same time. Scripts will have to be changed to use the mount directory instead of the device node.

For your script in post #1, you would have something like
Code:
if [ -b /dev/mmcblk0p1];
<syntax & stuff>
elif [ -b /dev/mmc0];
<syntax & stuff>
Otherwise, I'd look into whether you could cobble a kernel without mmc0. Distro kernels are inclined to have everything but the kitchen sink in them, but you mightn't need the offending stuff. What is /dev/mmcblk1 in your box?

Last edited by fohnbit; 08-22-2017 at 12:08 AM.
 
Old 08-22-2017, 01:58 AM   #30
fohnbit
LQ Newbie
 
Registered: Aug 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hello,

crazy ... now it works without any script or udev rule.

I added this to the fstab:
Code:
/dev/mmcblk0p1   /media/card  auto auto,rw,async,user,nofail  0   0
Now anytime I put it the sd card in the beaglebone, it mount and unmount when I remove.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] BASH Script - What am I doing wrong in this test? - BASH Script BW-userx Programming 34 04-08-2017 01:36 PM
MLED installation script as a proof-of-concept gegechris99 Microlinux / MLED 139 01-11-2017 08:03 AM
LXer: 4 host-proof or PRISM-proof Cloud storage services LXer Syndicated Linux News 0 08-19-2013 02:30 PM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:01 PM.

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