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


正在瀏覽:   1 名遊客


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

« 1 2 3 (4)


回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員一級
註冊日期:
2015/5/25 21:32
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 0
MP : 0 / 0
EXP: 0
離線

2015/5/25 21:35
應用擴展 工具箱
systemd.mount的用法
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29331
EXP: 6
離線
昨天晚上再翻了一下「systemd.mount

其中一段



DESCRIPTION
A unit configuration file whose name ends in ".mount" encodes
information about a file system mount point controlled and supervised
by systemd.



萌生了一些測試的想法。

以下是測試紀錄,測試環境是「Debian 8 (Jessie) Gnome 32位元」

延續「這篇」的測試,

我在「/etc/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



觀察開機後的掛載情形

執行下面指令 (你也可以使用「mount -l」來觀察掛載情形)


$ 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 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000



「tmp.mount」也被我「disable」了

所以並沒有掛載「/tmp」

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

切換到「/etc/systemd/system/」這個資料夾


$ cd /etc/systemd/system/



將「/lib/systemd/system/tmp.mount」複製到「/etc/systemd/system/tmp.mount」


$ sudo cp /lib/systemd/system/tmp.mount ./



修改「/etc/systemd/system/tmp.mount」


$ sudo vi +21 tmp.mount



原來的內容


# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime

[Install]
WantedBy=local-fs.target




將其中一行


Options=mode=1777,strictatime



改成


Options=size=2G,mode=1777,strictatime



觀看「tmp.mount」的狀態


$ systemctl list-unit-files tmp.mount




顯示


UNIT FILE STATE
tmp.mount disabled

1 unit files listed.




啟用「tmp.mount」


$ sudo systemctl enable tmp.mount



顯示


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



觀看「tmp.mount」的狀態


$ systemctl status tmp.mount



顯示


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



啟動「tmp.mount」


$ sudo systemctl start tmp.mount




觀看「tmp.mount」的狀態


$ sudo systemctl status tmp.mount



顯示


● tmp.mount - Temporary Directory
   Loaded: loaded (/etc/systemd/system/tmp.mount; enabled)
   Active: active (mounted) since 二 2015-05-26 17:12:59 CST; 46s ago
    Where: /tmp
     What: tmpfs
     Docs: man:hier(7)
           http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
  Process: 1732 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs -o size=2G,mode=1777,strictatime (code=exited, status=0/SUCCESS)

 5月 26 17:12:58 debian systemd[1]: tmp.mount: Directory /tmp to mount over is not empty, mounting anyway.





觀察系統掛載狀態


$ 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           101M  8.0K  101M    1% /run/user/120
tmpfs           101M  8.0K  101M    1% /run/user/1000
tmpfs           2.0G     0  2.0G    0% /tmp





你會發現「/tmp」已經被掛載「tmpfs」,並且設定大小為「2G」。

然後重新開機。

再執行


$ 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           2.0G  4.0K  2.0G    1% /tmp
tmpfs           101M  8.0K  101M    1% /run/user/120
tmpfs           101M  8.0K  101M    1% /run/user/1000





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


複製「/etc/systemd/system/tmp.mount」到「/etc/systemd/system/this-is-test.mount」



$ sudo cp tmp.mount this-is-test.mount




修改「/etc/systemd/system/this-is-test.mount」


$ sudo vi this-is-test.mount



最終改成


# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/this/is/test
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target

[Mount]
What=tmpfs
Where=/this/is/test
Type=tmpfs
Options=size=3G,mode=1777,strictatime

[Install]
WantedBy=local-fs.target




觀看「this-is-test.mount」啟用狀況


$ systemctl list-unit-files this-is-test.mount



顯示「disabled」


UNIT FILE STATE
this-is-test.mount disabled

1 unit files listed.




觀看「this-is-test.mount」目前狀態


$ systemctl status this-is-test.mount



顯示


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



啟用「this-is-test.mount」


$ sudo systemctl enable this-is-test.mount




顯示


Created symlink from /etc/systemd/system/local-fs.target.wants/this-is-test.mount to /etc/systemd/system/this-is-test.mount.




觀看「this-is-test.mount」啟用狀況


$ systemctl list-unit-files this-is-test.mount



顯示「enabled」



systemctl list-unit-files this-is-test.mount
UNIT FILE STATE
this-is-test.mount enabled

1 unit files listed.



