關於設定Debian Jessie /etc/default/tmpfs遇到的狀況 [論壇 - 新手村]


正在瀏覽:   1 名遊客


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

« 1 (2) 3 4 »


回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線

2015/5/23 22:08
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線
執行「df -h」 ,可以看到預設掛載一些「tmpfs」。



檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 504M 216K 504M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 12K 101M 1% /run/user/1000



但是在「/etc/fstab」並沒有設定。
剛剛提的「/etc/default/tmpfs」的機制也沒執行。
所以我現在有個疑問了,預設掛載的那些「tmpfs」,是在那設的

我猜應該跟「systemd有關」,初步看起來好像「在這」。

繼續探索...




## 探索紀錄


$ systemctl list-unit-files | grep mount



(我曉得為什麼我剛剛回覆提到的「tmp.mount enabled 」那一行會不見了,因為上面指令,我多加了個參數「--type=service」,也就是 「systemctl list-unit-files --type=service | grep mount」。)

顯示


proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
run-vmblock\x2dfuse.mount enabled
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
tmp.mount enabled
mountall-bootclean.service masked
mountall.service masked
mountdevsubfs.service masked
mountkernfs.service masked
mountnfs-bootclean.service masked
mountnfs.service masked
systemd-remount-fs.service static
umountfs.service masked
umountnfs.service masked
umountroot.service masked
umount.target static






執行


$ systemctl status systemd-remount-fs.service



顯示


● systemd-remount-fs.service - Remount Root and Kernel File Systems
Loaded: loaded (/lib/systemd/system/systemd-remount-fs.service; static)
Active: active (exited) since 六 2015-05-23 16:37:05 CST; 6h ago
Docs: man:systemd-remount-fs.service(8)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Main PID: 220 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/systemd-remount-fs.service




http://www.freedesktop.org/software/systemd/man/systemd-remount-fs.service.html
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems/

$ man systemd-remount-fs.service

$ cat /lib/systemd/system/systemd-remount-fs.service

https://github.com/systemd/systemd/blob/master/src/remount-fs/remount-fs.c
https://github.com/systemd/systemd/blob/master/src/core/mount-setup.h
https://github.com/systemd/systemd/blob/master/src/core/mount-setup.c

$ man file-hierarchy
$ man systemd.unit
$ man tmpfiles.d

2015/5/23 23:25
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線
BrLi 寫到:
IanHo 寫到:
我需要修正我的提問內容:

系統環境預設值為 Debian Jessie + gnome + 硬體:4GB RAM
系統預設值環境在"系統監控"可以查到:
裝置 tmpfs 目錄 /dev/shm 總數 2.1GB 可用空間 2.1GB 已經使用 225.3kB
然而我進入 /dev/shm 裏頭查看,可以發現有好幾個檔案容量均為67.1MB的
pulse-shm-XXXXXXXXXX 檔案。
接下來,"我需要"擴充 /dev/shm 裏頭的空間,我需要增大到2.5GB,
(若我的主機有8GB RAM,我會要把 /dev/shm 增大到5GB)


一般來講,我們不會想把檔案寫進/dev/shm,且那邊其實是直接顯示記憶體的空間狀況(總記憶體 - 被mount成tmpfs的容量)
所以一般而言,沒必要特別去指定/dev/shm的容量(而且,其實他的值+所有tmpfs的值>實際記憶體的話,系統會報錯誤,極有可能開機失敗)

所以,常見的實做通常是控制/tmp

IanHo 寫到:我會利用這個空間來 擺放/指向 例如gimp的"置換檔",網路瀏覽器的cache路徑等等。
/dev/shm下的資料,我是"不需要"另存檔案的,關機後消失沒有差。


CACHEDIR=/tmp/cache-$USER
[[ ! -d $CACHEDIR ]] && install -dm700 $CACHEDIR
rm -rf ~/.cache && ln -sf $CACHEDIR ~/.cache

把上面那串讀懂以後,寫進去~/.bashrc


IanHo 寫到:我期望/需求的操作設定情境是,在"不需要"額外於終端機內下指令的"前提"下,
不需造再新增更多字串的"前提"下(但是可以改字串/新增數值/改數值)
“有沒有”哪個"現成的"某個路徑下的"參數設定檔案"內的某個字串,可以讓我修改/新增數值?
然後重開機之後,裝置 tmpfs 目錄 /dev/shm "總數"的空間,
就可以是我填入的數值(或著很接近的數值)???
我有查閱 /etc/default/tmpfs 檔案的內容。
有嘗試man tmpfs了,個人英文文件能消化的有限,
我把 SHM_SIZE= 這行開頭的井字註解拿掉,並且填入數值 2500000000
存檔重開機後,發現"沒有"效果,
裝置 tmpfs 目錄 /dev/shm 總數仍然還是 2.1GB(主記憶體的一半)。


在/etc/fstab中,該mount設定那行的options後面加上size=?G或size=?M就好了,例如:
# <file system> <dir> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs nodev,nosuid,size=2G 0 0


如上所述,/dev/shm本身是換算的結果,直接改那邊根本不應該要有效果
且結果也與預期相符合,因為預設/tmp沒指定尺寸的話,就是主記憶體的一半,那想當然,/dev/shm就會是另外一半
假如真有心要親手搞定這玩意兒的話,建議是一邊查一邊讀man,通常man都有寫得很清楚了
但很可惜,查錯方向了。
你應該去查man fstab,而它會建議你去查 man mount,而有關mount options的東西,man mount裡都寫的詳詳細細,尤其是tmpfs options那邊,就有提到要怎麼指定tmpfs的容量大小
簡單的講,fstab只是一個讓系統開機時順著讀過去給mount這隻程式運作的script而已



我個人覺得上面這一段,對於某些講法,我還是充滿了疑惑,所以可以請大家來探討嗎?

另外我想要確認的是,上面的說法,是針對Debian系統嗎?或是其他的「Distribution」。


============================================================

關於

BrLi 寫到:

一般來講,我們不會想把檔案寫進/dev/shm



真的是這樣嗎?

我一直想要了解「/dev/shm」到底是什麼作用。

有特定的作用嗎?

還是也可以任意放置檔案?

雖然我查到幾篇有提到,但我還是,不是很了解。

http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems/



/dev/shm as location for userspace shared memory objects



http://wiki.linux.org.hk/w/Tmpfs



Linux 最早在 2.4 時開始引入 tmpfs。現時被大量應用在 /dev/shm 作為 POSIX 分享記憶體、/dev 作為 udev 存放裝置檔案、/var/run 存放各軟件的 PID 和 socket 和 /var/lock 用作鎖定檔案等。GLib 2.2 開始要求需要 tmpfs 掛載於 /dev/shm 才可以使用 POSIX 分享記憶體



後來找到一個比較看得懂的了

https://wiki.debian.org/ReleaseGoals/RunDirectory?highlight=%28mount%29#Packages_using_.2Fdev.2Fshm



Packages using /dev/shm

If you're using /dev/shm directly, then your package is broken. You should only be accessing it via the eglibc shm_* and sem_* functions implementing the POSIX SHM and SEM features. If we do eventually deprecate /dev/shm in favour of /run/shm, eglibc will need configuring to use /run/shm directly. In consequence, if you are using the standard interfaces such as shm_open, sem_open etc., no transition is required.




============================================================

關於

BrLi 寫到:


且那邊(/dev/shm)其實是直接顯示記憶體的空間狀況

(總記憶體 - 被mount成tmpfs的容量)



可以告訴我,你上面的說法,在哪裡有文件可以閱讀嗎?
還是你自己測試出來的結果,在什麼系統上測試的?

以下是我在「Debian 8 (Jessie) Gnome 32位元 」上測試的數據,
我是灌在「VirtualBox」上,我不知道會不會影響。


## 硬碟分割狀況,「SWAP」是「2G」

執行


$ lsblk



顯示



NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
├─sda1 8:1 0 78G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sr0 11:0 1 1024M 0 rom




## 記憶體狀況,「主記憶體: 1G」-「Swap: 2G」

執行


$ free -h



顯示


