[英]How to make /var/log persistent in Yocto Fido (poky)
I'm trying to get /var/log
to be persistent in my fido build.我试图让
/var/log
在我的 fido 构建中持久化。 The default setting on poky is, that there is a symlink in /var
which points log -> volatile/log
. poky 的默认设置是,
/var
中有一个符号链接,指向log -> volatile/log
。 volatile
is a mounted on a tmpfs. volatile
是安装在 tmpfs 上的。
So far i figured out that the symlink should be created by the base-files
recipe:到目前为止,我发现符号链接应该由
base-files
配方创建:
volatiles = "log tmp"
do_install () {
...
for d in ${volatiles}; do
ln -sf volatile/$d ${D}${localstatedir}/$d
done
...
I appended the base-files recipe so the link was not created, but it still turned up in my rootfs.我附加了基本文件配方,因此没有创建链接,但它仍然出现在我的 rootfs 中。 So where does it come from?
那么它来自哪里呢? I suspect that maybe the
fs-perms.txt
has something to do with it.我怀疑
fs-perms.txt
可能与它有关。 But i tried to create one without the但我试图创造一个没有
${localstatedir}/log link volatile/log
line and it still created that link.行,它仍然创建了该链接。 Any clues?
有什么线索吗?
A persistent log data option has made it in Yocto 2.4: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6132 Yocto 2.4 中有一个持久日志数据选项: https ://bugzilla.yoctoproject.org/show_bug.cgi ? id = 6132
Log data can now be made persistent by defining the following in your distro config:现在可以通过在发行版配置中定义以下内容来使日志数据持久化:
VOLATILE_LOG_DIR = "no"
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.
还有一个影响的第二个文件,它是一个 initscript,它在启动期间检查易失性目录、符号链接,如果丢失则创建。 You should append both
base-files
and initscripts
recipes.您应该附加
base-files
和initscripts
配方。 Finally, you have to update base-files related links in fs-perms.txt
.最后,您必须更新
fs-perms.txt
基础文件相关链接。
I suggest that If there is enough space on your hard drive you could mount /var/log
to a different partition from rootfs.我建议如果您的硬盘驱动器上有足够的空间,您可以将
/var/log
挂载到 rootfs 的不同分区。 That's more practical and safe way if there is something happen on your rootfs partition.如果您的 rootfs 分区上发生了某些事情,那是更实用和安全的方法。
new_log_part
is my log partition in this case.在这种情况下,
new_log_part
是我的日志分区。
If you create a new partition for logs, you should add it to fstab to automount on startup.如果为日志创建新分区,则应将其添加到 fstab 以在启动时自动挂载。 Include new fstab in base-files recipe.
在基本文件配方中包含新的 fstab。
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
}
initscripts append: initscripts 追加:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://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 changes: fs-perms.txt 更改:
# 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
Then in the layer's layer.conf file add this line to include new fs-perms.txt:然后在图层的 layer.conf 文件中添加这一行以包含新的 fs-perms.txt:
FILESYSTEM_PERMS_TABLES = "${LAYER_PATH}/fs_files/fs-perms.txt"
Note: You can create your own fs-perm file and append the default one in your conf.layer.注意:您可以创建自己的 fs-perm 文件并在 conf.layer 中附加默认文件。
FILESYSTEM_PERMS_TABLES = "fs-perm.txt my-fs-perm.txt"
I know this is an old question and that it has been answered, but to combine Bl00dh0und's and alpi's answers you could define VOLATILE_LOG_DIR = "no"
in the local.conf
, automount the new_log_part
in fstab
and then add something like this to the image recipe:我知道这是一个老问题并且已经得到解答,但是要结合 Bl00dh0und 和 alpi 的答案,您可以在
local.conf
定义VOLATILE_LOG_DIR = "no"
,在fstab
自动挂载new_log_part
,然后将类似的内容添加到图像配方中:
create_log_link_to_new_partition() {
cd ${IMAGE_ROOTFS}
rm -rf var/log
ln -s ../path/to/auto/mounted/new_log_part var/log
}
IMAGE_PREPROCESS_COMMAND += "create_log_link_to_new_partition;"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.