%global commit 5b5844c806d059a65b19b8979595902e2fd72373 %global shortcommit %{sub %{commit} 1 7} %global commitdate 20250807 Name: read-only-root-fs Version: 1.0~git%{commitdate}.%{shortcommit} Release: 1%{?dist} Summary: Files and Scripts for a RO root filesystem License: GPL-2.0-or-later URL: https://github.com/openSUSE/read-only-root-fs Source0: %{url}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz BuildArch: noarch BuildRequires: dracut %dnl BuildRequires: bootloader-rpm-macros? Requires: dracut Requires(post): coreutils Requires(post): rsync Requires(post): gawk Requires(post): btrfs-progs Requires(post): snapper Conflicts: tukit < 5.0.0 %dnl Conflicts: combustion < 1.5 Conflicts: ignition < 2.21.0 %dnl %{update_bootloader_requires} %description Files, scripts and directories to run the system with a read-only root filesystem with nested writable %{_sysconfdir} BTRFS subvolume. This package should never be installed in an already running system! It should only be selected by a system role for a read-only root filesystem with transactional updates. The package will create / modify entries for mounting /etc and /var. Those entries are used by dracut to mount the overlay file systems during the early boot phase. %package volatile Summary: Dracut Module to mount a tmpfs overlay on a RO Root Requires: dracut %description volatile A dracut module which mounts an overlayfs each on /etc and /var, with the upper layer in a tmpfs mount. This is the minimal setup to get a booting system, to have a writable /root or /home, additional fstab entries can be added. %prep %autosetup -p1 -n %{name}-%{commit} %build %install cp -a etc usr %{buildroot} %post # Create /etc subvolume for fresh installations # Exception: The host's file system for KIWI builds may also be btrfs, but for KIWI # (indicator: /.kconfig is present) the script will be called later in disk.sh. if [ "$1" = 1 ] && [ "`findmnt -n -o FSTYPE -l /`" = "btrfs" ] && [ ! -e /.kconfig ]; then %{_libexecdir}/setup-etc-subvol fi if [ ! -e /boot/writable -a "`findmnt -n -o FSTYPE -l /`" = "btrfs" ]; then %{_sbindir}/mksubvolume /boot/writable fi %dnl %{?update_bootloader_refresh_post} %posttrans if [ -f %{_sysconfdir}/zypp/zypp.conf ]; then sed -i 's/^multiversion =.*/multiversion =/g' %{_sysconfdir}/zypp/zypp.conf fi # btrfsmaintainence uses as default "/", but that is read-only. # Change that to /.snapshots/ for var in BTRFS_BALANCE_MOUNTPOINTS BTRFS_SCRUB_MOUNTPOINTS BTRFS_TRIM_MOUNTPOINTS; do grep -q "${var}=\"/\"" /etc/sysconfig/btrfsmaintenance && sed -i "s|${var}=.*|${var}=\"/.snapshots\"|g" /etc/sysconfig/btrfsmaintenance done # Replace ro with ro=vfs for / (boo#1156421) if [ -f %{_sysconfdir}/fstab ] && ! grep -qw "ro=vfs" %{_sysconfdir}/fstab; then gawk -i inplace '$2 == "/" && match($4, /^(.*,)?ro(,.*)?$/, m) { $4 = m[1] "ro=vfs" m[2]; } { print }' %{_sysconfdir}/fstab fi %dnl %{?update_bootloader_posttrans} exit 0 %files %license COPYING %{_libexecdir}/setup-etc-subvol %{_prefix}/lib/dracut/dracut.conf.d/10-read-only-root-fs.conf %dir %{_prefix}/lib/dracut/modules.d/50writable-etc %{_prefix}/lib/dracut/modules.d/50writable-etc/* %{_prefix}/lib/systemd/system-preset/* %dir %{_prefix}/lib/systemd/system/systemd-udevd.service.d %{_prefix}/lib/systemd/system/systemd-udevd.service.d/etcmount.conf %dir %{_prefix}/lib/systemd/system/systemd-remount-fs.service.d %{_prefix}/lib/systemd/system/systemd-remount-fs.service.d/writableagain.conf %dir %{_sysconfdir}/grub.d %config(noreplace) %{_sysconfdir}/grub.d/01_suse_ro_root %files volatile %license COPYING %{_prefix}/lib/dracut/modules.d/99volatile-overlay/ %changelog * Sat Feb 28 2026 Shawn W Dunn - 1.0~git20250807.5b5844c-1 - Initial Packaging