觀看「this-is-test.mount」目前狀態


$ systemctl status this-is-test.mount



顯示


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




啟動「this-is-test.mount」


$ sudo systemctl start this-is-test.mount



觀看「this-is-test.mount」目前狀態


$ systemctl status this-is-test.mount



顯示



● this-is-test.mount - Temporary Directory
Loaded: loaded (/etc/systemd/system/this-is-test.mount; enabled)
Active: active (mounted) since 二 2015-05-26 18:00:00 CST; 49s ago
Where: /this/is/test
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 1579 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)



觀看目前掛載狀況


$ df -h



顯示



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



可以看到最後一行「/this/is/test」已經掛載「tmpfs」了


重新啟動「this-is-test.mount」


$ sudo systemctl restart this-is-test.mount



觀看「this-is-test.mount」目前狀態


$ systemctl status this-is-test.mount



顯示


● this-is-test.mount - Temporary Directory
Loaded: loaded (/etc/systemd/system/this-is-test.mount; enabled)
Active: active (mounted) since 二 2015-05-26 18:03:32 CST; 37s ago
Where: /this/is/test
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 1624 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)




可以看到上面的


Process: 1579 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)



已經變成兩行


Process: 1624 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)



也就是會重新掛載。


再執行一次「start」。


$ sudo systemctl start this-is-test.mount




顯示


sam@debian:/etc/systemd/system$ systemctl status this-is-test.mount
● this-is-test.mount - Temporary Directory
Loaded: loaded (/etc/systemd/system/this-is-test.mount; enabled)
Active: active (mounted) since 二 2015-05-26 18:03:32 CST; 2min 12s ago
Where: /this/is/test
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 1624 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)



最兩行的「Process」是沒有變動的,也就是已經掛載了,再執行「start」,就不會再做任何動作了。


關閉「this-is-test.mount」


$ sudo systemctl stop this-is-test.mount



觀看「this-is-test.mount」目前狀態


$ systemctl status this-is-test.mount



顯示




● this-is-test.mount - Temporary Directory
Loaded: loaded (/etc/systemd/system/this-is-test.mount; enabled)
Active: inactive (dead) since 二 2015-05-26 18:08:14 CST; 5s ago
Where: /this/is/test
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 1646 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)






Process: 1624 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)



變成


Process: 1646 ExecUnmount=/bin/umount -n /this/is/test (code=exited, status=0/SUCCESS)
Process: 1625 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)




觀看目前掛載狀況。


$ df -h



顯示


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



「/this/is/test」已經卸載了。

然後重新開機。

觀看目前掛載狀況


$ 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 3.0G 0 3.0G 0% /this/is/test
tmpfs 2.0G 4.0K 2.0G 1% /tmp
tmpfs 101M 8.0K 101M 1% /run/user/120
tmpfs 101M 8.0K 101M 1% /run/user/1000



「/this/is/test」開機有自動掛載「tmpfs」


觀看「this-is-test.mount」。


$ systemctl status this-is-test.mount



顯示



● this-is-test.mount - Temporary Directory
Loaded: loaded (/etc/systemd/system/this-is-test.mount; enabled)
Active: active (mounted) since 二 2015-05-26 19:34:50 CST; 2min 39s ago
Where: /this/is/test
What: tmpfs
Docs: man:hier(7)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 133 ExecMount=/bin/mount -n tmpfs /this/is/test -t tmpfs -o size=3G,mode=1777,strictatime (code=exited, status=0/SUCCESS)




## 小結

* 若要利用「systemd.mount」的機制,可以參考我上面的作法,將「/lib/systemd/system/tmp.mount」複製到「/etc/systemd/system/」這個資料夾,再做修改。

* 要注意的是檔名的格式,副檔名要是「.mount」。然後你要掛載的路徑「/this/is/test」要對應到「this-is-test」,所以就是「this-is-test.mount」。

* 本來是要測試「dev-shm.mount」來掛載「/dev/shm」的,更改它的size的,不過系統預設就有掛載「/dev/shm」了,所以這部份就行不通。
但編寫「/etc/fstab」的方式來改變「/dev/shm」掛載size的方式,還是行得通,請參考之前的「回覆


## 附註

上面是我初步測試的結果,來做的推論,也許沒有看到全貌,有些概念也許還要補足,還在探索熟悉systemd中。


## 更多參考

$ man systemd.mount
$ man systemd-fstab-generator
$ man systemd.unit
$ Arch Wiki / Systemd / Using units
$ API File Systems


## 後記 2019-10-22

在「Ubuntu 18.04」的操作步驟,後來紀錄在下面這個回覆。

* #20 回覆: [Solved] ubuntu 近半年來隨機的開機凍結的元兇?

2015/5/26 20:28
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員一級
註冊日期:
2015/6/11 10:04
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 63
EXP: 10
離線
我將系統從wheezy升級到jessie後遇到底下的錯誤訊息

[ TIME ] Timed out waiting for device dev-sda3.device.
[DEPEND] Dependency failed for /mnt.
[DEPEND] Dependency failed for File System Check on /dev/sda3.
[ TIME ] Timed out waiting for device dev-sda2.device.
[DEPEND] Dependency failed for /dev/sda2.
[DEPEND] Dependency failed for Swap.
[ TIME ] Timed out waiting for device dev-ttyS1.device.
[DEPEND] Dependency failed for Serial Getty on ttyS1.

嘗試用systemd-fstab-generator把fstab轉到systemd格式
然後把/etc/fstab裏面的sda2與sda3註解掉,問題依舊存在

但開進系統後,我仍然可以手動mount sda2與sda3,看起來是自動mount功能失效了。

Kernel版本3.16.7 (從debian package解壓縮出來的source code自己編譯)
設定部份參考/usr/share/doc/systemd/README.gz,把建議的項目都打開了
> Maintain devtmpfs to mount at /dev
> Automount devtmpfs at /dev, after the kernel mounted the rootfs
> open by fhandle syscalls
> Control Group support
> Kernel automounter version 4 support (also supports v3)
> FUSE (Filesystem in Userspace) support

# systemctl list-unit-files swap.target
UNIT FILE STATE
swap.target enabled

# systemctl list-unit-files mnt.mount
UNIT FILE STATE
mnt.mount enabled

# systemctl list-units -t target --all | grep swap
swap.target loaded inactive dead Swap

# systemctl status mnt.mount
● mnt.mount - /mnt
Loaded: loaded (/etc/fstab; enabled)
Active: inactive (dead)
Where: /mnt
What: /dev/sda3
Docs: man:fstab(5)
man:systemd-fstab-generator(8)

6月 11 10:19:00 XX systemd[1]: Dependency failed for /mnt.
6月 11 10:38:37 XX systemd[1]: Dependency failed for /mnt.

有google到systemd在處理mount的time-out時間設定太短,以至於fsck做不完
但我進系統後執行fsck,不用三秒就完成了
# fsck.ext3 /dev/sda3

沒頭緒了,我能再往哪個方向查?

mnt.mount內容如下

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
RequiresOverridable=systemd-fsck@dev-sda3.service
After=systemd-fsck@dev-sda3.service

[Mount]
What=/dev/sda3
Where=/mnt
Type=ext3
Options=noauto,x-systemd.automount,defaults,noatime

[Install]
WantedBy=local-fs.target


swap.target內容如下

# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Swap
Documentation=man:systemd.special(7)

[Install]
WantedBy=local-fs.target


下一步是朝向[Unit]的After,找dev-sda3.service...只是目前找不到相關的資料


參考資料:
https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/fstab
https://fedoraproject.org/wiki/How_to_debug_Systemd_problems

2015/6/11 11:07
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29331
EXP: 6
離線
因為只是直接安裝Debian Jessie,不是升級的方式,所以我也沒遇過你說的問題。歹勢拉。

另外我上面只是在研究「systemd」的功能。
我個人目前認為,用原來的「/etc/fstab」的設定方式掛載就行了,
不用特別去改成「systemd」的設定方式來掛載。

但不確定,你原來「/etc/fstab」就會出錯,還是設定成「systemd」的方式,才導致出錯的。

Ralse 寫到:
我將系統從wheezy升級到jessie後遇到底下的錯誤訊息

[ TIME ] Timed out waiting for device dev-sda3.device.
[DEPEND] Dependency failed for /mnt.
[DEPEND] Dependency failed for File System Check on /dev/sda3.
[ TIME ] Timed out waiting for device dev-sda2.device.
[DEPEND] Dependency failed for /dev/sda2.
[DEPEND] Dependency failed for Swap.
[ TIME ] Timed out waiting for device dev-ttyS1.device.
[DEPEND] Dependency failed for Serial Getty on ttyS1.