total used free shared buffers cached
Mem: 1.0G 580M 427M 5.5M 23M 285M
-/+ buffers/cache: 271M 736M
Swap: 2.0G 0B 2.0G



## 掛載情形

「fstab」並沒有做任何掛載「tmpfs」的設定



# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=eeed1950-c51a-4ed1-ac35-3de40ce408a4 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=91e3b74b-b319-46f7-bb12-7a8cf43c6a11 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0




執行


$ df -h



顯示


檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 504M 160K 504M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000



上面的「tmpfs」加起來, 「197 + 504 + 5 + 504 + 101 + 101」 = 1412M。

加起來已經超過了主記憶體的「1G(1024M)」了。

跟你說的「(總記憶體 - 被mount成tmpfs的容量)=「/dev/shm」」,好像有出入

1024 - (197 + 5 + 504 + 101 + 101) = 1024 - 908 = 116

照你的說法來算,「/dev/shm」,應該是「116M」,可是實際顯示的是「504M」。

加上「swap」來當作「總記憶體」好了,「(1+2)*1024 = 3072」。

3072 - (197 + 5 + 504 + 101 + 101) = 3072 - 908 = 2164

照你的說法來算,「/dev/shm」,應該是「2164M」,可是實際顯示的是「504M」。

----------------------------------------------------------

換個狀況,

修改「fstab」,將「/tmp」掛載成「tmpfs」,並且不指定大小。


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=eeed1950-c51a-4ed1-ac35-3de40ce408a4 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=91e3b74b-b319-46f7-bb12-7a8cf43c6a11 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
tmpfs /tmp tmpfs defaults 0 0



執行


$ df -h




顯示


檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 504M 216K 504M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 504M 4.0K 504M 1% /tmp
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000




上面的「tmpfs」加起來, 「197 + 504 + 5 + 504 + 504 + 101 + 101」 = 1916M。

加起來已經超過了主記憶體的「1G(1024M)」了。

跟你說的「(總記憶體 - 被mount成tmpfs的容量)=「/dev/shm」」,好像有出入

1024 - (197 + 5 + 504 + 504 + 101 + 101) = 1024 - 1412 = -338

照你的說法來算,「/dev/shm」,應該是「-338M」,可是實際顯示的是「504M」。

加上「swap」來當作「總記憶體」好了,「(1+2)*1024 = 3072」。

3072 - (197 + 5 + 504 + 504 + 101 + 101) = 3072 - 1412 = 1600

照你的說法來算,「/dev/shm」,應該是「1600M」,可是實際顯示的是「504M」。

所以對照你另一段話

BrLi 寫到:
如上所述,/dev/shm本身是換算的結果,直接改那邊根本不應該要有效果
且結果也與預期相符合,因為預設/tmp沒指定尺寸的話,就是主記憶體的一半,那想當然,/dev/shm就會是另外一半



只有一個有match的。哪就是掛載「tmpfs」預設沒指定大小的話,會是「主記憶體的一半」,(注意是掛載「tmpfs」,不是掛載「/tmp」喔)

這個在「man mount」有說明
,結果是一致的。



Mount options for tmpfs
size=nbytes
Override default maximum size of the filesystem. The size is
given in bytes, and rounded up to entire pages. The default is
half of the memory. The size parameter also accepts a suffix %
to limit this tmpfs instance to that percentage of your physical
RAM: the default, when neither size nor nr_blocks is specified,
is size=50%


----------------------------------------------------------

再換個情況好了,

多掛載個「tmpfs」上來好了,掛到「/hi」這個路徑,一樣不指定大小。





# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=eeed1950-c51a-4ed1-ac35-3de40ce408a4 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=91e3b74b-b319-46f7-bb12-7a8cf43c6a11 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
tmpfs /tmp tmpfs defaults 0 0
tmpfs /hi tmpfs defaults 0 0




執行


$ df -h



顯示


檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 504M 160K 504M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 504M 0 504M 0% /hi
tmpfs 504M 4.0K 504M 1% /tmp
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000




上面的「tmpfs」加起來, 「197 + 504 + 5 + 504 + 504 + 504 + 101 + 101」 = 2420M。

