DOKK / manpages / debian 12 / depthcharge-tools / depthchargectl.1.en
DEPTHCHARGECTL(1) depthcharge-tools DEPTHCHARGECTL(1)

depthchargectl - Manage the ChromeOS bootloader and its boot images

depthchargectl [options] COMMAND ...

depthchargectl bless [options] [PARTITION | DISK]

depthchargectl build [options] [KERNEL_VERSION]

depthchargectl check [options] IMAGE

depthchargectl config [options] KEY

depthchargectl list [options] [DISK ...]

depthchargectl remove [options] (KERNEL_VERSION | IMAGE)

depthchargectl target [options] [PARTITION | DISK ...]

depthchargectl write [options] [KERNEL_VERSION | IMAGE]

depthchargectl automatically manages the ChromeOS bootloader by building images for the current board and system, writing them to appropriate ChromeOS kernel partitions, prioritizing those partitions accordingly, and setting them as successful on boot. When you have more than one ChromeOS kernel partition, they will be utilized in rotation so that an unsuccessful boot attempt can revert to the last good version.

The KERNEL_VERSION argument is a distro-specific representation of a kernel and usually is the latter part of /boot/vmlinuz-VERSION. The IMAGE argument is a boot image for the ChromeOS bootloader, or a file suspected to be one. DISK should be a physical disk containing a GPT partition table (e.g. /dev/mmcblk0, /dev/sda), but virtual disks (e.g. /dev/dm-0) are resolved to such physical disks if possible. PARTITION must be one of partition devices of a physical disk (e.g /dev/mmcblk0p1, /dev/sda2). The vmlinuz, initramfs and dtb files are as explained in mkdepthcharge(1).

The program's functionality is divided into subcommands:

Sets bootloader-specific flags for a given partition or the currently booted partition as detected from the kern_guid=PARTUUID parameter mkdepthcharge(1) adds to the kernel command line. By default, this marks the partition as successfully booted and the most preferred one, but can disable the partition or make it boot only on the next attempt as well.

Builds a bootable image from the running system for this board, using the latest or a specific kernel version. depthchargectl keeps a database of known ChromeOS boards and how to build bootable images for them. For example, it keeps track of which device-tree file that needs to be included for each ARM board. It also figures out distro-specific information of where the vmlinuz, initramfs and dtb files are located. It uses this information and mkdepthcharge(1) to build this image.

It automatically adds an appropriate root=ROOT kernel command line parameter deduced from /etc/fstab. Higher compression levels for the kernel are automatically tried as necessary, when the firmware supports them.

Retrieves the configured value for a given configuration key, primarily for use in scripts that integrate depthchargectl with the system upgrade process.

Checks if a file is a depthcharge image that can be booted on this board. depthchargectl also keeps track of restrictions on images for each board. For example, most ChromeOS board can boot images up to a specific size, e.g. 32MiB. It checks if its input is in a format the ChromeOS bootloader expects and satisfies these restrictions.

Prints a table of ChromeOS kernel partitions and their bootloader specific GPT flags (i.e. Successful, Priority, Tries). By default, it only searches the physical disks on which the boot and root partitions reside.

Disables partitions that contain a specific image or a specific kernel version. This is most useful when you are removing a kernel version and its modules from your system, and know images built with this kernel will fail to boot from that point on.

Chooses and prints the lowest priority, preferably unsuccessful ChromeOS kernel partition to write a boot image to. By default, searches the same disks as the list subcommand. If a partition is given, it checks if it is an appropriate for a boot image. Tries to avoid the currently booted kernel.

Writes a specific image or builds and writes a kernel-version image to a partition the target subcommand returns, and marks it as bootable once on the next boot. The bless subcommand must be run after a successful boot to make the partiiton permanently bootable, but that is possible to do automatically with the service files provided with this package.

Show a help message and exit.
Print info messages and mkdepthcharge(1) output to stderr.
Print program version and exit.
Root device or mountpoint of the system to work on. If a mounted device is given, its mountpoint is used. Defaults to the currently booted system's root.
Directory to keep temporary files. Normally depthchargectl creates a temporary directory by itself and removes it when it quits. However, if a temporary directory is specified with this option any temporary files will be created under it and will not be deleted.

