[OE-core] [PATCH] image.bbclass: Always try to run populate-volatile.sh at rootfs time
Mike Looijmans
mike.looijmans at topic.nl
Mon Aug 24 13:07:44 UTC 2015
Any comments on this?
And if unacceptable, how about at least making
"rootfs_populate_volatile_cache" available as a sort of library method so it
doesn't get repeated at each image recipe?
On 12-08-15 09:00, Mike Looijmans wrote:
> Currently populate-volatile.sh will only run when "readonly-rootfs" is
> selected.
>
> Running this script is very useful even on read/write root filesystems,
> because it reduces the number of "fixup" actions at first boot of the
> device. That not only reduces boot time, it also reduces the flash space
> usage. Also, when the system happens to have a read-only filesystem
> because for example the "read-only" switch of the SD card was set, or
> because the filesystem had errors on it, it will still be able to boot.
>
> I've been manually adding these lines to each and every image recipe I've
> used, so I guess it's time to move this into core.
>
> Signed-off-by: Mike Looijmans <mike.looijmans at topic.nl>
> ---
> meta/classes/image.bbclass | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index ff2ed0d..68deb84 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -185,6 +185,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb
> # Create /etc/timestamp during image construction to give a reasonably sane default time setting
> ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
>
> +# Create the volatile cache. Required for read-only rootfs, useful for all sysvinit systems to reduce writes to the system
> +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "rootfs_populate_volatile_cache;", "", d)}'
> +
> # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled
> ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
>
> @@ -216,6 +219,16 @@ do_rootfs[cleandirs] += "${S}"
> # task, so that we have a single fakeroot context for the whole process.
> do_rootfs[umask] = "022"
>
> +
> +# Run populate-volatile.sh at rootfs time to set up basic files and
> +# directories to reduce writes at first boot and to support read-only
> +# rootfs.
> +rootfs_populate_volatile_cache() {
> + if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
> + ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
> + fi
> +}
> +
> # A hook function to support read-only-rootfs IMAGE_FEATURES
> read_only_rootfs_hook () {
> # Tweak the mount option and fs_passno for rootfs in fstab
> @@ -226,11 +239,6 @@ read_only_rootfs_hook () {
> if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
> sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
> fi
> - # Run populate-volatile.sh at rootfs time to set up basic files
> - # and directories to support read-only rootfs.
> - if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
> - ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
> - fi
> # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
> # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
> # and the keys under /var/run/ssh.
>
Kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
Telefax: +31 (0) 499 33 69 70
E-mail: mike.looijmans at topicproducts.com
Website: www.topicproducts.com
Please consider the environment before printing this e-mail
More information about the Openembedded-core
mailing list