加起來已經超過了主記憶體的「1G(1024M)」了。

跟你說的「(總記憶體 - 被mount成tmpfs的容量)=「/dev/shm」」,好像有出入

1024 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 1024 - 1916 = -892

照你的說法來算,「/dev/shm」,應該是「-892」,可是實際顯示的是「504M」。

加上「swap」來當作「總記憶體」好了,「(1+2)*1024 = 3072」。

3072 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 3072 - 1916 = 1156

照你的說法來算,「/dev/shm」,應該是「1156M」,可是實際顯示的是「504M」。

----------------------------------------------------------

再換個情況好了,

下指令來重新掛載「/dev/shm」的大小好了

執行


$ sudo mount -o remount,size=2G /dev/shm



再執行


$ df -h



顯示


檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 2.0G 216K 2.0G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 504M 0 504M 0% /hi
tmpfs 504M 4.0K 504M 1% /tmp
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000




上面的「tmpfs」加起來, 「197 + 2048 + 5 + 504 + 504 + 504 + 101 + 101」 = 3964M。

加起來已經超過了主記憶體的「1G(1024M)」了。
而且「/dev/shm」設成「2G(2048M)」,也超過了主記憶體的「1G(1024M)」了。

跟你說的「(總記憶體 - 被mount成tmpfs的容量)=「/dev/shm」」,好像有出入

1024 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 1024 - 1916 = -892

照你的說法來算,「/dev/shm」,應該是「-892M」,可是實際顯示的是「2048M」。

加上「swap」來當作「總記憶體」好了,「(1+2)*1024 = 3072」。

3072 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 3072 - 1916 = 1156

照你的說法來算,「/dev/shm」,應該是「1156M」,可是實際顯示的是「2048M」。


對照你說的一段話

BrLi 寫到:

如上所述,/dev/shm本身是換算的結果,直接改那邊根本不應該要有效果



----------------------------------------------------------

再換個情況好了

把剛剛手動更改「/dev/shm」大小的方式,改為寫在「/etc/fstab」


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=eeed1950-c51a-4ed1-ac35-3de40ce408a4 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=91e3b74b-b319-46f7-bb12-7a8cf43c6a11 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
tmpfs /tmp tmpfs defaults 0 0
tmpfs /hi tmpfs defaults 0 0
tmpfs /dev/shm tmpfs defaults,size=2G 0 0



執行


$ df -h



顯示




檔案系統 容量 已用 可用 已用% 掛載點
/dev/sda1 77G 4.6G 69G 7% /
udev 10M 0 10M 0% /dev
tmpfs 202M 4.8M 197M 3% /run
tmpfs 2.0G 216K 2.0G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
tmpfs 504M 0 504M 0% /hi
tmpfs 504M 4.0K 504M 1% /tmp
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000





上面的「tmpfs」加起來, 「197 + 2048 + 5 + 504 + 504 + 504 + 101 + 101」 = 3964M。

加起來已經超過了主記憶體的「1G(1024M)」了。
而且「/dev/shm」設成「2G(2048M)」,也超過了主記憶體的「1G(1024M)」了。

跟你說的「(總記憶體 - 被mount成tmpfs的容量)=「/dev/shm」」,好像有出入

1024 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 1024 - 1916 = -892

照你的說法來算,「/dev/shm」,應該是「-892M」,可是實際顯示的是「2048M」。

加上「swap」來當作「總記憶體」好了,「(1+2)*1024 = 3072」。

3072 - (197 + 5 + 504 + 504 + 504 + 101 + 101) = 3072 - 1916 = 1156

照你的說法來算,「/dev/shm」,應該是「1156M」,可是實際顯示的是「2048M」。

對照你說的一段話

BrLi 寫到:

所以一般而言,沒必要特別去指定/dev/shm的容量(而且,其實他的值+所有tmpfs的值>實際記憶體的話,系統會報錯誤,極有可能開機失敗)



和對照「這篇」的一段話