In addition to its built-in configuration, depthchargectl reads /etc/depthcharge-tools/config and /etc/depthcharge-tools/config.d/* as configuration files to make it adaptable to different boards and systems. The following options allow this configuration to be overridden temporarily.

Additional configuration file to read. This can include changing board properties or adding new boards, which mostly isn't possible to do with command-line options.
Assume depthchargectl is running on the specified board. Normally it tries to detect which board it's running on primarily based on the HWID of the board set by the vendor, among other things.
Directory to store and look for built depthcharge images. By default, set to /boot/depthcharge.
The kernel keyblock file required to sign and verify images. By default, set to /usr/share/vboot/kernel.keyblock.
The public key required to verify images, in .vbpubk format. By default, set to /usr/share/vboot/kernel_subkey.vbpubk.
The private key necessary to sign images, in .vbprivk format. By default, set to /usr/share/vboot/kernel_data_key.vbprivk.

--kernel-cmdline CMD [CMD ...]
Command-line parameters for the kernel. By default, set to "console=tty0 quiet splash". depthchargectl and mkdepthcharge(1) append some other values to this: an appropriate root=ROOT, the kern_guid=%U parameter required for the bless subcommand, noinitrd if --ignore-initramfs is given.

Do not include initramfs in the built images. For some boards, depthchargectl cannot build an image that includes an initramfs so it exits with an error if your OS kernel has a corresponding one. If you know that your OS kernel can boot on this board without an initramfs, you can specify this option to build an initramfs-less image.

Set the specified partition as unbootable. This sets all three of the Successful, Priority, Tries flags to 0.
Set the specified partition to be tried once in the next boot. This sets the Successful flag to 0, Tries flag to 1, and makes sure the Priority flag is the highest one among all the partitions of the disk the specified one is in.
Partition number in the given disk image, for when the positional argument is a disk image instead of a partition block device.

Human-readable description for the image. By default, a string that describes your system with the specified kernel release name, like "Debian GNU/Linux, with Linux 5.10.0-6-arm64".
Root device to add to kernel cmdline. By default, this is acquired from /etc/fstab or a filesystem UUID is derived from the mounted root. If "none" is passed, no root parameter is added.

Compression types to attempt. By default, all compression types that the board supports based on depthchargectl configuration are attempted from lowest to highest compression.

Build timestamp for the image. By default, SOURCE_DATE_EPOCH is used if it's set. If not, the modification date of either the initramfs or vmlinuz is used as an attempt to keep images somewhat reproducible.
Output image to path instead of storing it in the images-dir.

The following options allow one to specify the exact files to be used in building the image, instead of letting depthchargectl deduce them:

--kernel-release NAME
Release name for the kernel to be used in image filename under the images-dir (unless --output is specified).
Kernel executable. Usually /boot/vmlinuz-VERSION by default, but depends on your OS.
Ramdisk image. Usually /boot/initrd.img-VERSION by default, but depends on your OS.
Directory to search device-tree binaries for the board. Usually /boot/dtbs or a directory like /usr/lib/linux-image-VERSION, depends on your OS. dtb files in this dir are searched to find ones matching your board's device-tree compatible string set in configuration.

Device-tree binary files to use instead of searching fdtdir.

Config section to retrieve configured values from. By default, this is the globally default section: depthcharge-tools.
A default value to return if the given config key doesn't exist in the given config section. If a default value is not given, this subcommand prints an error message and exits with nonzero status when the key is missing.

This subcommand takes no specific options.

List partitions on all disks.
Print only the count of partitions.
Don't print column headings.
Comma separated list of columns to output. Supported columns are ATTRIBUTE (or A), SUCCESSFUL (or S), TRIES (or T), PRIORITY (or P) for ChromeOS GPT flags, PATH for the partition device (if exists), DISKPATH (or DISK) for the disk device/image the partition is in, PARTNO for the partition number, and SIZE for the partition size in bytes.

Allow disabling the currently booted partition.

Consider all available disks, instead of considering only disks containing the root and boot partitions.
Allow targeting the currently booted partition.
Only consider partitions larger than this size in bytes. Defaults to 64 KiB to ignore unused partitions in ChromeOS installations.

Allow overwriting the currently booted partition.
Write image to disk even if it cannot be verified by the check subcommand.
Don't modify ChromeOS GPT flags on the partition. Normally, the flags would be set to make the system boot from the newly written partition on the next boot.
Specify a disk or partition device to write to. This device is passed to the target subcommand to determine where exactly to write to.

In general, exits with zero on success and non-zero on failure. Some subcommands return more specified exit statuses:

0
Image built and stored successfully.
1
An error occurred before or during building the image.
3
Can build an image with an initramfs, but it is too big for the board despite using maximum allowed kernel compression. This might be solvable by reducing the initramfs size.
4
Like 3, but without an initramfs or reducing the initramfs size wouldn't make things fit. This might be solvable by reducing the vmlinuz size, perhaps by building a custom kernel.

0
The image passes all checks.
1
Errors unrelated to image checks.
2
The image isn't a readable file.
3
Size of the image is too big for the board.
4
The image cannot be interpreted by vbutil_kernel(1).
5
The image fails the vbutil_kernel(1) signature checks.
6
The image is built with a wrong format for the board.
7
The image is missing device-tree files compatible with the board.

0
A usable partition is given, or a usable partition was chosen from disks. The partition passes the checks and is printed to output.
1
Errors unrelated to partition checks.
2
The partition is not a writable block device.
3
The disk containing the partition is not a writable block device.
4
Cannot parse a partition number from the partition.
5
The partition is not a ChromeOS kernel partition.
6
The partition is the currently booted partition.
7
The partition is smaller than the --min-size argument.

/etc/depthcharge-tools/config
System configuration file. The "Configuration options" explained above can be set here to have them as long-term defaults. It's also possible to modify board properties or add new boards here.
/etc/depthcharge-tools/config.d/*
These files are considered appended to the config file.
/usr/lib/systemd/system/depthchargectl-bless.service
A systemd service that runs the depthchargectl bless on successful boots.
/etc/init.d/depthchargectl-bless
An init service that runs depthchargectl bless on successful boots.
/boot/depthcharge/*.img
The most recently built images for each kernel version.

Get a list of partitions depthchargectl will act on by default.
Build an image for the Samsung Chromebook Plus (v1), using files from and intended to boot with the chroot system mounted at /mnt.
Print the board codename for the detected board.
Print the enable-system-hooks config if it's set, False if not. This specific config key is meant to be a common mechanism which distro packagers can use to let users disable system upgrade hooks that use depthchargectl.
Build, check and write an image for the latest kernel-version of this system to disk while allowing overwriting the currently booted partiiton. You might use this if you only have a single ChromeOS kernel partition, but broken kernels might make your system unbootable.
Write the vmlinux.kpart file to /dev/mmcblk1p1, only if both the image and the partition are valid. Something of this form would be used for writing images to a secondary or external disk.

mkdepthcharge(1), cgpt(1), vbutil_kernel(1)

2022-11-24 v0.6.1