如何使/var/log在Yocto Fido中持久化(poky) [英] How to make /var/log persistent in Yocto Fido (poky)
问题描述
我正在尝试使/var/log
在我的fido构建中保持不变.
poky的默认设置是/var
中有一个指向log -> volatile/log
的符号链接. volatile
是安装在tmpfs上的.
I'm trying to get /var/log
to be persistent in my fido build.
The default setting on poky is, that there is a symlink in /var
which points log -> volatile/log
. volatile
is a mounted on a tmpfs.
到目前为止,我发现符号链接应该由base-files
配方创建:
So far i figured out that the symlink should be created by the base-files
recipe:
volatiles = "log tmp"
do_install () {
...
for d in ${volatiles}; do
ln -sf volatile/$d ${D}${localstatedir}/$d
done
...
我附加了基本文件配方,因此未创建链接,但仍在我的rootfs中显示该链接.那么它是从哪里来的呢?我怀疑fs-perms.txt
可能与它有关.但是我尝试创建一个没有
I appended the base-files recipe so the link was not created, but it still turned up in my rootfs. So where does it come from? I suspect that maybe the fs-perms.txt
has something to do with it. But i tried to create one without the
${localstatedir}/log link volatile/log
行,它仍然创建了该链接.有任何线索吗?
line and it still created that link. Any clues?
推荐答案
基本文件配方创建基本的系统目录并创建易失性符号链接.还有一个第二个文件会影响它,它是一个初始化脚本,用于检查易失性目录,启动期间的符号链接并在缺少时创建.您应该同时添加base-files
和initscripts
配方.最后,您必须在fs-perms.txt
中更新与基本文件相关的链接.
The base-files recipe creates the basic system directories and makes the volatile symlinks. There is also a second file that affects, it's an initscript that checks volatile directories, symlinks during startup and creates if missing. You should append both base-files
and initscripts
recipes. Finally, you have to update base-files related links in fs-perms.txt
.
我建议,如果硬盘驱动器上有足够的空间,则可以将/var/log
挂载到rootfs所在的不同分区.如果您的rootfs分区上发生了某些事情,那是一种更实用,更安全的方法.
I suggest that If there is enough space on your hard drive you could mount /var/log
to a different partition from rootfs. That's more practical and safe way if there is something happen on your rootfs partition.
new_log_part
是我的日志分区.
如果为日志创建新分区,则应将其添加到fstab以在启动时自动挂载.在基本文件配方中包括新的fstab.
If you create a new partition for logs, you should add it to fstab to automount on startup. Include new fstab in base-files recipe.
要追加的基本文件配方:
The base-files recipe to append:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://fstab"
dirs755_remove = "${localstatedir}/volatile/log"
volatiles_remove = "log"
do_install_append () {
ln -snf new_log_part ${D}${localstatedir}/log
}
附加的脚本:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://volatiles"
volatiles文件:
volatiles file:
# This configuration file lists filesystem objects that should get verified
# during startup and be created if missing.
#
# Every line must either be a comment starting with #
# or a definition of format:
# <type> <owner> <group> <mode> <path> <linksource>
# where the items are separated by whitespace !
#
# <type> : d|f|l : (d)irectory|(f)ile|(l)ink
#
# A linking example:
# l root root 0777 /var/test /tmp/testfile
# f root root 0644 /var/test none
#
# Understanding links:
# When populate-volatile is to verify/create a directory or file, it will first
# check it's existence. If a link is found to exist in the place of the target,
# the path of the target is replaced with the target the link points to.
# Thus, if a link is in the place to be verified, the object will be created
# in the place the link points to instead.
# This explains the order of "link before object" as in the example above, where
# a link will be created at /var/test pointing to /tmp/testfile and due to this
# link the file defined as /var/test will actually be created as /tmp/testfile.
d root root 0755 /var/volatile/cache none
d root root 1777 /var/volatile/lock none
d root root 0755 /var/new_log_part none
d root root 0755 /var/volatile/run none
d root root 1777 /var/volatile/tmp none
l root root 0755 /var/cache /var/volatile/cache
l root root 1777 /var/lock /var/volatile/lock
l root root 0755 /var/log /var/new_log_part
l root root 0755 /var/run /var/volatile/run
l root root 1777 /var/tmp /var/volatile/tmp
d root root 0755 /var/lock/subsys none
f root root 0664 /var/new_log_part/wtmp none
f root root 0664 /var/run/utmp none
l root root 0644 /etc/resolv.conf /var/run/resolv.conf
f root root 0644 /var/run/resolv.conf none
fs-perms.txt更改:
fs-perms.txt changes:
# Items from base-files
# Links
${localstatedir}/run link volatile/run
${localstatedir}/log link new_log_part
${localstatedir}/lock link volatile/lock
${localstatedir}/tmp link volatile/tmp
然后在图层的layer.conf文件中添加以下行以包含新的fs-perms.txt:
Then in the layer's layer.conf file add this line to include new fs-perms.txt:
FILESYSTEM_PERMS_TABLES = "${LAYER_PATH}/fs_files/fs-perms.txt"
注意:您可以创建自己的fs-perm文件,并将默认文件附加到conf.layer中.
Note: You can create your own fs-perm file and append the default one in your conf.layer.
FILESYSTEM_PERMS_TABLES = "fs-perm.txt my-fs-perm.txt"
这篇关于如何使/var/log在Yocto Fido中持久化(poky)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!