當中六個 tmpfs 檔案系統並非表示系統分配了 1008 MiB x 6 = 5.90 GiB 的記憶體,實際分配了 124 KiB + 2.8 MiB + 472 KiB + 2 MiB = 5.39 MiB 的虛擬記憶體。 1008 MiB 只是每個 tmpfs 檔案系統可以使用虛擬記憶體的上限罷了。



和對照「這篇」的一段話


Linux

tmpfs is supported by the Linux kernel from version 2.4 and up.[3] tmpfs (previously known as shmfs) is based on the ramfs code used during bootup and also uses the page cache, but unlike ramfs it supports swapping out less-used pages to swap space as well as filesystem size and inode limits to prevent out of memory situations (defaulting to half of physical RAM and half the number of RAM pages, respectively).




----------------------------------------------------------

現在只有一個想法還沒有實驗,把一個大檔,丟到這些「tmpfs」,大小超過記憶體,會發生什麼事了?
先紀錄到此。有空再來測。

----------------------------------------------------------

另外額外一提,上面的回覆,有提到一個「tmp.mount」。


$ sudo systemctl enable tmp.mount




重開機,就會將「tmpfs」掛載到「/tmp」這個路徑。大小預設就是「主記憶體的一半」。

若同時「/etc/fstab」有設定的話,則是以「/etc/fstab」為準。

----------------------------------------------------------

2015/5/24 4:27
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2010/2/9 18:20
所屬群組:
已註冊使用者
等級: 31
HP : 0 / 758
MP : 438 / 29496
EXP: 33
離線
Jessie 應該換到 systemd 上面了吧?
那 /dev/shm 就會變成由systemd自動掛載,似乎就不會受到 fstab 影響了?(待確認)(不過一般真的不需要動它的設定值)

關於/dev/shm的容量問題:之前的說法有破綻,不是加總掛載的容量大小。而是主記憶體 - {各目錄裡,檔案實際消耗的容量的和}
看起來似乎 /dev/shm 的容量政策也跟一般tmpfs一樣,是主記憶體之半(但實際可用的其實是剩下的記憶體位址)

其他使用者自訂的 tmpfs 掛載點我不清楚,不過要是把 /tmp 寫滿的話,系統會很有趣...
把 /dev/shm 寫到快滿時,舊檔案會自動清除,基本上寫不滿,除非用單一大檔

2015/5/24 11:31
在下有時候會回答的很簡略
請善用google搜尋回答中的關鍵字

應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2010/2/9 18:20
所屬群組:
已註冊使用者
等級: 31
HP : 0 / 758
MP : 438 / 29496
EXP: 33
離線
samwhelp 寫到:
另外額外一提,上面的回覆,有提到一個「tmp.mount」。

$ sudo systemctl enable tmp.mount

重開機,就會將「tmpfs」掛載到「/tmp」這個路徑。大小預設就是「主記憶體的一半」。
若同時「/etc/fstab」有設定的話,則是以「/etc/fstab」為準。


不需要手動啟用 tmp.mount 的 systemd 單元,這應該是系統自己會去作的事情(否則使用者開機以後怎麼會有/tmp /dev/shm/等tmpfs可以用呢?)

呃...還有,Debian 那一大串 mount service 還真的頗詭異...我只能想像那是為了相容舊版 sysinit 的東西(畢竟都指向 /dev/null)
大概是給直升的用戶用的吧?我這邊沒那些東西。

然後那該死的pulseaudio...算了...標準的「我就是規矩」的姿態,自己創標準,自己弄砸自己最厲害了

而且,小建議,systemd 勞煩到使用者的通常只有 .service 檔,其他的 target, mount 那些都應該是由 service 啟動時自己去找的東西

2015/5/24 11:39
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線
BrLi 寫到:
samwhelp 寫到:

另外額外一提,上面的回覆,有提到一個「tmp.mount」。


$ sudo systemctl enable tmp.mount




重開機,就會將「tmpfs」掛載到「/tmp」這個路徑。大小預設就是「主記憶體的一半」。

若同時「/etc/fstab」有設定的話,則是以「/etc/fstab」為準。

----------------------------------------------------------


不需要手動啟用 tmp.mount 的 systemd 單元,這應該是系統自己會去作的事情(否則使用者開機以後怎麼會有/tmp /dev/shm/等tmpfs可以用呢?)



