RFC: Pre pull request for openbmc initfs updates
Milton Miller II
miltonm at us.ibm.com
Thu Mar 3 14:05:54 AEDT 2016
All,
I have completed initial testing of my updates to initfs to allow
running from RAM. Comments on the option names and functions are
welcome. The branch is available at
https://github.com/mdmillerii/openbmc/tree/wip-from-ram
There are a couple of use cases enabled by this series:
1) Allow the BMC to run without any access to the flash.
2) Allow running a new application layer while updating the flash.
3) Allow a new application layer to be tested without committing it
to flash.
4) Allow running the overlay totally from RAM with only white
listed files saved at specific times.
This is implemented by having the following options in init:
- An option and hook to run a command that could download an image
- Alternatively use existing debug-init-sh hook
- An option to copy existing read-only file into RAM
- Mount an read-only file system image in RAM via a loop device
- An option to copy white listed files from read-write file system to
RAM for use at runtime (can also use empty overlay but that would
loose dropbear key, machine id, network settings)
- An option to suppress mounting Read-Write file system before creating
overlay
The following options control the behavior of /init in the initramfs:
- debug-init-sh : a previously existing hook to invoke a shell via
sulogin, can add or change options here
- openbmc-init-download-files : will execute via sh -c the saved
contents of openbmcinitdownload u-boot variable (which can be
used to download files via http (wget) or tftp).
- clean-rwfs-filesystem : an existing option to remove , erase, and
restore files. unless a image-rwfs exists via download this will
have the side effect of converting the read-write files ystem to
jffs2 our current build choice.
- copy-files-to-ram : copy files from the read-write files system to ram
- overlay-filesystem-in-ram : skip mounting read-write filesystem, will
be blank if copy-files-to-ram not set
- copy-base-filesystem-to-ram : copy existing flash to image to ram
unless an image file is already present in ram
These options are read from the /run/initramfs/init-options which is
initialized from the combination of the kernel command line and
the saved contents of two u-boot environment variables openbmcinit
and openbmconce. The file can be edited at the debug-init-sh prompt
and/or via the shell command line stored in the debug hook.
A custom initramfs can be booted via tftp with an embedded image-rofs
that will be activated for run.
I do not have a dhcp server to test setting variables from a dhcp script.
An example download command today might be:
u-boot env:
# set kernel command line with copy of static ip configuration (none). run addip
fw_setenv addip 'setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:none:${dnsip}:${dnsip2}'
# init option via kernel command line for temporary host by "run triggerdownload"
fw_setenv triggerdownload "setenv bootargs ${bootargs} openbmc-init-download-files"
# an http get from dns resolved host
fw_setenv openbmcinitdownload 'cp /proc/net/pnp /run/resolv.conf ; ln -snf ../run/resolv.conf /etc/resolv.conf ; wget -O /run/image-rofs http://server.example.com/openbmc/test-image-rofs'
# a simple tftp to fixed numberic server
fw_setenv openbmcinitdownload 'tftp -r test-image-rofs -l /run/image-rofs -g 192.168.0.1'
---
at the u-boot prompt you can then run
run addip dodownload
Not implemented but on shortlist:
Make update script more strict / lenient / smart, allowing update or save
of rwfs files during runtime while read only file system is running from
flash, or writing read only file system image while read write file
system is running from flash (possibly cleaned to white listed files on
this boot). Delayed because it needs to exclude bmc container update
in addition to 3 ways to specify mtd device to mount.
Modify update script to take list of images to update instead of finding
files via wildcard would save creating empty updates to run white list
functions and duplicate knowledge of where images to flash are located.openbmc-init-download-files
Add options to change runtime init (eg init= kernel command line), defer
updates (flash_images_before_init=n), and force jffs2 options in boot.
Adding hook for running script(s) before runtime init run to setup files
before systemd.
Adding systemd unit to clear the run-once init options variable from
u-boot environment. The command is "fw_setenv openbmcbootonce" and it
can run every boot as the shutdown script will trigger an update of the
fw_env back to flash on shutdown if the file differs from the flash.
More information about the openbmc
mailing list