嘗試用systemd-fstab-generator把fstab轉到systemd格式
然後把/etc/fstab裏面的sda2與sda3註解掉,問題依舊存在

但開進系統後,我仍然可以手動mount sda2與sda3,看起來是自動mount功能失效了。

Kernel版本3.16.7 (從debian package解壓縮出來的source code自己編譯)
設定部份參考/usr/share/doc/systemd/README.gz,把建議的項目都打開了
> Maintain devtmpfs to mount at /dev
> Automount devtmpfs at /dev, after the kernel mounted the rootfs
> open by fhandle syscalls
> Control Group support
> Kernel automounter version 4 support (also supports v3)
> FUSE (Filesystem in Userspace) support

# systemctl list-unit-files swap.target
UNIT FILE STATE
swap.target enabled

# systemctl list-unit-files mnt.mount
UNIT FILE STATE
mnt.mount enabled

# systemctl list-units -t target --all | grep swap
swap.target loaded inactive dead Swap

# systemctl status mnt.mount
● mnt.mount - /mnt
Loaded: loaded (/etc/fstab; enabled)
Active: inactive (dead)
Where: /mnt
What: /dev/sda3
Docs: man:fstab(5)
man:systemd-fstab-generator(8)

6月 11 10:19:00 XX systemd[1]: Dependency failed for /mnt.
6月 11 10:38:37 XX systemd[1]: Dependency failed for /mnt.

有google到systemd在處理mount的time-out時間設定太短,以至於fsck做不完
但我進系統後執行fsck,不用三秒就完成了
# fsck.ext3 /dev/sda3

沒頭緒了,我能再往哪個方向查?

mnt.mount內容如下

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
RequiresOverridable=systemd-fsck@dev-sda3.service
After=systemd-fsck@dev-sda3.service

[Mount]
What=/dev/sda3
Where=/mnt
Type=ext3
Options=noauto,x-systemd.automount,defaults,noatime

[Install]
WantedBy=local-fs.target


swap.target內容如下

# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Swap
Documentation=man:systemd.special(7)

[Install]
WantedBy=local-fs.target


下一步是朝向[Unit]的After,找dev-sda3.service...只是目前找不到相關的資料


參考資料:
https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/fstab
https://fedoraproject.org/wiki/How_to_debug_Systemd_problems

2015/6/11 13:28
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員一級
註冊日期:
2015/6/11 10:04
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 63
EXP: 10
離線
原本在wheezy的fstab沒有問題,升級後原本的fstab發生dependency錯誤才想把他轉去systemd,後來發現轉過去一樣有問題,最終問題依舊沒解決。


# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext3 defaults,noatime,nodiratime 0 1
proc /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=20 0 0

#/dev/sda2 none swap auto,defaults 0 0
#PARTUUID=170bef8a-02 none swap defaults 0 0

#/dev/sda3 /mnt ext3 x-systemd.automount,defaults,noatime 0 0
#PARTUUID=170bef8a-03 /mnt ext3 defaults,noatime 0 2


嘗試把file system改用UUID=""跟PARTUUID=""方式去掛載,reboot一樣發生dependency錯誤。

剛剛把mnt.mount裡面的fsck拿掉,發現reboot時仍然會去做/dev/sda3的fsck...我想systemd裏面有其他部份會去做整個device的檢查,只能先朝這方向去看看有沒有問題了。

2015/6/11 13:51
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員一級
註冊日期:
2015/6/11 10:04
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 63
EXP: 10
離線
最後發現問題在系統沒有/dev/disk/資料夾。
這些資料夾應該是由udev去產生,但我重開機後系統不會建立這些資料夾,要自己手動執行udevadm trigger才會產生。

系統是從Debian wheezy -> jessie,裝在NAS上(CPU: powerpc),用u-boot載入uImage開機
沒有initramfs

也確認/etc/udev/rules.d/60-persistent-storage.rules是正確的。

目前就這個人的問題看起來跟我比較像
http://askubuntu.com/questions/445735/why-do-my-udev-rules-run-if-i-use-udevadm-trigger-but-not-at-boot-time

關於這問題有正確的解決方法嗎?

