This the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Seamless Update with A/B Partition System

You can seamlessly update or roll back Photon OS with the support for A/B partition system. You can create a shadow partition set of the system and maintain the two partition sets. For example, an active set of partitions (partition A) and an inactive set of partitions (shadow partition or partition B).

The two partition sets ensure that the working system runs seamlessly on the active partition set while the update is performed on the inactive partition set. After the inactive partition set is updated, you can execute a kexec to boot quickly into the updated partition set. If the updated partition set does not work, the system can reboot and roll back to the previously working state on partition A.

Note: The kexec boot is executed with the abupdate switch command. The kexec boot does not modify the EFI boot manager (or MBR in the case of BIOS).

1 - Configuring A/B Partition System

You need to create a shadow partition set and configure the A/B partition system to use it for Photon OS updates and modifications.

To use the A/B partition system, ensure the following prerequisites:

  • If you boot with BIOS, only a root filesystem pair is needed. If you boot with UEFI, an EFI partition pair is also needed.

  • In the kickstart configuration file, when you create a partition, set the value of the ab parameter as true to create a shadow partition of the user-defined partition.

    To know more about the kickstart configuration, see the following page: Kickstart Support in Photon OS

    The following example shows how to create a shadow partition mounted at /:

    {
      "partitions": [
                      {
                        "disk": "/dev/sda",
                        "mountpoint": "/",
                        "size": 0,
                        "filesystem": "ext4",
                        "ab": true
                      },
                      {
                        "disk": "/dev/sda",
                        "mountpoint": "/sda",
                        "size": 100,
                        "filesystem": "ext4"
                      }
                    ]
    }
    
  • Configure the system details of the partitions for A/B update in the following configuration file: /etc/abupdate.conf

    The following template shows how a configuration file looks like:

    # either UEFI, BIOS, or BOTH
    # BOOT_TYPE=<boot type>
    
    # automatically switch to other partition set after update?
    # AUTO_SWITCH=NO
    
    # automatically finalize the update after a switch?
    # AUTO_FINISH=no
    
    # can choose to either use tdnf or rpm as a package manager
    # if not specified, tdnf is used
    # PACKAGE_MANAGER=tdnf
    
    # Provide information about partition sets
    # PartUUID info can be found with the "blkid" command
    #
    # EFI is needed if booting with UEFI
    # Format: PARTUUID A, PARTUUID B, mount point
    #
    # Example: HOME=("PARTUUID A" "PARTUUID B" "/home")
    
    # Note that the / partition should be labeled as _ROOT
    # EFI=("PARTUUID A" "PARTUUID B" "/boot/efi")
    # _ROOT=("PARTUUID A" "PARTUUID B" "/")
    
    # List of all partition sets
    # SETS=( "ROOT" )
    
    # exclude the following directories/files from being synced
    # note that these directory paths are absolute, not relative to current working directory
    #
    # Format: <set name>_EXCLUDE=( "/dir1/" "/dir2" "/dir3/subdir/file" ... "/dirN/" )
    #
    # Example:
    # HOME_EXCLUDE=( "/mnt" "lost+found" )
    

You can use the abupdate init command to auto-populate all the fields. However, it is recommended that you manually enter the fields for better accuracy.

Note: Persistent or shared partitions that exist outside the active and inactive partition sets are also supported in the A/B partition system. You need not specify the persistent or shared partitions in the configuration files.

2 - Executing Update and Rollback Using A/B Partition System

To modify or rollback Photon OS updates using A/B partition system, perform the following workflow:

  1. Edit the files on the inactive partition set. You can use the command options like mount, update, and deploy to mount and edit the files based on your requirements.

  2. Switch to an inactive partition set using the abupdate switch command.

  3. If you are not satisfied with the update, execute abupdate switch or reboot to roll back to the old active partition set.

  4. If you are satisfied with the update on the inactive partition set, finalize the switch with the abupdate finish command. Note: Once you execute the abupdate finish command, a reboot does not roll back to the previous partition set.

To know more about the commands for various operations, visit the following topic: Commands for Operations

3 - Commands for Operations

You can perform various operations in the A/B partition system using the following commands:

  • abupdate mount/unmount: Use this command to mount or unmount the inactive partition set. The partition set is mounted as a tree at the following location: /mnt/abupdate/. After you mount the partition set, the files are accessible for modifications.

  • abupdate update: Use this command to automatically upgrade the packages on the inactive partition set. This command supports tdnf and rpm as the package managers.

  • abupdate sync: Use this command to synchronize the active partition set with the inactive partition set. Note that this command eliminates the ability to rollback to a safe system anymore as both becomes mirrored partition sets after the command is executed.

  • abupdate clean: Use this command to erase everything on the inactive partition set.

  • abupdate deploy <tar.gz>: Use this command to erase and clean the inactive partition set, mount the inactive partition set, and then install or unpack the specified OS image in the inactive partition set from a tar file.

  • abupdate check: Use this command to run checks on the inactive partition set from the active partition set. Execute this command before you execute the switch command to ensure that the inactive partition set is not broken. This command also runs checks on tools needed to update or switch from the active partition set.

  • abupdate switch: Use this command to switch from the active partition set to the inactive partition set. Note that this command does not modify the EFI boot manager (or MBR in case of BIOS), and hence, any subsequent reboot rolls back to the previously active partition set.

    If the AUTO_SWITCH parameter is set to yes in the configuration file, then the system automatically switches into the updated partition set after the update is complete.

  • abupdate finish: Use this command to finalize the update. This command modifies the EFI boot manager (or MBR in case of BIOS). After you execute this command, the subsequent reboots load this partition set instead of rolling back to the previous partition set.

    Note: If the AUTO_FINISH parameter is set to yes in the configuration file, then the system automatically finalizes the switch with the finish command.

  • abupdate help: Use this command to print the help menu.