LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   /dev/shm mounted twice on -current (https://www.linuxquestions.org/questions/slackware-14/dev-shm-mounted-twice-on-current-4175571741/)

atelszewski 02-08-2016 04:31 PM

/dev/shm mounted twice on -current
 
Hi,

Code:

$ cat /proc/mounts
proc /proc proc rw,relatime,gid=2001,hidepid=2 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /run tmpfs rw,relatime,mode=755 0 0
devtmpfs /dev devtmpfs rw,relatime,size=4037652k,nr_inodes=1009413,mode=755 0 0
/dev/sda2 / ext4 rw,relatime,data=ordered 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,relatime 0 0
cgroup_root /sys/fs/cgroup tmpfs rw,relatime,mode=755 0 0
cpuset /sys/fs/cgroup/cpuset cgroup rw,relatime,cpuset 0 0
cpu /sys/fs/cgroup/cpu cgroup rw,relatime,cpu 0 0
cpuacct /sys/fs/cgroup/cpuacct cgroup rw,relatime,cpuacct 0 0
blkio /sys/fs/cgroup/blkio cgroup rw,relatime,blkio 0 0
memory /sys/fs/cgroup/memory cgroup rw,relatime,memory 0 0
devices /sys/fs/cgroup/devices cgroup rw,relatime,devices 0 0
freezer /sys/fs/cgroup/freezer cgroup rw,relatime,freezer 0 0
net_cls /sys/fs/cgroup/net_cls cgroup rw,relatime,net_cls 0 0
perf_event /sys/fs/cgroup/perf_event cgroup rw,relatime,perf_event 0 0
net_prio /sys/fs/cgroup/net_prio cgroup rw,relatime,net_prio 0 0
pids /sys/fs/cgroup/pids cgroup rw,relatime,pids 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sda3 /home ext4 rw,relatime,data=ordered 0 0
tmpfs /dev/shm tmpfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
gvfsd-fuse /home/antezu/.gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1001,group_id=100 0 0

/dev/shm is mounted twice. Is that correct?

--
Best regards,
Andrzej Telszewski

GazL 02-08-2016 05:49 PM

Well spotted. Looks like rc.udev mounts it before /etc/mtab gets cleared out, and then it gets mounted again by 'mount -a' later on.

This should fix it:
Code:

--- rc.S.orig  2016-02-08 23:15:45.715960963 +0000
+++ rc.S        2016-02-08 23:42:01.282616442 +0000
@@ -273,12 +273,15 @@
 # Add entry for / to /etc/mtab:
 /sbin/mount -f -w /
 
-# Add /proc and /sys mounts to /etc/mtab:
+# Add /proc, /sys and /dev/shm mounts to /etc/mtab:
 if [ -d /proc/sys ]; then
-  /sbin/mount -f proc /proc -t proc
+  /sbin/mount -f -t proc proc /proc
 fi
 if [ -d /sys/bus ]; then
-  /sbin/mount -f sysfs /sys -t sysfs
+  /sbin/mount -f -t sysfs sysfs /sys
+fi
+if grep -q '^[^ ]\+ /dev/shm ' /proc/mounts 2>/dev/null; then
+  /sbin/mount -f -t tmpfs tmpfs /dev/shm
 fi
 
 # Configure ISA Plug-and-Play devices:

I also took the liberty of fixing the mount commands: options should always come before args.

Andersen 02-15-2016 02:16 PM

Quote:

Current (pre-release) ChangeLog for x86_64

Thu Feb 11 21:56:21 UTC 2016
a/sysvinit-scripts-2.0-noarch-29.txz: Rebuilt.
rc.S: Avoid mounting /dev/shm twice.
Thanks to Andrzej Telszewski and GazL.
rc.6, rc.K: Match 'type nfs ' rather than 'type nfs' to avoid false hits
(and error messages) from matching nfsd pseudo-filesystems.
Thanks to Jonathan Woithe.
This solution found its way to -current changelog, but after latest upgrade I have problems with chromium and vlc:

Code:


ERROR:shared_memory_posix.cc(302)] Creating shared memory in /dev/shm/.org.chromium.Chromium.WkqRcM failed: Permission denied
[2217:2217:0215/210852:ERROR:shared_memory_posix.cc(305)] Unable to access(W_OK|X_OK) /dev/shm: Permission denied
[2217:2217:0215/210852:FATAL:shared_memory_posix.cc(307)] This is frequently caused by incorrect permissions on /dev/shm.  Try 'sudo chmod 1777 /dev/shm' to fix.

Code:


VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
shm_open() failed: Permission denied

Is it safe to try proposed fix chmod 1777 /dev/shm ?

atelszewski 02-15-2016 02:21 PM

Hi,

/dev/shm should be drwxrwxrwt, which is the case on my system.
Is your different?

--
Best regards,
Andrzej Telszewski

ponce 02-15-2016 02:23 PM

Quote:

Originally Posted by atelszewski (Post 5500662)
/dev/shm should be drwxrwxrwt, which is the case on my system.

I can confirm this: after installing latest updates, with the new rc.* scripts in place and rebooting
Code:

