Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrBootNameAndRevisionNotReady = errors.New("boot revision not yet established")
)
Functions ¶
func MakeBootable ¶
func MakeBootable(model *asserts.Model, rootdir string, bootWith map[string]*snap.Info, unpackedGadgetDir string) error
MakeBootable sets up the image filesystem with the given rootdir such that it can be booted. bootWith is a map from the paths in the image seed for kernel and boot base to their snap info. This entails:
- installing the bootloader configuration from the gadget
- creating symlinks for boot snaps from seed to the runtime blob dir
- setting boot env vars pointing to the revisions of the boot snaps to use
- extracting kernel assets as needed by the bootloader
func MarkBootSuccessful ¶
func MarkBootSuccessful() error
MarkBootSuccessful marks the current boot as successful. This means that snappy will consider this combination of kernel/os a valid target for rollback.
The states that a boot goes through are the following:
- By default snap_mode is "" in which case the bootloader loads two squashfs'es denoted by variables snap_core and snap_kernel.
- On a refresh of core/kernel snapd will set snap_mode=try and will also set snap_try_{core,kernel} to the core/kernel that will be tried next.
- On reboot the bootloader will inspect the snap_mode and if the mode is set to "try" it will set "snap_mode=trying" and then try to boot the snap_try_{core,kernel}".
- On a successful boot snapd resets snap_mode to "" and copies snap_try_{core,kernel} to snap_{core,kernel}. The snap_try_* values are cleared afterwards.
- On a failing boot the bootloader will see snap_mode=trying which means snapd did not start successfully. In this case the bootloader will set snap_mode="" and the system will boot with the known good values from snap_{core,kernel}
Types ¶
type BootKernel ¶
type BootKernel interface { // RemoveKernelAssets removes the unpacked kernel/initrd for the given // kernel snap. RemoveKernelAssets() error // ExtractKernelAssets extracts kernel/initrd/dtb data from the given // kernel snap, if required, to a versioned bootloader directory so // that the bootloader can use it. ExtractKernelAssets(snap.Container) error // Is this a trivial implementation of the interface? IsTrivial() bool }
A BootKernel handles the bootloader setup of a kernel.
type BootParticipant ¶
type BootParticipant interface { // SetNextBoot will schedule the snap to be used in the next boot. For // base snaps it is up to the caller to select the right bootable base // (from the model assertion). SetNextBoot() error // ChangeRequiresReboot returns whether a reboot is required to switch // to the snap. ChangeRequiresReboot() bool // Is this a trivial implementation of the interface? IsTrivial() bool }
A BootParticipant handles the boot process details for a snap involved in it.
func Participant ¶
Participant figures out what the BootParticipant is for the given arguments, and returns it. If the snap does _not_ participate in the boot process, the returned object will be a NOP, so it's safe to call anything on it always.
Currently, on classic, nothing is a boot participant (returned will always be NOP).
type Model ¶
Model carries information about the model that is relevant to boot. Note *asserts.Model implements this, and that's the expected use case.
type NameAndRevision ¶
func GetCurrentBoot ¶
func GetCurrentBoot(t snap.Type) (*NameAndRevision, error)
GetCurrentBoot returns the currently set name and revision for boot for the given type of snap, which can be snap.TypeBase (or snap.TypeOS), or snap.TypeKernel. Returns ErrBootNameAndRevisionNotReady if the values are temporarily not established.