Git Product home page Git Product logo

fedora-immutable-cheatsheet's Introduction

fedora-immutable-cheatsheet

A cheatsheet for immutable fedora variants, usually about ostree and rpm-ostree

System files health checking

Finding all damaged objects. --delete flag will delete corrupted files and mark commits with damaged files as "partial", which then allow to redownload it.

ostree fsck -a

Current deployment status

rpm-ostree status

Emergency fallback

booting previous deployment

  1. Boot into the last booted deployment before the currently booted deployment, and make it your default deployment
rpm-ostree rollback
  1. Make a specific deployment your default deployment, 0 is the deployment index
ostree admin set-default 0

falling back to any previous commit of the system branch

  1. Download last 5 commits (parameter --commit-metadata-only is optional but makes things faster)
ostree pull --commit-metadata-only --depth 5 fedora fedora/38/x86_64/kinoite
  1. (Optionally) pin current deployment if there is chance of need to return to it. 0 is index of current deployment. to list deploymends run rpm-ostree status or ostree admin status
ostree admin pin 0
  1. List downloaded commits to choose the best one, basing on the timestamp or anything elese
ostree log fedora:fedora/38/x86_64/kinoite
  1. Deploy selected commit using its hash (or version, like 38.20231008.0)
rpm-ostree deploy 520e744c643b85fd14817a3eb948f200e7dec902cad4157e411dfeda2c6d7aab
  1. Reboot into the new deoloyment (to see it before reboot, run rpm-ostree status)

  2. (Optionally) unpin previously pinned deployment (id will be 1 if it is listed as the one before currently booted one)

ostree admin pin -u 1

Rebase into different tree (also for switching flavors of the distro)

  1. List trees of the ostree repository (fedora example)
ostree remote summary fedora
  1. Rebase the system into the selected tree
rpm-ostree rebase fedora:fedora/39/x86_64/kinoite
  1. reboot into the new deployment

cleaning

Main tool for cleanup is rpm-ostree cleanup command. To see all options run:

rpm-ostree cleanup --help

Full cleanup (including all deployments other than currently deployed)

rpm-ostree cleanup -p -b -r -m

ostree also have cleaning tool

ostree prune

Managing packages deployed with system

Adding package fzf to the (new) deployment

rpm-ostree install fzf

Removing packgage that was additionally installed

rpm-ostree remove fzf

Removing package that is in the system by default

rpm-ostree override remove firefox

Restore default package that was removed with override

rpm-ostree override reset firefox

Other

Allow system modification

Temporarily

rpm-ostree usroverlay --transient

Make the changes to /usr persist reboots

rpm-ostree usroverlay --hotfix

encrypted BTRFS on ssd-like disk maintenance/health

It is very important for performance to have trimming working. To test it run the below to trim all mounted filesystems (can take long time, like over 10,20 minutes) (if root disk is not trimmed, it have discard not enabled at some level):

fstrim -av

If trimming is not working, check the below:

  • /etc/crypttab if it have discard set for root
  • discard=async, discard=sync, or discard flags set in /etc/fstab
  • lsblk -o +DISC-GRAN,DISC-MAX - the additional columns should have non-zero values
  • cryptsetup luksDump /dev/nvme0n1p3 - if flag allow-discards is set (optional but best way to make cryptsetup allow discards by default)

Setting performance improving flags on luks volume:

cryptsetup refresh \
    --allow-discards \
    --perf-no_read_workqueue \
    --perf-no_write_workqueue \
        --persistent \
            /dev/mapper/<disk>

Arch wiki about workqueues: https://wiki.archlinux.org/title/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance

Recommended flags for btrfs volume mounting (compression flag optional, I guess):

noatime,space_cache=v2,discard=async,compress-force=zstd:1

If for some reason space_cache is not set properly on volume mount, do this , (fs need to be unmounted):

  • clear any v1 and v2 space_cache
  • mount with space_cache=v2 flag
  • check if flag is set correctly (maybe also create some file there?)
btrfs check --clear-space-cache v1 /dev/mapper/<device>
btrfs check --clear-space-cache v2 /dev/mapper/<device>

mount -o space_cache=v2 /dev/mapper/<device> /mnt
mount | grep space_cache
echo "hello" > /mnt/some/path/file.txt
umount /mnt

fedora-immutable-cheatsheet's People

Contributors

szwendacz99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

senses3

fedora-immutable-cheatsheet's Issues

Add ostree set-default to the list

Say you have 3 OSTree deployments,

State: idle
AutomaticUpdates: stage; rpm-ostreed-automatic.timer: no runs since boot
Deployments:
โ— ostree-image-signed:docker://ghcr.io/ublue-os/kinoite-main:39
                   Digest: sha256:8c082c3f5a9ef25185eca3f0bac1839615bdce32b741b7d3cde74a446d51ce2d
                  Version: 39.20231224.0 (2023-12-24T15:07:37Z)
      RemovedBasePackages: firefox firefox-langpacks 121.0-2.fc39
          LayeredPackages: epson-inkjet-printer-escpr fish
            LocalPackages: fcitx-openbangla-3.0.0-1.fc39.x86_64

  ostree-image-signed:docker://ghcr.io/ublue-os/silverblue-main:39
                   Digest: sha256:7d2ccfd745d84a80eabcd85c7e4b4b18b0c768e2c5487ede83e25e872d1dd83b
                  Version: 39.20231226.0 (2023-12-26T15:05:30Z)
      RemovedBasePackages: firefox firefox-langpacks 121.0-2.fc39
          LayeredPackages: epson-inkjet-printer-escpr fish
            LocalPackages: fcitx-openbangla-3.0.0-1.fc39.x86_64 ibus-openbangla-3.0.0-1.fc39.x86_64
                   Pinned: yes

  ostree-image-signed:docker://ghcr.io/ublue-os/kinoite-main:39
                   Digest: sha256:8156739c85e3564bc034ae9a77e17e3073dbefd043b2dda976af5dfe8cc72053
                  Version: 39.20231212.0 (2023-12-12T15:06:32Z)
      RemovedBasePackages: firefox firefox-langpacks 120.0.1-1.fc39
          LayeredPackages: epson-inkjet-printer-escpr fish
            LocalPackages: fcitx-openbangla-3.0.0-1.fc39.x86_64
                   Pinned: yes

Deployment 39.20231226.0 has the index number of 0, thus everytime my laptop boots, it will boot into 39.20231226.0 by default unless I select another deployment from the GRUB menu.
If an user wishes to boot into another deployment, say 39.20231212.0 by default, it can be annoying to select that specific deployment in the GRUB menu everytime their laptop/PC boots

The way to select which deployment boots by default can be changed with the command
sudo ostree admin set-default <INDEX>

I saw that your documentation was missing this command, I believe it would be a useful addition to the documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.