$ ls -la /dev/ | grep shm
drwxrwxrwt  2 root  root        100 feb 15 21:21 shm


Andersen 02-15-2016 02:38 PM

Upgraded, chose to overwrite with new config files, and rebooted, but..

Code:

bash-4.3$ ls -la /dev/ | grep shm
drwxr-xr-t   2 root  root          40 Sep 23  2008 shm

Then, just in case I missed O option last time, I did another check:

Quote:

bash-4.3# slackpkg new-config
Searching for NEW configuration files
No .new files found.
edit:

Only now I see Sep 23 2008 shm What the.. :/

yars 02-15-2016 04:11 PM

Quote:

Is it safe to try proposed fix chmod 1777 /dev/shm ?
Yes.
EDIT: Have you a entry for /dev/shm in fstab?

Andersen 02-15-2016 05:50 PM

Thanks. Yes I do..

Code:

tmpfs            /dev/shm        tmpfs      defaults        0  0
I don't know what caused the problem, but before the latest upgrade everything worked well..

GazL 02-15-2016 06:29 PM

Have you checked whether the /dev/shm mount is actually being done? (grep 'shm' /proc/mounts).

If it's not, then it's possible that the second unintended mount was masking a failure of the first, though why it might be failing I couldn't say.

Andersen 02-15-2016 06:46 PM

Code:

bash-4.3$ grep 'shm' /proc/mounts
tmpfs /dev/shm tmpfs rw,relatime 0 0

I tried chmod 1777 /dev/shm. It worked, but just until reboot.
Now it's back with drwxr-xr-t 2 root root 40 Sep 23 2008 shm

Richard Cranium 02-15-2016 08:06 PM

initrd, perhaps?

GazL 02-16-2016 04:47 AM

Just an observation regarding rc.udev:

One thing I noticed is that the mount for /dev/shm in rc.udev doesn't include a '-n' but the rootfs will be 'ro' at this point.

On modern kernels devtmpfs will be pre-mounted before rc.S or even the initrd get involved (CONFIG_DEVTMPFS_MOUNT=y). The unmounting of pts and shm in order to mount devtmpfs and the later remounting of shm and pts in rc.udev seems not at-all 'KISS', especially given that the rootfs will be 'ro' at this point: introducing other obstacles to be worked around. So, I'm wondering whether it might not be better all round to leave /dev/shm and /dev/pts for 'mount -a' to do (once rootfs has gone 'rw') and maybe even strip out all this dancing around with devtmpfs and related mounts from rc.udev completely.

Even if shm and pts are required this early in boot (are they?) and can't be left for 'mount -a', then I suggest it's better to promote their mounting into rc.S where all the other mounting activity resides. IMO it would be cleaner for rc.udev to just concern itself with udevd and not devtmpfs, /dev/shm or /dev/pts.

Andersen 02-16-2016 05:27 AM

Quote:

Originally Posted by Richard Cranium (Post 5500816)
initrd, perhaps?

I'm using huge.s kernel, no initrd. Actually, that's why this is even more puzzling to me, I didn't make any changes from default configuration.

GazL 02-16-2016 07:35 AM

Clearly something is not quite right with your system. /proc/mounts shows that /dev/shm is mounted, yet your ls -l shows a date of 2008 and non-default permissions, which doesn't make sense for a tmpfs created at boot time.

A few other things to check:
That devtmpfs is mounted on /dev
/etc/rc.d/rc.udev is 755, and has a md5sum of efc795ae7830f3ad598b6db170569e28
/lib/udev/devices/shm doesn't exist (in fact on my box the directory is empty).
That you haven't got anything funky in your rc.local.

Andersen 02-16-2016 07:58 AM

Quote:

Originally Posted by GazL (Post 5501003)
Clearly something is not quite right with your system. /proc/mounts shows that /dev/shm is mounted, yet your ls -l shows a date of 2008 and non-default permissions, which doesn't make sense for a tmpfs created at boot time.

A few other things to check:
That devtmpfs is mounted on /dev
/etc/rc.d/rc.udev is 755, and has a md5sum of efc795ae7830f3ad598b6db170569e28
/lib/udev/devices/shm doesn't exist (in fact on my box the directory is empty).
That you haven't got anything funky in your rc.local.

Thanks GazL. Everything looks ok from here:

Code:

bash-4.3$ grep 'devtmpfs' /proc/mounts
devtmpfs /dev devtmpfs rw,relatime,size=1947532k,nr_inodes=486883,mode=755 0 0

Code:

bash-4.3$ ls -l /etc/rc.d/rc.udev
-rwxr-xr-x 1 root root 7042 Feb  6 11:04 /etc/rc.d/rc.udev


Code:

bash-4.3$ md5sum /etc/rc.d/rc.udev
efc795ae7830f3ad598b6db170569e28  /etc/rc.d/rc.udev

rc.local is clear.

Code:

bash-4.3$ cat /etc/rc.d/rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

Quote:

/lib/udev/devices/shm doesn't exist (in fact on my box the directory is empty).
Same thing here.


All times are GMT -5. The time now is 04:50 AM.