2015/6/15 18:01
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
版主
註冊日期:
2008/7/14 0:03
來自 螢幕的另一端
所屬群組:
網站管理員
已註冊使用者
討論區管理群
等級: 33
HP : 0 / 808
MP : 511 / 35215
EXP: 34
離線
我有同樣的問題,在debian jessie之前的版本只要做這兩個動作
vim /etc/default/tmpfs

#RAMTMP=no
改成
RAMTMP=yes
然後,存檔離開,重開機之後 tmpfs 就會自動掛載到 /tmp 底下了,預設使用 ram 一半大小

但是到 debian jessie 這一版本之後,上面的做法就不管用了,不知為什麼?

不然的話,以前那樣的做法,的確是挺方便的。

其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,因為 debian 本身就有設計這個功能,無奈是它好象有點bug,前面人的回應都歪樓了...從這點上看起來象是你們在欺負樓主,歪樓歪的很嚴重,他問的是正確的。

不過,前面有人提到一個重點了,樓主若想要用ramdisk的話,應該使用的是 /tmp 而不是使用 /dev/shm 這才是正確的用法。


補充說明:
後來我查到相關資料,這裡也有提到相關問題
https://lists.debian.org/debian-user/2014/07/msg01306.html
這裡有人回應解法
https://lists.debian.org/debian-user/2014/07/msg01314.html
解法就是底下這行指令
systemctl enable tmp.mount

2016/11/8 23:12
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2010/9/16 14:08
所屬群組:
已註冊使用者
等級: 25
HP : 0 / 619
MP : 274 / 23032
EXP: 76
離線
太棒了~先引言記錄下來。
---
原來非常接近我的需求的解決方案,在我提問的前一年就已經出現了。
然而我提問且經歷了文字霸凌的一年多之後,才遇到熱心網友提供該解決方案的討論串link。真的是可遇不可求。
或許真的要習慣網路文化吧?
提一個問題,有設定一些解法需求,然後開始被某些技客網路文字霸凌,又過了一段時間,看似要被遺忘了的主題,遇到熱心的網友,提供了link,原來非常接近我需求的解決方案早就存在。(當然我就是搜尋能力不足,找不到該link,才提問的。)
這樣的情境我已經遇過不只一次了。
總之就是提問的內容在方向上沒有問題,理論上有非常接近甚至符合需求的解法,但是就得先經歷一段網路文字霸凌,然後又要再隔一段時間,才會突然出現符合或著非常接近我描述所需求的且早就存在的解決方案。


夢見草 寫到:
我有同樣的問題,在debian jessie之前的版本只要做這兩個動作
vim /etc/default/tmpfs

#RAMTMP=no
改成
RAMTMP=yes
然後,存檔離開,重開機之後 tmpfs 就會自動掛載到 /tmp 底下了,預設使用 ram 一半大小

但是到 debian jessie 這一版本之後,上面的做法就不管用了,不知為什麼?

不然的話,以前那樣的做法,的確是挺方便的。

其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,因為 debian 本身就有設計這個功能,無奈是它好象有點bug,前面人的回應都歪樓了...從這點上看起來象是你們在欺負樓主,歪樓歪的很嚴重,他問的是正確的。

不過,前面有人提到一個重點了,樓主若想要用ramdisk的話,應該使用的是 /tmp 而不是使用 /dev/shm 這才是正確的用法。


補充說明:
後來我查到相關資料,這裡也有提到相關問題
https://lists.debian.org/debian-user/2014/07/msg01306.html
這裡有人回應解法
https://lists.debian.org/debian-user/2014/07/msg01314.html
解法就是底下這行指令
systemctl enable tmp.mount

2016/11/8 23:43
----------------
個人網路文字作品集:
MacOSX10.5.8 安裝、設定、使用,個人經驗分享,正體中文版;以Windows思維用Linux,GNOME桌面篇;PDF
http://www.scribd.com/ianian1979
全字庫注音輸入法表格檔2019 (搭配CNS11643中文全字庫規格的Unicode格式傳統注音輸入法對照表)
https://sites.google.com/site/ianho7979/InputMethodTables
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29331
EXP: 6
離線
夢見草 寫到:
我有同樣的問題,在debian jessie之前的版本只要做這兩個動作
vim /etc/default/tmpfs

#RAMTMP=no
改成
RAMTMP=yes
然後,存檔離開,重開機之後 tmpfs 就會自動掛載到 /tmp 底下了,預設使用 ram 一半大小

