Commit Graph

66 Commits

Author SHA1 Message Date
Fredrik Lönnegren f132230beb Update copyright year (2025)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2025-01-07 16:43:28 +01:00
Loic Devulder 7f707ca021 Add missing Autologin feature
Still not enabled by default, but could be added like any other
features.

Signed-off-by: Loic Devulder <ldevulder@suse.com>
2024-12-03 12:44:21 +01:00
Bernhard M. Wiedemann d9873c8404 Make tar creation deterministic
for that, we sort entries, override owner+group+mtime
and omit ctime+atime
2024-12-02 16:46:09 +01:00
David Cassany 19606359c3 Fix dracut modules dependencies
Signed-off-by: David Cassany <dcassany@suse.com>
2024-11-11 14:58:41 +01:00
Rodolphe de Saint Léger 5b2bb7ab14 Add orange btrfs snapshotter support
Changes:
- ensure that kernel and initrd are relative links
- add 'active_snap' variable to grub (managed by snapshotter)
- add 'root_subpath' variable to grub
- snapper can now be used on orange flavor (see notes)

Notes:
- 'active_snap' and 'root_subpath' allows grub to build a relative path to the kernel and initrd when btrfs_relative_path is not available.
- Snapper works on orange flavor, however it can take several minutes before the daemon initialize in active or passive mode. If elemental upgrade is invoked during this time it will fail.
2024-11-07 19:03:24 +01:00
Fredrik Lönnegren 1898d5db2e Use --strict flag in elemental-setup services
The default behavior has been to hide any errors and only log warnings.
Using the --strict flag will ensure any yip errors are actually
reported.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-11-06 15:01:00 +01:00
David Cassany eb77a4ca92 Update spec dependecies and dracut module dependencies
Signed-off-by: David Cassany <dcassany@suse.com>
2024-11-06 09:59:36 +01:00
David Cassany Viladomat 30a64d70be
Add cloud-init paths of the new root in 'after-*' hooks (#2192)
* Add cloud-init paths of the new root in 'after-*' hooks

This commit enables to run the non chrooted 'after-*' hooks
included in the newly deployed image root. This specially applies to the
install, reset, upgrade and build-disk commands.

Moreover, 'after-disk' command now includes static reference paths to
the new root and working directory, so that those can be used within
the hooks regardless of the choosen output directory.


* Include arm-firwmare feature

This commit introduces an arm-firmware feature adding
the required after-* hooks to ensure the RPi firmware is
copied to the EFI partition.

It could be, eventually, extended to support other boards
and it does not harm systems which are not including RPi
firmware.


* Allow features to be passed as arguments

Signed-off-by: David Cassany <dcassany@suse.com>
2024-09-25 09:47:12 +02:00
David Cassany 5e0a28c63c Do not require network in initrd by default
Signed-off-by: David Cassany <dcassany@suse.com>
2024-09-05 13:20:53 +02:00
David Cassany 75e17df1c5 Bump to v2.1.1 for tests and fix recovery test
Signed-off-by: David Cassany <dcassany@suse.com>
2024-09-05 13:20:53 +02:00
David Cassany Viladomat b1cc863b10
Make RAW disks recovery partition expandable (#2159)
Signed-off-by: David Cassany <dcassany@suse.com>
2024-08-08 10:38:52 +02:00
David Cassany 6c301f2e98 Move mount config file to /run/elemental
Signed-off-by: David Cassany <dcassany@suse.com>
2024-05-10 15:09:08 +02:00
Fredrik Lönnegren 1c89db027a
SELinux relabel on boot (#2074)
In this commit we add selinux support to the mount command.

During mount we put a list of persistent+ephemeral directories in
/run/systemd/extra-relabel.d/elemental.layout in order to make systemd
relabel the directories before loading the policy.

We also try to chroot into the new sysroot and run setfiles using a find
wrapper to set on deepest files first.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-05-10 13:43:49 +02:00
David Cassany c95aa381f1 Define layout with yaml format
Signed-off-by: David Cassany <dcassany@suse.com>
2024-05-08 11:01:45 +02:00
Fredrik Lönnegren d7d208a186
Add branding for live CD (#2065)
The other modes are covered in 03_branding.yaml, but not the live_mode.

This commit adds a short motd and hostname when booting from live CD.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-05-07 16:27:44 +02:00
David Cassany 46a88e108c Change default root password
Signed-off-by: David Cassany <dcassany@suse.com>
2024-05-02 14:29:54 +02:00
David Cassany Viladomat 4d469e7f3a
Enable SELinux for tumbleweed and green (#2052)
* Enable SELinux for tumbleweed and rename it to green

Signed-off-by: David Cassany <dcassany@suse.com>

* Disable SELinux on recovery and refine relabelling

Signed-off-by: David Cassany <dcassany@suse.com>

* Remove k3s-selinux, not needed for examples

Signed-off-by: David Cassany <dcassany@suse.com>

* Improve SELinux labelling

Signed-off-by: David Cassany <dcassany@suse.com>

* Fix unit tests

Signed-off-by: David Cassany <dcassany@suse.com>

---------

Signed-off-by: David Cassany <dcassany@suse.com>
2024-04-29 15:20:36 +02:00
Fredrik Lönnegren dddb716b50
Add autologin feature (#2056) 2024-04-23 17:37:07 +02:00
Fredrik Lönnegren 127fa52814
Snapshottable recovery system (#2032)
* Snapshottable recovery system

Deploy the entire recovery system to the same folder (kernel, initrd and
rootfs).

During upgrade deploy to a transitional folder and then switch it with
the current recovery system and then delete the old one.

This makes sure we clean up old recovery systems and don't risk mixing
systems during upgrade.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-04-05 08:09:32 +02:00
Fredrik Lönnegren 88a9d0cc5b
Change description of boot assessment service (#2037)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-04-03 11:11:27 +02:00
David Cassany d99311339b Wait for relevant elemental init stages
This commit ensures the boot assessment checkers wait for
the network and boot stages of yip. This makes sure
the checkers are executed once cloud-init based config
files are processed.

Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-26 15:53:40 +01:00
Fredrik Lönnegren 5f2cdb0e9f Backwards compatible recovery boot configuration
The recovery system has been changed to extract the kernel/initrd and
bootargs.cfg in order to not rely on loopback devices.

This commit adds backwards compatibility to the grub configuration in
case we have upgraded the bootloader but not the recovery system on a
host.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-03-25 15:06:37 +01:00
David Cassany 1a6026e2fa Iterate over passive snapshots on boot-assessment
This commit prevents falling back to recovery system during the boot
assessment process.

In addition it also sets the boot_assessment to be executed on install
and reset reboots.

Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-25 15:05:09 +01:00
David Cassany Viladomat 80bd8d8171
make configurable boot-assessment checks (#2018)
* make configurable boot-assessment checks

Signed-off-by: David Cassany <dcassany@suse.com>

* Improve EventuallyConnects in tests

Signed-off-by: David Cassany <dcassany@suse.com>

* Fix fallback test

Signed-off-by: David Cassany <dcassany@suse.com>

* Store boot assessment variables in grubenv

This commit refactors the boot-assessment logic to run checks
with a customizable service and to store grub variables in
already existing files in EFI partition and OEM.

Also the EFI partition is made accessible in after-*-chroot
hooks. This makes easier to write and manage files in EFI
partition if needed (e.g. grub_oem_env variable file), without
having to relay on mounts or remounts.

Signed-off-by: David Cassany <dcassany@suse.com>

---------

Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-22 14:11:04 +00:00
David Cassany 4fb44d230a Fix passive snapshots listing in grub.cfg
Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-21 13:40:17 +01:00
Fredrik Lönnegren d61a24c707
Extract recovery kernel (#2016)
* Default recovery system to squashfs

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Refactor build-iso

Refactors build-iso command to use the new DeployRecoverySystem method.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Refactor install command

Use DeployRecoverySystem to deploy the recovery system.

Needs some changes to grub.cfg to be fully compatible and also extracts
the bootargs.cfg file into the recovery partition.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Refactor build-disk command

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Refactor upgrade-recovery command

This commit changes the DeployRecoverySystem method to remove any
conflicting boot artifacts before copying the new files.

Also adds power and squashfs compression flags to the command.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

---------

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-03-20 10:24:08 +01:00
Fredrik Lönnegren a2c4f0b3b0
Change location of bootargs.conf (#2013)
Use the same location as grub.conf, /etc/elemental.

The grub config is backwards compatible and tries to source from
/etc/cos/bootargs.conf as well.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-03-15 14:48:22 +00:00
Fredrik Lönnegren 9231c8f3e0
Remove deprecated feature immutable-rootfs (#2007)
* Remove deprecated feature immutable-rootfs

Immutable-rootfs is deprecated in favor of elemental-rootfs feature.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Fix flaky downgrade test

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

---------

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-03-13 15:27:05 +00:00
David Cassany Viladomat c05f5d4913
bump elemental-toolkit to v2 (#1969)
* bump elemental-toolkit to v2

Signed-off-by: David Cassany <dcassany@suse.com>

* Move pkg/types/v2 to simply pkg/types

This commit leaves the code with a single set of types
and in refers to it as the types packge instead of
v1 or v2.

For the time being we do not foresee managing more
than one single major version of type within the
same code.

Signed-off-by: David Cassany <dcassany@suse.com>

* Stop referring to mocks package as v2mock in favor of simply 'mocks'

Signed-off-by: David Cassany <dcassany@suse.com>

* Fix leftovers after rebase

Signed-off-by: David Cassany <dcassany@suse.com>

---------

Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-08 09:14:56 +01:00
David Cassany 744e9fdd9e Align sysroot mount options with SLE Micro, which in turn is applying default mount options
Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-07 15:45:31 +01:00
David Cassany Viladomat c4bea710cd
Do not migrate legacy images if snapshots are already present (#1990)
* Do not migrate legacy images if snapshots are already present

This commit prevents executing the legacy images migration logic
if snapshotter already finds available snapshots. This mostly
means the migration was already executed and legacy images
had already a chance to be converted into snapshots.

* Fix btrfs snapshotter image variable

Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-06 10:10:17 +01:00
David Cassany a7fec29f67 Image variable includes full image path already
Signed-off-by: David Cassany <dcassany@suse.com>
2024-03-05 14:52:57 +01:00
David Cassany Viladomat 9538960857
Fix grub setup to properly set fallback (#1981)
* Fix grub setup to properly set fallback
* Do not modify recovery in any way unless it is updated

Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-28 11:50:38 +01:00
David Cassany Viladomat ab63f5644d
Fix regression introduced in 547cb932 (#1977)
Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-27 09:27:16 +01:00
David Cassany 547cb9320d Ensure /run/elemental/efi is RW for upgrades
Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-26 14:08:50 +01:00
David Cassany Viladomat e04b8c23a0
Make snapshotter root dynamic based on the reported mountpoint (#1971)
* Make snapshotter root dynamic based on the reported mountpoint
* Add state partition as a InitSnapshotter parameter
* Fix build-disk command and unit tests

Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-26 12:13:11 +01:00
David Cassany Viladomat 8f802fa84b
Btrfs snapshotter implementation (#1957)
* Implementation of Btrfs snapshotter
* Btrfs based examples
* Refined and adapt features
* Update build-disk to new snapshotter and prevent including State partition on expandable images
* Remove /oem bind mount in initramfs, already mounted by mount command
* Adapt unit tests
* Add mount command unit tests
* Make grubfallback test more generic
* Adding btrfs snapshotter unit tests and fixing default snapshotter config constructor
* Add utils test
* Fix upgrade ENV variables mapping
* Include transactional-update package in example
* Fix persistent bind mounts
* Make sure state is RW mounted upgrading from legacy
* Remove unused passive symlinks for loopdevice
* Fix upgrade from older version

Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-21 14:04:05 +01:00
Fredrik Lönnegren e4c00e0a6a
Move elemental services to /etc (#1962)
Move elemental services to /etc

Move elemental-setup-* and elemental-rootfs services from /usr/lib/systemd/system to /etc/systemd/system.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-02-19 16:29:16 +01:00
Fredrik Lönnegren ca17862e39
Embed file permissions for features (#1961)
* Generate tarballs

This commit generates tarballs for each feature and embeds that in the
elemental binary.

The tarballs are generated before build using 'go generate ./...' and
are not checked in to source control.

When a feature is installed using elemental init the tarball will be extracted
to the filesystem.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-02-19 12:34:06 +00:00
David Cassany 7dd54878da Umount OEM before switching root
Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-13 13:01:40 +01:00
Fredrik Lönnegren a5439f636f Add back the BindPath for /oem
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-02-06 15:02:58 +01:00
Fredrik Lönnegren c9db7b1084
Bump yip to v1.4.10 (#1926)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-02-06 14:28:14 +01:00
Fredrik Lönnegren af89ac6d7f
Remove BindMount for /oem in initramfs stage (#1934) 2024-02-06 11:25:56 +01:00
David Cassany Viladomat 4cab6a0eae
Refactor to switch to snapshotter interface (#1906)
* Refactor to switch to snapshotter interface

This commit adopts snapshotter interface in install,
reset and upgrade commands. The change implies changes
to the respective specs, grub configuration and dracut
modules.

This commit also changes the behavior of recovery system
upgrades. Now recovery upgrades are an optional step
of a system upgrade. Recovery image can't be upgraded
without upgrading the active system.

Finally build-disk command is also changed to be better
aligned with upgrade and install procedures. Expandable
disks are an unprivileged build and non expandable ones
require privileges as they relay on snapshotter.

* Attempting to fix integration tests

* Adding a migration path from legacy deployments

* Omit /etc/resolv.conf for dir:// paths

* Adaptations after rebase

* Make sure we also mount EFI in upgrades if it was not already mounted

* Default maximum number of snapshots is 2

* Upgrade grub to EFI partition

* Improve recovery management

* Recovery back to ext2 by default

* Adapt upgrade after rebase


Signed-off-by: David Cassany <dcassany@suse.com>
2024-01-31 11:03:24 +01:00
David Cassany 22c7e8a19d Make mount setup more dynamic based on detected partitions
Signed-off-by: David Cassany <dcassany@suse.com>
2024-01-29 08:26:58 +01:00
David Cassany d423036408 Imporve support for old boot arguments
Signed-off-by: David Cassany <dcassany@suse.com>
2024-01-25 10:32:39 +01:00
Fredrik Lönnegren cfcae7c6bb Bind mount /oem in elemental-setup-initramfs
Bind /oem into /sysroot/oem when running elemental-setup-initramfs to
enable running initramfs stages from config files in oem partition.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-24 21:24:54 +01:00
Fredrik Lönnegren 56b2723919
Install grub.cfg into EFI System Partition (#1904)
* Install grub.cfg into EFI System Partition

Change the bootloader install logic to install the grub.cfg into the EFI
System Partition (ESP).

This needs some changes to how root is set in the grub.cfg as well as
moving grub_oem_env file to ESP when created in install/reset/upgrade
command.

Install grub-modules to both EFI/BOOT and EFI/ELEMENTAL.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-22 18:46:36 +01:00
Fredrik Lönnegren 0bf2c64230 Move grub-config to /etc/elemental
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-10 17:56:09 +01:00
Fredrik Lönnegren 0f4746efea Change default rootfs feature
Use the new elemental-rootfs and elemental-sysroot instead of
immutable-rootfs.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-09 15:56:57 +01:00