简体   繁体   English

如何在 Yocto Fido (poky) 中使 /var/log 持久化

[英]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-filesinitscripts配方。 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.

相关问题 如何在 Yocto Rocko 中将 /var/log 符号链接到持久存储 - How to make /var/log symlink to a persistent storage in Yocto Rocko 如何在Yocto / Poky图像上设置root密码? - How to set root password on Yocto / Poky image? 如何在 yocto (poky) 飞思卡尔 linux 中创建 rpm 包 - How to create rpm package in yocto (poky) freescale linux Yocto、OpenEmbedded、Poky……健全性检查 - Yocto, OpenEmbedded, Poky… Sanity check 如何在 /var/volatile/log/ 下创建一个新目录并在 Yocto 构建中更改权限? - How to create a new directory under /var/volatile/log/ and change permission in Yocto build? poky平台如何独立 - How is poky platform independent 嵌入式poky dist。 从bash执行python或gcc时不返回任何东西(Yocto Project) - embedded poky dist. do not return any thing when execute python or gcc from bash (Yocto Project) 用于init-ifupdown的Yocto Poky-Pyro bbappend文件未替换/ etc / network / interfaces - Yocto Poky-Pyro bbappend file for init-ifupdown is not replacing /etc/network/interfaces 哪个实用程序生成“ Poky(Yocto项目参考发行版)2.6.1(无)/ dev / console” - which utility produces “Poky (Yocto Project Reference Distro) 2.6.1 (none) /dev/console” 任务 415 (virtual:native:/home/user/Yocto/Poky/poky/meta/recipes-devtools/automake/automake_1.15.bb, do_compile) 失败,退出代码为“1” - Task 415 (virtual:native:/home/user/Yocto/Poky/poky/meta/recipes-devtools/automake/automake_1.15.bb, do_compile) failed with exit code '1'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM