我正试图让/var/log
坚持我的fido版本。
poky的默认设置是,/var
中有一个指向log -> volatile/log
的符号链接。 volatile
安装在tmpfs上。
到目前为止,我发现符号链接应该由base-files
食谱创建:
volatiles = "log tmp"
do_install () {
...
for d in ${volatiles}; do
ln -sf volatile/$d ${D}${localstatedir}/$d
done
...
我附加了基本文件配方,因此没有创建链接,但它仍然在我的rootfs中出现。那么它来自哪里?我怀疑fs-perms.txt
可能与它有关。但我试图创建一个没有
${localstatedir}/log link volatile/log
行,它仍然创建了该链接。有线索吗?
答案 0 :(得分:9)
基本文件配方创建基本系统目录并生成易失性符号链接。还有一个影响的第二个文件,它是一个intscript,用于检查易失性目录,启动期间的符号链接以及创建是否丢失。您应该附加base-files
和initscripts
个食谱。最后,您必须更新fs-perms.txt
中的基本文件相关链接。
我建议如果硬盘上有足够的空间,可以将/var/log
挂载到与rootfs不同的分区。如果你的rootfs分区发生了某些事情,这是更实际和更安全的方法。
new_log_part
是我的日志分区。
如果为日志创建新分区,则应在启动时将其添加到fstab以自动挂载。在基础文件配方中包含新的fstab。
要附加的基础文件配方:
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追加:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://volatiles"
挥发性文件:
# 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更改:
# 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:
FILESYSTEM_PERMS_TABLES = "${LAYER_PATH}/fs_files/fs-perms.txt"
注意:您可以创建自己的fs-perm文件,并在conf.layer中附加默认文件。
FILESYSTEM_PERMS_TABLES = "fs-perm.txt my-fs-perm.txt"
答案 1 :(得分:3)
持久性日志数据选项已在Yocto 2.4中实现: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6132
现在可以通过在发行版配置中定义以下内容来使日志数据持久化:
VOLATILE_LOG_DIR = "no"
答案 2 :(得分:0)
我知道这是一个古老的问题,并且已经回答了,但是要结合Bl00dh0und和alpi的答案,可以在VOLATILE_LOG_DIR = "no"
中定义local.conf
,在{{ 1}},然后在图像配方中添加以下内容:
new_log_part