但是到 debian jessie 這一版本之後,上面的做法就不管用了,不知為什麼?

不然的話,以前那樣的做法,的確是挺方便的。

其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,因為 debian 本身就有設計這個功能,無奈是它好象有點bug,前面人的回應都歪樓了...從這點上看起來象是你們在欺負樓主,歪樓歪的很嚴重,他問的是正確的。

不過,前面有人提到一個重點了,樓主若想要用ramdisk的話,應該使用的是 /tmp 而不是使用 /dev/shm 這才是正確的用法。


補充說明:
後來我查到相關資料,這裡也有提到相關問題
https://lists.debian.org/debian-user/2014/07/msg01306.html
這裡有人回應解法
https://lists.debian.org/debian-user/2014/07/msg01314.html
解法就是底下這行指令
systemctl enable tmp.mount




關於

夢見草 寫到:
補充說明:
後來我查到相關資料,這裡也有提到相關問題
https://lists.debian.org/debian-user/2014/07/msg01306.html
這裡有人回應解法
https://lists.debian.org/debian-user/2014/07/msg01314.html
解法就是底下這行指令
systemctl enable tmp.mount



關於「systemctl enable tmp.mount」這個指令我之前的幾個回覆「#32」,「#18」,「#9」應該有提到。

而且樓主其中的一個需求是要改掛載大小,請看「#1」和「#4

後來有一篇我的回覆「#32

就有紀錄我當時摸索出來的一個方式,如何透過「systemd.mount」的方式,來更改掛載大小。

不過這個方法,並不符合樓主設定的另一個條件「"不需要"額外於終端機內下指令的"前提"下」,請參考「#4

以下摘錄「#4

IanHo 寫到:
我期望/需求的操作設定情境是,在"不需要"額外於終端機內下指令的"前提"下,
不需造再新增更多字串的"前提"下(但是可以改字串/新增數值/改數值)
“有沒有”哪個"現成的"某個路徑下的"參數設定檔案"內的某個字串,可以讓我修改/新增數值?
然後重開機之後,裝置 tmpfs 目錄 /dev/shm "總數"的空間,
就可以是我填入的數值(或著很接近的數值)???




#32」提到的方法,除了需要「下指令」,還有需要複製檔案,修改檔案設定。

於是這又違反了樓主,另一個設定的條件,請參考「#22


以下摘錄「#22


IanHo 寫到:
因為我提問"所需求"的是:
"不"於終端機內下指令,"不"寫新script,
"只"於"現成既有"的參數設定檔案內,"修改""字串值",新增或修改既有的"數值",
這樣的提問條件。
補充,"新增"字串值可以接受
但是"必須是"一行一個的那種,類似於Windows *.ini那種概念的
幾乎不用讀文件就可一目了然修改的新增修改字串值。
而"不是" 那種需要先讀文件判斷每個逗點之間要填寫什麼規範內容的那種字串值。


tmpfs /tmp tmpfs nodev,nosuid,size=2560m,mode=1777 0 0

這種的"太複雜"了。



所以不太懂下面這一段說的,到底是哪裡歪樓了?

夢見草 寫到:
其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,
因為 debian 本身就有設計這個功能,無奈是它好象有點bug,
前面人的回應都歪樓了...
從這點上看起來象是你們在欺負樓主,歪樓歪的很嚴重,他問的是正確的。



還有到底是『「誰」在「欺負」「誰」?

更有趣的是,請對照「#38」提到的

我自己的心得是,
----------------------------------------
我告誡自己

請別「作繭自縛」的「為難自己」,Orz...

請別「得了便宜還賣乖」的「為難別人」,Orz...
----------------------------------------

我之前的回覆寫的很亂,只是因為我當時看到樓主的提問,當下我其實一點概念都沒有,
我也是從樓主提到的關鍵字,然後慢慢找相關的文章和線索,
灌好Debian Jessie在Virtual Box上,然後探索系統,一個指令一個指令下,一個檔案一個檔案翻,慢慢的找答案,
有新的發現,就紀錄上來,所以才呈現非常亂的狀態,後來我也沒力氣再去整理了。
基本上我探索過程中,相關的參考指令和步驟都寫在上面了,
我個人相信只要有跟著步驟下指令,就會有收穫。
雖然照著指令下,不見得讓您能完全了解到我看到的,讓您能完全了解我要表達的,
但我認為或多或少,您都會有收穫。
當然這是我自己的假設,您若真的沒收獲的話,您就擱著忽略不看吧,
就請您再去找其他網路上的參考文章了,
真的抱歉,沒能幫上忙,還耽誤您爬文的時間。

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

