請問放在/dev/shm/下面的任何檔案都無法執行(已解決) [論壇 - LinuxMint]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊

« 1 (2)


回覆: 請問放在/dev/shm/下面的任何檔案都無法執行
管理員
註冊日期:
2010/5/7 5:46
所屬群組:
已註冊使用者
討論區管理群
等級: 31
HP : 0 / 755
MP : 434 / 29616
EXP: 23
離線
poloshiao 寫到:
明天早上 再幫你翻譯

感恩,麻煩你了

2012/12/15 22:50
應用擴展 工具箱
回覆: 請問放在/dev/shm/下面的任何檔案都無法執行
管理員
註冊日期:
2010/5/7 5:46
所屬群組:
已註冊使用者
討論區管理群
等級: 31
HP : 0 / 755
MP : 434 / 29616
EXP: 23
離線
後來我把一些檔案裝回舊版的去比較
[降級] sysvinit:amd64 2.88dsf-34 -> 2.88dsf-13.1+squeeze1
[降級] sysvinit-utils:amd64 2.88dsf-34 -> 2.88dsf-13.1+squeeze1
[降級] ifupdown:amd64 0.7.5 -> 0.7
[降級] initscripts:amd64 2.88dsf-34 -> 2.88dsf-22.1
[降級] sysv-rc:amd64 2.88dsf-34 -> 2.88dsf-13.1+squeeze1
這樣做之後,程式就可以放在/dev/shm/亦即/run/shm/裡執行
不一樣的地方在/etc/init.d/mountdevsubfs.sh
新版的mountdevsubfs.sh在shm的部分只有這樣(sysv-rc 2.88dsf-34)
# Mount a tmpfs on /run/shm
mount_shm "$MNTMODE"

而舊版的mountdevsubfs.sh有以下內容(sysv-rc 2.88dsf-13.1+squeeze1)
# Mount a tmpfs on /run/shm
	if [ ! -d /run/shm ]
	then
		mkdir --mode=755 /run/shm
		[ -x /sbin/restorecon ] && /sbin/restorecon /run/shm
	fi

	if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then
		domount "$MNTMODE" tmpfs shmfs /run/shm tmpfs "-onosuid,nodev$SHM_OPT"
	else
		chmod "$SHM_MODE" /run/shm
	fi

	# Migrate early, so /dev/shm is available from the start
	if [ "$MNTMODE" = mount_noupdate ] || [ "$MNTMODE" = mount ]; then
		run_migrate /dev/shm /run/shm ../run/shm
	fi

改完之後重開機就能在/dev/shm/裡執行程式和軟體
以上降級的部分皆已升回2.88dsf-34,ifupdown也裝回0.7.5
謝謝UGP和poloshiao兩位大大的幫忙,感謝^^
目前我的問題已解決,如有錯漏還請各位大大多多指教

2012/12/16 0:10
應用擴展 工具箱
回覆: 請問放在/dev/shm/下面的任何檔案都無法執行
管理員
註冊日期:
2011/3/11 6:32
所屬群組:
討論區管理群
等級: 44
HP : 216 / 1084
MP : 1088 / 39829
EXP: 38
離線
或許這只代表說本來就不應該在那種地方執行檔案?

2012/12/16 0:18
應用擴展 工具箱
回覆: 請問放在/dev/shm/下面的任何檔案都無法執行
管理員
註冊日期:
2010/5/7 5:46
所屬群組:
已註冊使用者
討論區管理群
等級: 31
HP : 0 / 755
MP : 434 / 29616
EXP: 23
離線
V字龍 寫到:
或許這只代表說本來就不應該在那種地方執行檔案?

我也不知道耶
可能是因為我用debian testing的關係

2012/12/16 0:24
應用擴展 工具箱
回覆: 請問放在/dev/shm/下面的任何檔案都無法執行(已解決)

註冊日期:
2009/12/6 10:32
所屬群組:
已註冊使用者
等級: 71
HP : 1053 / 1756
MP : 4456 / 70949
EXP: 24
離線
我用debian testing


我的是 ubuntu 12.04
代表 Ubuntu 12.04 還沒把 /run/shm 掛載爲 tmpfs 檔案系統形態

How to disable tmpfs on /run/shm in proper way


By default (at least on Debian wheezy), /run/shm is a subdirectory of /run, which is mounted as tmpfs. So if you don't want /run/shm to be a mount point, don't change the default configuration.

表示 在 Debian wheezy (以及 以後版本 ?) /run/shm 預裝時 是被掛載爲 tmpfs 檔案系統形態
所以 如果 你沒有 另將 /run/shm 爲 其它 掛載點 的需求 請不要改變這個預設

