How to use the command 'rpm-ostree' (with examples)

How to use the command 'rpm-ostree' (with examples)

The rpm-ostree command is a powerful tool used in systems that utilize a hybrid approach for managing operating system images and packages. It combines features of both immutability and flexibility by integrating the OSTree model with traditional package management. This allows administrators to maintain and modify system images, manage deployments, customize packages, apply filesystem overlays, and control boot configurations. With rpm-ostree, users can manage system updates and deployment states efficiently, ensuring systems remain secure and consistent.

Use case 1: Show rpm-ostree deployments in the order they will appear in the bootloader

Code:

rpm-ostree status

Motivation: This use case is invaluable when you need to review the various deployments available on your system. It gives you an overview of the current state and changes in your system, aiding in decision-making regarding boot configurations. Understanding which deployment will be booted next is critical for troubleshooting and planning system updates.

Explanation:

  • rpm-ostree: Invokes the rpm-ostree command to interact with system deployments.
  • status: The status argument provides a detailed summary of the current system state, including details about the current deployment and any others available in the boot list.

Example output:

State: idle
Deployments:
  ostree://fedora:fedora/37/x86_64/silverblue
                   Version: 37.20230807.0 (2023-08-07T00:00:00Z)
                BaseCommit: e4391b74eef106b055f6dc9d4f44f7bb1c68d66569e5fg7332d8
              GPGSignature: Valid signature by <gpg-key-id>
  ostree://fedora:fedora/37/x86_64/silverblue
                   Version: 37.20230702.0 (2023-07-02T03:05:21Z)
                BaseCommit: c3a9b26093c62977898fbee8396998875c200ffa5ccdfd050
              GPGSignature: Valid signature by <gpg-key-id>

Use case 2: Show packages which are outdated and can be updated

Code:

rpm-ostree upgrade --preview

Motivation: This command is particularly useful when you want to assess the potential updates available for your system without actually applying them. It provides a preview of what packages will be upgraded, allowing for informed planning before executing an actual upgrade. This can help avoid unexpected changes and minimize system disruption.

Explanation:

  • rpm-ostree: Invokes the rpm-ostree command-line tool for managing system deployments.
  • upgrade: Indicates the intention to upgrade the system.
  • --preview: This option allows the user to view the list of available updates without actually applying them, offering a valuable snapshot to manage updates strategically.

Example output:

Available updates:
glibc 2.37-3.fc37 -> 2.37-4.fc37
kernel 5.15.6-200.fc35 -> 5.17.1-200.fc37
...

Use case 3: Prepare a new ostree deployment with upgraded packages and reboot into it

Code:

rpm-ostree upgrade --reboot

Motivation: This command is essential for ensuring your system remains up-to-date with minimal downtime. By preparing a new deployment with the latest package upgrades and then immediately rebooting into it, you ensure that your system security and functionality are maintained without manual intervention.

Explanation:

  • rpm-ostree: Executes the rpm-ostree tool, interacting with system packages and deployments.
  • upgrade: Signals the system to perform an upgrade of existing packages.
  • --reboot: Automatically reboots the system into the new deployment once the upgrade process is completed, streamlining the upgrade operation.

Example output:

Resolving dependencies... done
Applying upgrades... done
Upgraded:
  glibc 2.37-3.fc37 -> 2.37-4.fc37
  kernel 5.15.6-200.fc35 -> 5.17.1-200.fc37

Transaction complete. Reboot to start using the new deployment.

Use case 4: Reboot into the previous ostree deployment

Code:

rpm-ostree rollback --reboot

Motivation: Rolling back to a previous deployment can be a lifesaver in situations where an upgrade leads to instability or unintended changes. This command enables quick recovery by rebooting the system into a previously-saved, functioning deployment state, reducing downtime and allowing further troubleshooting or testing without immediate pressure.

Explanation:

  • rpm-ostree: Calls the rpm-ostree tool for package and deployment management.
  • rollback: Instructs the system to roll back to the previous deployment.
  • --reboot: Ensures that once the rollback process is completed, the system automatically reboots into the restored deployment, simplifying the rollback process and minimizing manual intervention.

Example output:

Marked deployment 0 as pending for rollback
Will automatically rollback on next reboot. Rebooting now...

Use case 5: Install a package into a new ostree deployment and reboot into it

Code:

rpm-ostree install package --reboot

Motivation: This command is useful when you need to install new software while ensuring that the system remains consistent with the atomic update model. It prepares a new system deployment with the specified package installed and reboots into it, blending installation with seamless system updates.

Explanation:

  • rpm-ostree: The tool used for managing system packages and deployment layers.
  • install: This option specifies that a package should be installed into the system.
  • package: The name of the package you’d like to install, such as vim or httpd.
  • --reboot: After creating the new deployment with the installed package, the system reboots to activate the changes.

Example output:

Resolving dependencies... done
Found: vim-8.2.2875-6.fc37.x86_64

Downloading packages... done
Installing vim-8.2.2875-6.fc37... done

Transaction complete. Rebooting now to apply changes.

Conclusion

The rpm-ostree command is an essential tool for anyone managing deployments on systems that leverage the ‘ostree’ and ‘rpm’ technologies. With its capabilities ranging from viewing deployment states to installing new packages in a controlled environment, rpm-ostree empowers administrators to maintain system consistency and security while providing the flexibility needed for tailored system configurations. Understanding and using these commands ensure efficient management of system updates, rollbacks, and package installations.

Related Posts

Exploring the 'xman' Command (with examples)

Exploring the 'xman' Command (with examples)

The xman command serves as a manual page viewer specifically designed for the X Window System.

Read More
How to Use the Command 'date' (with Examples)

How to Use the Command 'date' (with Examples)

The date command is a versatile tool in Unix-like operating systems that allows users to retrieve, format, or even modify the current system date and time settings.

Read More
Exploring the Use Cases of 'add-apt-repository' Command (with examples)

Exploring the Use Cases of 'add-apt-repository' Command (with examples)

The add-apt-repository command is a valuable tool for users of Debian-based Linux distributions, such as Ubuntu, allowing them to add or remove repositories for their package management system.

Read More