夢見草 寫到:
我有同樣的問題,在debian jessie之前的版本只要做這兩個動作
vim /etc/default/tmpfs

#RAMTMP=no
改成
RAMTMP=yes
然後,存檔離開,重開機之後 tmpfs 就會自動掛載到 /tmp 底下了,預設使用 ram 一半大小

但是到 debian jessie 這一版本之後,上面的做法就不管用了,不知為什麼?

不然的話,以前那樣的做法,的確是挺方便的。

其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,因為 debian 本身就有設計這個功能,無奈是它好象有點bug


您提的這個方法,我在「#3

有紀錄之前找到的一篇「參考文章」,裡面就有提到這個方法。

至於後來版本,為啥沒作用,

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

也就是關於

夢見草 寫到:
其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,
因為 debian 本身就有設計這個功能,無奈是它好象有點bug,



我之前在「#18
有貼一篇我當時找到的「參考文章」。
這篇參考文章,裡面有另一個「參考文章」,
請參考這兩篇的說明,還有我之前的回覆「#6」,「#9」,「#16」,「#18」,「#32」。


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

另外我個人也偏向使用「#20」「ChoCo」提到的方法,直接編輯「/etc/fstab」,

這個方法我在一開始的回覆就有提了,請參考「#2」,「#3」,

這是我一開始在「nana」的另一篇「回覆」看到的方法。

可以執行「$ man mount」和「$ man fstab」找尋「tmpfs」來閱讀。

再次釐清




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

## Manpage

$ man mount
$ man fstab
$ man systemd.mount
$ man systemd.unit
$ man file-hierarchy
$ man hier


## File

執行


$ dpkg -L systemd | grep tmp.mount



顯示


/usr/share/systemd/tmp.mount



## Source Code (參考 #12)

* systemd/src/core/mount-setup.c
* systemd/src/remount-fs/remount-fs.c


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




以下原文參考



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

#1

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,
我會利用這個空間來 擺放/指向 例如 gimp的"置換檔",網路瀏覽器的cache路徑等等。
/dev/shm下的資料,我是"不需要"另存檔案的,關機後消失沒有差。
於是我開始查閱 /etc/default/tmpfs 檔案的內容該怎麼設定???
有嘗試man tmpfs了,個人英文文件能消化的有限,
我把 SHM_SIZE= 這行開頭的井字註解拿掉,並且填入數值 2500000000
存檔重開機後,發現"沒有"效果,
裝置 tmpfs 目錄 /dev/shm 總數仍然還是 2.1GB 。
我該怎麼去修改tmpfs的參數設定值???
我原本的這套做法,在debian wheezy+ gnome是有效的,
為什麼在Debian Jessie + gnome就無效了???
我該修改些什麼才能再生效???



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

#4

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)
我會利用這個空間來 擺放/指向 例如gimp的"置換檔",網路瀏覽器的cache路徑等等。
/dev/shm下的資料,我是"不需要"另存檔案的,關機後消失沒有差。
我期望/需求的操作設定情境是,在"不需要"額外於終端機內下指令的"前提"下,
不需造再新增更多字串的"前提"下(但是可以改字串/新增數值/改數值)
“有沒有”哪個"現成的"某個路徑下的"參數設定檔案"內的某個字串,可以讓我修改/新增數值?
然後重開機之後,裝置 tmpfs 目錄 /dev/shm "總數"的空間,
就可以是我填入的數值(或著很接近的數值)???
我有查閱 /etc/default/tmpfs 檔案的內容。
有嘗試man tmpfs了,個人英文文件能消化的有限,
我把 SHM_SIZE= 這行開頭的井字註解拿掉,並且填入數值 2500000000
存檔重開機後,發現"沒有"效果,
裝置 tmpfs 目錄 /dev/shm 總數仍然還是 2.1GB(主記憶體的一半)。



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

#22

IanHo 寫到:
ChoCo 寫到:
這一篇落落長是怎麼回事...

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

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


