Linux: Golden Image Preparation and Production Deployment

From Compulab Mediawiki
Revision as of 15:02, 20 September 2023 by Igor (talk | contribs) (Created page with "=Introduction= This article outlines the recommended process for image preparation and production deployment of a custom target O/S image onto IOT-GATE-iMX8 and IOT-GATE-iMX8P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

This article outlines the recommended process for image preparation and production deployment of a custom target O/S image onto IOT-GATE-iMX8 and IOT-GATE-iMX8PLUS devices.
The suggested flow utilizes the Compulab cl-deploy and cl-auto utilities and involves the following steps:

  1. Creating the desired "golden" image
  2. Cloning the image to create production deployment media
  3. Using the production deployment media for automated unattended installation on any IOT-GATE-iMX8 or IOT-GATE-iMX8PLUS unit

Creating the Desired "Golden" Image

This guide assumes that the "source" unit is already running the latest CompuLab Debian package.

Apply the Necessary Custom Modifications (optional)

Make the required modifications to the root file system, for example:

  • Copy the required files
  • Install additional packages
  • Create the required users
  • Update the root user password
  • Clean up the history and logs

Configure the Automatic Installation Script Behavior

The cl-auto auto-installer utility supports custom exit functions. This allows the user to define device behavior once deployment is finished.

Function names:

  • external_okay_exit -- a non-error exit
  • external_error_exit -- an error exit

File to place these functions: /usr/share/cl-deploy/cl-auto.notifier

Example:
The following cl-auto.notifier code sets the device to power-off after a successful installation.

cat > /usr/share/cl-deploy/cl-auto.notifier << EOF
# cl-auto.notifier

external_okay_exit() {
# Select Off/Reboot #
dialog_msg="Turn off the device in \${good_timeout} seconds ..."

dialog --yes-label "Turn Off" --no-label "Reboot" --timeout \${good_timeout} --title "cl-deploy: status [ okay ]" --yesno "\${dialog_msg}" 10 60 2>/dev/null
if [[ \$? -eq 1 ]]; then
exit 0
fi

# Turn off the device #
echo 1 > /proc/sys/kernel/sysrq
sync;sync;sync
for cmd in s u o;do echo \${cmd} > /proc/sysrq-trigger ; done
sleep 10
}
EOF

Create Production Deployment Media

  • Use any commercially available USB flash drive sufficient to contain your image. Minimizing the flash drive size will reduce the time of deployment.
Admolition important.png USB drive size MUST not exceed eMMC size of the target unit
Make sure that only one USB flash drive is inserted
  • Insert the USB flash drive into one of the USB ports of the "source" unit.
  • Execute cl-deploy to copy the contents of the internal storage (eMMC) to the USB flash drive:
# cl-deploy
  • Press the space bar to start the copy process.
  • The following message will be displayed when the process is complete:
┌──────────────────────────────────────────────────────────────────────────────┐
│ Boot media has been deployed on /dev/sda                                     │
│                                                                              │
│ Would you like to reboot the device now?                                     │
│                                                                              │
│                                                                              │
│                                                                              │
├──────────────────────────────────────────────────────────────────────────────┤
│                         < Yes >             < No  >                          │
└──────────────────────────────────────────────────────────────────────────────┘
  • Reboot the device with the USB flash drive
  • Login with the root user
  • Enable the automatic installation:
# cl-auto -c
# cl-auto -A
  • Power off the device
# poweroff
  • Remove the USB flash drive. Now it contains the auto-deployable "golden" image.

Production Deployment

  • Insert the USB flash drive into one of the USB ports of the target device.
Admolition important.png Make sure that only one USB flash drive is inserted
  • Power on the target device.
  • The following message will be displayed before the installation begins:
         +--------cl-deploy will get started in 5 seconds-----------+
         | Configuration file /etc/cl-auto.conf parameters:         |
         | --------------------------------------------------       |
         | DST=/dev/mmcblk2                                         |
         | QUIET=Yes                                                |
         | --------------------------------------------------       |
         | Press any key for terminating ...                        |
         |                                                          |
         |                                                          |
         |                                                          |
         |                                                          |
         |                                                          |
         +----------------------------------------------------------+
         |                 <Stop Auto Installer>                    |
         +----------------------------------------------------------+
  • If not interrupted, the installation will begin automatically.
  • Wait for the success message:
         #####  #     #  #####   #####  #######  #####   #####
        #     # #     # #     # #     # #       #     # #     #
        #       #     # #       #       #       #       #
         #####  #     # #       #       #####    #####   #####
              # #     # #       #       #             #       #
        #     # #     # #     # #     # #       #     # #     #
         #####   #####   #####   #####  #######  #####   #####
  • Use the space bar and the arrow keys to select power off or reboot:
         +---------------cl-deploy: status [ okay ]-----------------+
         |                                                          |
         |                                                          |
         +----------------------------------------------------------+
         |               <Turn Off>        < Reboot >               |
         +----------------------------------------------------------+