Skip to content

Latest commit

 

History

History
 
 

abupdate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
A/B Update

Package to perform update/rollback with A/B partition sets.

Design:
    In this design, we have A and B sets of partitions, hence the name A/B upgrade. There is also support for shared/persistent partitions that are not part of
    other set. To update/modify the system, the idea is that the system on the B partition set can be modified freely while the active system is running. Once
    an update is desired, it can be achieved atomically by booting into the B partition set and running the newly updated/modified system. Importantly, a simple switch
    doesn't modify the bootloader so any subsequent reboots will be back into the unmodified A set. This allows for safe updates, as if anything goes wrong
    in the B system, we can roll back to the A version of the system.

    We only modify the bootloader when it is specifically requested, but after that point subsequent reboots will now be into the modified/updated system.
    This is done through the "finish" command.

    This tool allows for various utilities to support this design:
        - mounting/unmounting shadow partitions, so that they can be easily modified
        - updating packages on B set
        - check for capabilities
        - clean out the shadow partitions
        - deploy an OS image from a tarball into the B set
        - sync the A and B partition sets (mirror)
        - switch from A to B partition sets
        - finalize update/switch by modifying bootloader

Requirements:
    Requires two sets of partitions, A and B. Each partition set can be comprised of multiple individual partitions.
    - If booting with BIOS, only a root filesystem pair is needed.
    - If booting with UEFI, an EFI partition pair is also needed.

    Optionally, other partition pairs can be added as well.

Config File:
    Configuration options can be set in /etc/abupdate.conf. These options are read in as a bash script, so they must be formatted in bash syntax.
    The "init" command can, in some situations, auto-populate this file.

    Available options:
        BOOT_TYPE (either UEFI, BIOS, or BOTH if applicable)
        PLATFORM (for grub-install, if BIOS)
        AUTO_SWITCH (automatically switch to B partition set after update)
        AUTO_FINISH (automatically finalize a switch)
        PACKAGE_MANAGER (either tdnf or rpm)

    Partition pairs:
        Some partitions have a corresponding shadow partition, so we should specify the mapping here as partition pairs. Persistent/shared partitions
        do not need to be specified in this config file.
        Partition pairs are added as a bash array, with the A and B partition uuids given, along with the mount point.
        To specify the ROOT partition pair, use the name ROOT (all caps). EFI is the same. Other set names can any mixture of characters.

        Example:
            <name>=("partition uuid A" "partition uuid B" "mount point")

        Once a partition set has been added in the config file, you must also update the SETS array to include the name of the set.
        Otherwise, the script will not know that it exists.

        Example:
            SETS=("ROOT" "EFI" "<new set name>")

    Excluding files/folders:
        To exclude a file/folder from being synced across A->B partition sets, you can set an exclude array for that partition set.
        Syntax - <set name>_EXCLUDE=("file name" "/folder/file" "/folder1/folder2")

        Example:
            HOME_EXCLUDE=("/myfolder")

Script usage:
    ./abupdate <options>

    Available options:
          init
                Initializes /etc/abupdate.conf. Attempts to auto detect A and B partitions and boot type.
          sync
                Mirrors the active (A) partition set to the inactive (B) partition set. Syncs all data between the two partition sets
                This is done efficiently using rsync, which transfers only the delta between the two sets.
          deploy <image.tar.gz>
                Accepts an OS image as a tar file. Cleans the B partition set and then deploys the OS image into the B partition set
          mount
                Mounts B partition set, and pseudo filesystems, at /mnt/abupdate
          unmount
                Unmounts B partition set and pseudo filesystems from /mnt/abupdate
          clean
                Cleans the B partition set. Removes all files from all specified shadow partitions. Does not touch any shared/persistent partitions.
          update <packages>
                Accepts a list of packages to update.
                If PACKAGE_MANAGER is set to rpm, the list must be a list of .rpm files
                If no args, updates all packages on the B partition set.
                If AUTO_SWITCH is set, automatically switches into B partition set
          switch
                Executes a kexec boot into the B partition set.
                If AUTO_FINISH is set, automatically finalizes the switch with the finish command
                Otherwise, the next boot will be back into the original A partition set
          finish
                Finalizes the switch by updating the bootloader. Ensures that the next reboot will be into the current partition set.
          check
                Runs various checks to verify A/B partition sets are good to go.
          help
                Print help menu