我裝完「Debian 8 (Jessie) Gnome 」,預設「tmp.mount」是「disabled」的。

至於「/tmp」並沒有特別掛載「硬碟空間」或是「tmpfs」。

我安裝的時候,是讓安裝程式自己分割硬碟空間。

我的系統是只有掛載「/dev/sda1」到「/」。自然就會有一個資料夾「/tmp」,「/tmp」使用的是「硬碟」的空間「/dev/sda1」。

你可以再去看我上面回覆一開始提到的測試環境。

「/dev/shm/」則是系統自己掛載「tmpfs」上來。我在「/etc/fstab」並沒有特別去設定。

這也是上面我後來有一篇「回覆」,我在找這一段是放在哪裡。


2015/5/24 11:54
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2010/2/9 18:20
所屬群組:
已註冊使用者
等級: 31
HP : 0 / 758
MP : 438 / 29496
EXP: 33
離線
看起來是你自己把測試環境搞爛了wwww

fstab 裡有 /tmp 的設定值的話,tmp.mount 就會被啟動了歐~
我不認為 Debian 安裝會沒有寫 /tmp 的指令進去啦,不過假如真的這樣的話...只能說 Debian 規矩真多...

2015/5/24 11:59
在下有時候會回答的很簡略
請善用google搜尋回答中的關鍵字

應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線
BrLi 寫到:
看起來是你自己把測試環境搞爛了wwww



我裝好就如此了,「/etc/fstab」並沒有去做設定。「tmp.mount」預設就是「disabled」。

等會再來重新安裝一次,再度確認一下。

後記 :
(剛重新安裝,讓安裝程式自己分割硬碟,
「/etc/fstab」並沒有設定掛載「/tmp」,「tmp.mount」預設就是「disabled」)

==============================================


BrLi 寫到:

fstab 裡有 /tmp 的設定值的話,tmp.mount 就會被啟動了歐~



這個我要再測試確認,

我的認知,「fstab」裡面的設定,跟「tmp.mount」是沒有連動的。

這可能要去看程式碼的實作才比較清楚。

我只就目前,我測試的結果,來做下面的推論,
他們兩個的機制是分隔的,並不會因為「fstab 裡有 /tmp 的設定值的話,tmp.mount 就會被啟動了」。
但「tmp.mount」若啟動的話,會先檢查「/etc/fstab」有沒有設定,
「/etc/fstab」有設定,就還是依照「/etc/fstab」的設定。

後記 :
(用剛剛重新安裝的系統來測試,
「/etc/fstab」加入「tmpfs /tmp tmpfs defaults 0 0」,重新開機,
並不會讓「tmp.mount」變成「enabled」,
但會掛載「/tmp」)

執行


$ systemctl list-unit-files tmp.mount



顯示


UNIT FILE STATE
tmp.mount disabled
1 unit files listed.



比較特別是,上面是「tmp.mount disabled」

但是執行下面的指令,顯示「active (mounted) 」,不過它有一個「loaded (/etc/fstab; disabled)」。


$ systemctl status tmp.mount



顯示



● tmp.mount - /tmp
Loaded: loaded (/etc/fstab; disabled)
Active: active (mounted) since Sat 2015-05-23 23:09:45 PDT; 5min ago
Where: /tmp
What: tmpfs
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Process: 224 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs (code=exited, status=0/SUCCESS)



更多參考

* man systemd-fstab-generator
* man systemd.mount

----------------------------------------------------

於是把剛剛的「/etc/fstab」加上的那一行拿掉,重開機。

執行


$ systemctl list-unit-files tmp.mount



顯示


UNIT FILE STATE
tmp.mount disabled
1 unit files listed.



執行


$ systemctl status tmp.mount



顯示



● tmp.mount - Temporary Directory
Loaded: loaded (/lib/systemd/system/tmp.mount; disabled)
Active: inactive (dead)
Where: /tmp
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems



更多參考

$ man hier
* http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems

----------------------------------------------------

再來測試「tmp.mount」給「enable」

執行


$ systemctl enable tmp.mount