If you create an entry for /run/shm in /etc/fstab, it will be mounted only if you specify the filesystem type; otherwise /dev/shm is bind-mounted there.

如果 你要在 /etc/fstab 增加 一項 掛載 檔案系統 必須指定 -t 檔案系統 (猜測 指 tmpfs 以外的 檔案系統)
否則 該項 掛載 不會發生作用 (指不會改變 檔案系統 被綁定爲 tmpfs 檔案系統 的事實)

Not having /run/shm as tmpfs is not a supported configuration.

不把 /run/shm 綁定爲 tmpfs 檔案系統 是不被支援的設定

If you want to use some other filesystem type, create an fstab entry and edit /etc/init.d/mountall.sh and /etc/init.d/mountdevsubfs.sh so that they call mount_shm with an argument other than mount or mount_update.

如果 (你希望 在 /run/shm) 掛載爲 其它檔案系統
在 /etc/fstab 新增一個 掛載項目
修改 /etc/init.d/mountall.sh
修改 /etc/init.d/mountdevsubfs.sh
讓他們 呼叫 mount_shm 同時 引用 除了 mount 或 mount_update 以外的參數

Whatever you do, make sure that /run/shm is mode 1777 and has no files left over from a previous boot.

無論你做了哪些動作
確記 把 /run/shm 權限模式 設爲 1777 (第一個是數目字的 1)
同時 /run/shm 不可以含有 上一次 開機 關機後還留下來的檔案

不一樣的地方在/etc/init.d/mountdevsubfs.sh
新版的mountdevsubfs.sh在shm的部分只有這樣(sysv-rc 2.88dsf-34)
# Mount a tmpfs on /run/shm
mount_shm "$MNTMODE"


猜測 $MNTMODE 含有 mount 或 mount_update 參數

或許這只代表說本來就不應該在那種地方執行檔案?


Linux 官網文件 有關 tmpfs 檔案系統 :

Tmpfs is a file system which keeps all files in virtual memory.

Since tmpfs lives completely in the page cache and on swap, all tmpfs 20pages currently in memory will show up as cached. It will not show up 21as shared or something like that. Further on you can check the actual 22RAM+swap use of a tmpfs instance with df(1) and du(1).

tmpfs has the following uses:
(在這裏 列了 3 個 tmpfs 的用途 但是 沒有 存放 可執行檔 這一項)

1) There is always a kernel internal mount which you will not see at all. This is used for shared anonymous mappings and SYSV shared memory.

This mount does not depend on CONFIG_TMPFS. If CONFIG_TMPFS is not set, the user visible part of tmpfs is not build. But the internal mechanisms are always present.

2) glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for POSIX shared memory (shm_open, shm_unlink). Adding the following line to /etc/fstab should take care of this:

tmpfs /dev/shm tmpfs defaults 0 0

Remember to create the directory that you intend to mount tmpfs on if necessary.

This mount is _not_ needed for SYSV shared memory. The internal mount is used for that. (In the 2.3 kernel versions it was necessary to mount the predecessor of tmpfs (shm fs) to use SYSV shared memory)

3) Some people (including me) find it very convenient to mount it e.g. on /tmp and /var/tmp and have a big swap partition. And now loop mounts of tmpfs files do work, so mkinitrd shipped by most distributions should succeed with a tmpfs /tmp.

4) And probably a lot more I do not know about

簡單猜測:
你需要把 /run/shm 掛載爲 ramdisk 避免被掛載爲 tmpfs

2012/12/16 10:08
應用擴展 工具箱
回覆: 請問放在/dev/shm/下面的任何檔案都無法執行(已解決)
管理員
註冊日期:
2010/5/7 5:46
所屬群組:
已註冊使用者
討論區管理群
等級: 31
HP : 0 / 755
MP : 434 / 29616
EXP: 23
離線
poloshiao 寫到:
簡單猜測:
你需要把 /run/shm 掛載爲 ramdisk 避免被掛載爲 tmpfs

謝謝poloshiao的翻譯^^
df /dev/shm;df /run/shm/
檔案系統 1K-區段 已用 可用 已用% 掛載點
tmpfs 810960 229424 581536 29% /run/shm
檔案系統 1K-區段 已用 可用 已用% 掛載點
tmpfs 810960 229424 581536 29% /run/shm
這二個指令是我在修改mountdevsubfs.sh之後得到的結果
一樣都是tmpfs
修改前僅能放檔案,不能執行
我猜是考慮到安全因素之類的吧

2012/12/16 16:25
應用擴展 工具箱

« 1 (2)

 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.