Warning: the Torizon Update System is a project currently under development at Toradex Labs. It is still an experimental project in it's early stages which is subject to changes without notice. This might impact new releases and/or iterations.
OSTree is a library - actualy libostree - that handles updates for filesystem trees, that is, the entire Linux image. It applies updates atomically, therefore guaranteeing the system integrity in case of a failure provided by a power-cut or dropped internet connectivity for instance. Different from the A/B partition mechanism of updates, OSTree works in a git-like model, providing file updates and thus saving storage space as well as connection bandwidth and allowing more than 2 software revisions on the device at the same time. In addition, some directories such as /var and /etc and handled as special cases, providing persistent configuration and user data to be preserved between updates.
OSTree is a key technology used by the Torizon Update System, but it is not meant to be used standalone. That being said, this article shows how to use OSTree directly from command-line, for demonstration purposes.
This article complies to the Typographic Conventions for Torizon Documentation.
Here's a quick demo on performing an update using the underlying OSTree technology on the device manually. It helps to understand how things are done, which can then be used for automation.
Whenever you build TorizonCore a directory
ostree_repo gets produced during the build. This directory is git-like containing the meta-data for that build's filesystem. Toradex uploads the nightly and release Torizon builds OSTree repository and makes them available. Feeds can be found at the following location:
Attention: All device commands must be executed as root, so you have to login as root on the device or, if you are logged-in using the torizon user, prefix the following command lines with "sudo" to execute them as root.
Here is an example how to update using the Toradex feeds.
# ostree remote add --no-gpg-verify toradex-nightly \ http://feeds.toradex.com/ostree/torizon-master/nightly/apalis-imx6/
# ostree remote refs toradex-nightly toradex-nightly:torizon-core-balena toradex-nightly:torizon-core-docker toradex-nightly:torizon-core-lite
# ostree pull toradex-nightly:torizon-core-docker 172 metadata, 485 content objects fetched; 17704 KiB transferred in 12 seconds
ostree diffcan be used:
# ostree diff toradex-nightly:torizon-core-docker M /usr/package.manifest M /usr/etc/manifest.xml ...
# ostree admin deploy toradex-nightly:torizon-core-docker Copying /etc changes: 5 modified, 2 removed, 7 added Transaction complete; bootconfig swap: yes; deployment count change: 1
# ostree admin status torizon 0cbeafe2973079d5edb4457839054af3c1bb8ea09678c92bcf022eea2ca92e60.0 (pending) origin refspec: toradex-nightly:torizon-core-docker * torizon 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6.0 origin refspec: 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6
# ostree admin status * torizon 0cbeafe2973079d5edb4457839054af3c1bb8ea09678c92bcf022eea2ca92e60.0 origin refspec: toradex-nightly:torizon-core-docker torizon 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6.0 (rollback) origin refspec: 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6
If you are building TorizonCore image locally you may provide an ostree repo directly from your PC. If you have Python installed, just move to the ostree_repo folder of your build directory (should be under deploy/images/$MACHINE/ostree_repo) and bring-up the Python built-in simple HTTP server:
$ python -m SimpleHTTPServer 8081
In this way your PC will be sharing the image you just built on port 8081. You can replace http://feeds.toradex.com/ostree/nightly/apalis-imx6/ in the above instructions with
<your PC ip address>:8081 and update your device directly from your build machine.
Please notice that this kind of operation is not secure and such a configuration should be used only for debugging purposes.
If you don't have network connectivity on target board, In that case, keep the OStree repo to the USB thumb drive then connect the USB thumb drive to the target board and then can do the update by following the instructions below.
If you are building Torizoncore image locally the OSTree files will be in deploy/images/$MACHINE/ostree_repo path.
# ostree refs --repo=PATH_TO_REPO_DIRCTORY
# ostree refs --repo=/home/root/pendrive/ostree_repo/ torizon/torizon-core-docker torizon/torizon-core-docker-torizon-core-docker
# ostree pull-local PATH_TO_USB_REPO REFS_NAME
# ostree pull-local /home/root/pendrive/ostree_repo/ torizon/torizon-core-docker
# ostree admin deploy REFS
e.g. ostree admin deploy torizon/torizon-core-docker
# ostree admin status torizon 1d98e25015a390556e7ab93c9b94e01e8632d30d800b36bff1ddd54fa9fc7cf4.0 (pending) origin refspec: torizon/torizon-core-docker * torizon d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660.0 origin refspec: d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660
Finally, you can view your current and previous deployment which you can rollback to if need be.
# ostree admin status * torizon 1d98e25015a390556e7ab93c9b94e01e8632d30d800b36bff1ddd54fa9fc7cf4.0 origin refspec: torizon/torizon-core-docker torizon d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660.0 (rollback) origin refspec: d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660