Keep user-data when installing Easy Installer image

What we would like to be able to do is create a tezi image that keeps certain user-data (configuration files, calibration data etc) intact if it is present. If this data is not present, a set of default files should be installed. We have come up with two ways of doing this:

  1. Use the prepare and wrapup scripts to mount the existing image, copy the user-data to a temporary location (In /var/volatile, for example) and then copy this data back after the image has been installed
  2. Create 2 images: one for an initial install (e.g. during production) that includes a separate partition where the set of default files are placed, and a second image for all subsequent upgrades that does not include this partition.

I was wondering, however, if Easy Installer has some standard feature to facilitate this. I’m not seeing it in the documentation so far, but maybe it does exist after all.

Thanks in advance,

Jeroen

Hi Jeroen

During the flashing process with Toradex Easy Installer the partition table is remade, so you will lose all user data. You can do the first option by moving the user-data to a temporary place and copying back or you can copy this data to the tezi image and then flash the tezi image.

Hi Jaski,

Thanks for your reply. What do you mean when you say “copy the data to the tezi image”? Is this something I can do from the prepare script? How do I indicate this in the tezi json configuration file?

Regards,

Jeroen

The Toradex Easy Installer (Tezi) as such was not meant as an update tool. It was more designed for the initial flashing/and complete recovery use case. Therefor it is rather heedless when it creates partitions: By default, after it creates the partition table, it dd’s the first kilobytes to make sure that subsequent mkfs commands succeed. Hence at its current state it is not possible to let Tezi preserve partitions.

By coping data back to the Tezi image Jaski meant reintegrating the data into a Tezi image. This would only be possible for static user data files really…

So when dealing with device dependent user data/calibration files, your best bet is option 1.

Hi Stefan,

Thanks for the explanation, that makes sense. I agree option 1 is our best bet then. I already have this working, but just wanted to make sure there is no better option.

Regards,

Jeroen

Unfortunately no, at the moment not. Thanks for your feedback!

For option 1 here is my working script:

in prepare.sh you could do something like this

SRC=/var/volatile/_cur
TGT=/var/volatile/_backup
mkdir $SRC
mount -t auto -v /dev/mmcblk0p2 $SRC

if [ -d ${SRC}/usr/share/myapp/cfg ] 
then
	echo "Existing Configuration detected"
	mkdir $TGT
	cp -f ${SRC}/etc/hostname $TGT
	cp -fr ${SRC}/usr/share/myapp/cfg $TGT
else
	echo "Deploying to new Hardware"
fi

umount /dev/mmcblk0p2 -l

Don’t forget to umount the partition, otherwise TEZI will show an error-message that the partitions are in use.

In the wrapup.sh you could do something like this (IMAGE_FOLDER points to the root of my USB):

BACKUP=/var/volatile/_backup
if [ -d "${BACKUP}/cfg" ] 
then
	cp -f ${BACKUP}/hostname ${DEST}/etc
	cp -fr ${BACKUP}/cfg $APPDIR
fi

if [ -f "${IMAGE_FOLDER}/app.tar.gz" ]
then
	cd $APPDIR
	rm -rf dist
	tar xf ${IMAGE_FOLDER}/app.tar.gz
fi

Hope this helps someone wanting to do similar actions.

For information - I got the name mmcblk0p2 by executing lsblk and checking the source of the / mount.

HI @tw.apex

Thanks for sharing this valuable Information.

Best regards,
Jaski