因為我提問"所需求"的是:
"不"於終端機內下指令,"不"寫新script,
"只"於"現成既有"的參數設定檔案內,"修改""字串值",新增或修改既有的"數值",
這樣的提問條件。
補充,"新增"字串值可以接受,
但是"必須是"一行一個的那種,類似於Windows *.ini那種概念的
幾乎不用讀文件就可一目了然修改的新增修改字串值。
而"不是" 那種需要先讀文件判斷每個逗點之間要填寫什麼規範內容的那種字串值。

tmpfs /tmp tmpfs nodev,nosuid,size=2560m,mode=1777 0 0

這種的"太複雜"了。


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

#38

IanHo 寫到:

太棒了~先引言記錄下來。
---

原來非常接近我的需求的解決方案,在我提問的前一年就已經出現了。
然而我提問且經歷了文字霸凌的一年多之後,才遇到熱心網友提供該解決方案的討論串link。真的是可遇不可求。
或許真的要習慣網路文化吧?
提一個問題,有設定一些解法需求,然後開始被某些技客網路文字霸凌,又過了一段時間,看似要被遺忘了的主題,遇到熱心的網友,提供了link,原來非常接近我需求的解決方案早就存在。(當然我就是搜尋能力不足,找不到該link,才提問的。)
這樣的情境我已經遇過不只一次了。
總之就是提問的內容在方向上沒有問題,理論上有非常接近甚至符合需求的解法,但是就得先經歷一段網路文字霸凌,然後又要再隔一段時間,才會突然出現符合或著非常接近我描述所需求的且早就存在的解決方案。


夢見草 寫到:
我有同樣的問題,在debian jessie之前的版本只要做這兩個動作
vim /etc/default/tmpfs

#RAMTMP=no
改成
RAMTMP=yes
然後,存檔離開,重開機之後 tmpfs 就會自動掛載到 /tmp 底下了,預設使用 ram 一半大小

但是到 debian jessie 這一版本之後,上面的做法就不管用了,不知為什麼?

不然的話,以前那樣的做法,的確是挺方便的。

其實樓主想要使用 /etc/default/tmpfs 這裡面的設定想法是正確的,因為 debian 本身就有設計這個功能,無奈是它好象有點bug,前面人的回應都歪樓了...從這點上看起來象是你們在欺負樓主,歪樓歪的很嚴重,他問的是正確的。

不過,前面有人提到一個重點了,樓主若想要用ramdisk的話,應該使用的是 /tmp 而不是使用 /dev/shm 這才是正確的用法。


補充說明:
後來我查到相關資料,這裡也有提到相關問題
https://lists.debian.org/debian-user/2014/07/msg01306.html
這裡有人回應解法
https://lists.debian.org/debian-user/2014/07/msg01314.html
解法就是底下這行指令
systemctl enable tmp.mount



後記 (2017-06-12) :

* #4 回覆: MacBook Pro2006 + Debian Stretch 遇到的圖形驅動程式問題

聯想到一個預言故事「上帝為甚麽不救我?」。

Orz...

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

2016/11/9 4:09
應用擴展 工具箱
回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況
管理員
註冊日期:
2011/3/11 6:32
所屬群組:
討論區管理群
等級: 44
HP : 216 / 1084
MP : 1088 / 38822
EXP: 38
離線
(這則回覆代表版主們已經開始關注這則討論串)

附件:



jpeg  images.duckduckgo.com.jpeg (9.76 KB)
24266_5822ac703ed94.jpeg 250X164 px

2016/11/9 12:56
本篇發表文章以「創用CC BY 3.0 或更新之台灣地區版本」授權條款釋出,如何使用敬請參考
 Creative Commons — 姓名標示 3.0 台灣 — CC BY 3.0 TW
 http://creativecommons.org/licenses/by/3.0/tw/

「你不懂的東西就不要亂講,被懂得人看破手腳就算了,騙不懂的人誤導別人,還要別人把你當成大師,這就真的是說不過去了。」
 by Allen Own
 出處 http://www.plurk.com/p/i4uogm

自由知識創作平台介紹
 https://docs.google.com/document/d/1MGG6lW_0qCgH4U785R-IwSc_INdoBGej1l-JxiA4gPE
如何建立新的自由知識創作平台文件
 https://docs.google.com/document/d/11NdzOW2lGYksfyQIcPMPye5tlmj1J0QTkgPTmQvIvKA
應用擴展 工具箱

« 1 2 3 (4)

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


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