顯示


Created symlink from /etc/systemd/system/local-fs.target.wants/tmp.mount to /lib/systemd/system/tmp.mount.



重新開機

執行


$ systemctl list-unit-files tmp.mount



顯示


UNIT FILE STATE
tmp.mount enabled
1 unit files listed.



執行


$ systemctl status tmp.mount



顯示


● tmp.mount - Temporary Directory
Loaded: loaded (/lib/systemd/system/tmp.mount; enabled)
Active: active (mounted) since Sat 2015-05-23 23:41:27 PDT; 3min 40s ago
Where: /tmp
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 132 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs -o mode=1777,strictatime (code=exited, status=0/SUCCESS)



----------------------------------------------------

再把剛剛那一行「tmpfs /tmp tmpfs defaults 0 0」加回「/etc/fstab」

重新開機

執行


$ systemctl list-unit-files tmp.mount



顯示


UNIT FILE STATE
tmp.mount enabled
1 unit files listed.



執行


$ systemctl status tmp.mount



顯示


● tmp.mount - /tmp
Loaded: loaded (/etc/fstab; enabled)
Active: active (mounted) since Sat 2015-05-23 23:50:39 PDT; 3min 29s ago
Where: /tmp
What: tmpfs
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Process: 225 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs (code=exited, status=0/SUCCESS)



跟我一開始的推論有些一致,在「tmp.mount」設為「enable」,且「/etc/fstab」有設掛載「tmpfs」到「/tmp」的時候。
會以「/etc/fstab」為準。

==============================================

至於

BrLi 寫到:
我不認為 Debian 安裝會沒有寫 /tmp 的指令進去啦,





另外我昨天有看到「一篇」,「debian」後來的版本,「/tmp」預設就不使用「tmpfs」。
他說的應該是「tmpfs」提到的。



RAMTMP Mount /tmp as a tmpfs. Defaults to no; set to yes to enable
(/tmp will be part of the root filesystem if disabled). /tmp
may also be configured to be a separate mount in /etc/fstab,
which will override the RAMTMP setting.



但不過這裡提到的是「/etc/defaut/tmpfs」的設定。「debian 8」看來沒有使用了。
不過我想這應該是debian的統一政策。所以其他的機制應該也會一致。
只是不知道從debian哪個版本開始,「/tmp」預設就不掛載「tmpfs」了。
這個就依照各個版本的實際狀況了。
這個網頁「tmpfs」可以設定不同版本的manual。

==============================================

關於


不過假如真的這樣的話...只能說 Debian 規矩真多...



所以還是要多了解Debian的系統,才會知道它的行為模式。
才不會遇到一些莫名的Why not work!

還有請依照每個版本為基準,有時候還要加上實際的環境,因為有些因素不同的話,有可能會導致行為不同。

==============================================


2015/5/24 12:32
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29281
EXP: 6
離線
剛從「這篇

看到一句「 該服務會被導向到 /dev/null」。

再回去翻「systemctl」。

看到


mask NAME...
Mask one or more unit files, as specified on the command line. This
will link these units to /dev/null, making it impossible to start
them. This is a stronger version of disable, since it prohibits all
kinds of activation of the unit, including manual activation. Use
this option with care. This honors the --runtime option to only
mask temporarily until the next reboot of the system.

unmask NAME...
Unmask one or more unit files, as specified on the command line.
This will undo the effect of mask.



看來要再來研究一下「mask」和「unmask」的用法了

暫時紀錄到此



https://wiki.debian.org/systemd

2015/5/24 21:43
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員二級
註冊日期:
2009/6/22 14:07
所屬群組:
已註冊使用者
等級: 8
HP : 0 / 179
MP : 28 / 7316
EXP: 18
離線
這一篇落落長是怎麼回事...

直接在 /etc/fstab 裡新增底下一行
tmpfs /tmp tmpfs nodev,nosuid,size=2560m,mode=1777 0 0

然後執行以下指令就能把 /tmp 當作 RamDisk 來用了啊
sudo mount -a

2015/5/25 0:03
應用擴展 工具箱

« 1 (2) 3 4 »

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


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