Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename initoverlayfs-setup to initoverlayfs #70

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fw -> bootloader -> kernel -> mini-initramfs --------------> initoverlayfs -> ro

fw -> bootloader -> kernel -> init ------------------------------------------------>
|
`-initoverlayfs-setup-+
`-initoverlayfs-+
```

# Why use initoverlayfs?
Expand All @@ -45,7 +45,7 @@ Conversely, the initoverlayfs approach proposes a solution: dividing the initram

This division entails segregating the initramfs image into two distinct components.

The first component (initramfs) contains init, kernel modules, udev-rules and an initoverlayfs-setup tool, responsible for setting up and mounting initoverlayfs. Then we switches to the second component (initoverlayfs), containing all additional kernel modules and essential files required to support the Linux boot process.
The first component (initramfs) contains init, kernel modules, udev-rules and an initoverlayfs tool, responsible for setting up and mounting initoverlayfs. Then we switches to the second component (initoverlayfs), containing all additional kernel modules and essential files required to support the Linux boot process.

This scalable approach moves a significant portion on the initial filesystem content to initoverlayfs which is more scalable as it does on-demand decompression.

Expand Down Expand Up @@ -196,10 +196,10 @@ To validate whether the new image has been successfully loaded after the reboot,
# journalctl -b -o short-monotonic | grep -i initoverlayfs
[ 4.949129] fedora systemd[1]: Queued start job for default target pre-initoverlayfs.target.
[ 5.526459] fedora systemd[1]: Starting pre-initoverlayfs.service - pre-initoverlayfs initialization...
[ 9.179469] fedora initoverlayfs-setup[193]: bootfs: {"UUID=1a3a6db4-a7c2-43e5-bed5-9385f26c68ff", "bootfs UUID=1a3a6db4-a7c2-43e5-bed5-9385f26c68ff"}, bootfstype: {"ext4", "bootfstype ext4"}, fs: {"(null)", "(null)"}, fstype: {"(null)", "(null)"}
[ 9.179469] fedora initoverlayfs-setup[193]: fork_execlp("udevadm")
[ 9.179469] fedora initoverlayfs-setup[193]: forked 199 fork_execlp
[ 9.179469] fedora initoverlayfs-setup[193]: mount("/boot", "/initoverlayfs/boot", "ext4", MS_MOVE, NULL) 2 (No such file or directory)
[ 9.179469] fedora initoverlayfs[193]: bootfs: {"UUID=1a3a6db4-a7c2-43e5-bed5-9385f26c68ff", "bootfs UUID=1a3a6db4-a7c2-43e5-bed5-9385f26c68ff"}, bootfstype: {"ext4", "bootfstype ext4"}, fs: {"(null)", "(null)"}, fstype: {"(null)", "(null)"}
[ 9.179469] fedora initoverlayfs[193]: fork_execlp("udevadm")
[ 9.179469] fedora initoverlayfs[193]: forked 199 fork_execlp
[ 9.179469] fedora initoverlayfs[193]: mount("/boot", "/initoverlayfs/boot", "ext4", MS_MOVE, NULL) 2 (No such file or directory)
[ 9.216158] fedora systemd[1]: Finished pre-initoverlayfs.service - pre-initoverlayfs initialization.
[ 9.235546] fedora systemd[1]: Starting pre-initoverlayfs-switch-root.service - Switch Root pre-initoverlayfs...
[ 12.207906] fedora systemd[1]: pre-initoverlayfs-switch-root.service: Deactivated successfully.
Expand Down
2 changes: 1 addition & 1 deletion initoverlayfs-setup.c → initoverlayfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _GNU_SOURCE
#endif

#include "initoverlayfs-setup.h"
#include "initoverlayfs.h"
#include <assert.h>
#include <dirent.h>
#include <err.h>
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions initoverlayfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Requires: dracut

%build
RPM_OPT_FLAGS="${RPM_OPT_FLAGS/-flto=auto /}"
gcc ${RPM_OPT_FLAGS} initoverlayfs-setup.c -o initoverlayfs-setup
gcc ${RPM_OPT_FLAGS} initoverlayfs.c -o initoverlayfs

%install
install -D -m755 bin/initoverlayfs-install ${RPM_BUILD_ROOT}/%{_bindir}/initoverlayfs-install
install -D -m755 initoverlayfs-setup ${RPM_BUILD_ROOT}/%{_sbindir}/initoverlayfs-setup
install -D -m755 initoverlayfs ${RPM_BUILD_ROOT}/%{_sbindir}/initoverlayfs
install -D -m755 lib/dracut/modules.d/81initoverlayfs/module-setup.sh ${RPM_BUILD_ROOT}/%{_prefix}/lib/dracut/modules.d/81initoverlayfs/module-setup.sh
install -D -m644 lib/systemd/system/pre-initoverlayfs.target ${RPM_BUILD_ROOT}/%{_prefix}/lib/systemd/system/pre-initoverlayfs.target
install -D -m644 lib/systemd/system/pre-initoverlayfs.service ${RPM_BUILD_ROOT}/%{_prefix}/lib/systemd/system/pre-initoverlayfs.service
Expand All @@ -37,7 +37,7 @@ install -D -m644 lib/systemd/system/pre-initoverlayfs-switch-root.service ${RPM_
%doc README.md
%attr(0755,root,root)
%{_bindir}/initoverlayfs-install
%{_sbindir}/initoverlayfs-setup
%{_sbindir}/initoverlayfs
%{_prefix}/lib/dracut/modules.d/81initoverlayfs/
%{_prefix}/lib/systemd/system/pre-initoverlayfs.target
%{_prefix}/lib/systemd/system/pre-initoverlayfs.service
Expand Down
4 changes: 2 additions & 2 deletions integration/tests/boot-validation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set -x

if [ "${TMT_REBOOT_COUNT}" == "1" ];then
echo -n "machine is up"
storage_init=$(journalctl -r | grep "init -> usr/sbin/initoverlayfs-setup" | tail -1)
storage_init=$(journalctl -r | grep "init -> usr/sbin/initoverlayfs" | tail -1)
exit_code="$?"
if [ "$exit_code" != "0" ]; then
echo -n "initoverlayfs, initoverlayfs-setup messages not found in journal"
echo -n "initoverlayfs, initoverlayfs messages not found in journal"
exit "$exit_code"
fi
echo -n "initoverlayfs boot complete"
Expand Down
2 changes: 1 addition & 1 deletion lib/dracut/modules.d/81initoverlayfs/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ depends() {
}

install() {
inst_multiple -o /etc/initoverlayfs.conf /usr/sbin/initoverlayfs-setup \
inst_multiple -o /etc/initoverlayfs.conf /usr/sbin/initoverlayfs \
"$systemdsystemunitdir/pre-initoverlayfs.target" \
"$systemdsystemunitdir/pre-initoverlayfs.service" \
"$systemdsystemunitdir/pre-initoverlayfs-switch-root.service"
Expand Down
2 changes: 1 addition & 1 deletion lib/systemd/system/pre-initoverlayfs.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ After=systemd-journald.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/initoverlayfs-setup
ExecStart=/usr/sbin/initoverlayfs --systemd
StandardInput=null
StandardOutput=journal+console
StandardError=journal+console
Expand Down
12 changes: 6 additions & 6 deletions scripts/build-bin-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -ex

clang++ -o a -O3 -pedantic -fno-exceptions -fno-rtti -Wall -Wextra -Werror -Wno-write-strings -Wno-language-extension-token -Wno-deprecated -std=c++20 initoverlayfs-setup.c &
g++ -o b -O0 -ggdb -pedantic -fno-exceptions -fno-rtti -Wall -Wextra -Werror -Wno-write-strings -Wno-language-extension-token -std=c++20 initoverlayfs-setup.c &
clang -o c -O3 -pedantic -fno-exceptions -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs-setup.c &
clang++ -o a -O3 -pedantic -fno-exceptions -fno-rtti -Wall -Wextra -Werror -Wno-write-strings -Wno-language-extension-token -Wno-deprecated -std=c++20 initoverlayfs.c &
g++ -o b -O0 -ggdb -pedantic -fno-exceptions -fno-rtti -Wall -Wextra -Werror -Wno-write-strings -Wno-language-extension-token -std=c++20 initoverlayfs.c &
clang -o c -O3 -pedantic -fno-exceptions -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs.c &

if [ -e /usr/lib/rpm/redhat/redhat-hardened-cc1 ]; then
gcc -O2 -fanalyzer -fno-exceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection initoverlayfs-setup.c -o d &
gcc -O2 -fanalyzer -fno-exceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection initoverlayfs.c -o d &
else
gcc -O2 -fanalyzer -fno-exceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection initoverlayfs-setup.c -o d &
gcc -O2 -fanalyzer -fno-exceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection initoverlayfs.c -o d &
fi

wait

gcc -O0 -fno-exceptions -ggdb -pedantic -Wall -Wextra -Werror -fanalyzer initoverlayfs-setup.c
gcc -O0 -fno-exceptions -ggdb -pedantic -Wall -Wextra -Werror -fanalyzer initoverlayfs.c
sudo valgrind ./a.out

26 changes: 13 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ set -ex

cd ~/git/initoverlayfs
if [ "$2" = "initramfs" ]; then
sudo clang -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs-setup.c -o /usr/sbin/initoverlayfs-setup
sudo gcc -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token -fanalyzer initoverlayfs-setup.c -o /usr/sbin/initoverlayfs-setup
sudo clang -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs.c -o /usr/sbin/initoverlayfs
sudo gcc -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token -fanalyzer initoverlayfs.c -o /usr/sbin/initoverlayfs

sudo cp -r lib/dracut/modules.d/81initoverlayfs-setup /usr/lib/dracut/modules.d/
sudo cp -r lib/dracut/modules.d/81initoverlayfs /usr/lib/dracut/modules.d/
sudo cp -r lib/dracut/modules.d/81kamoso /usr/lib/dracut/modules.d/
du -sh /boot/initramfs*
sudo dd if=/dev/urandom of=/usr/bin/random-file count=1 bs="$1"
Expand All @@ -110,14 +110,14 @@ fi
UNLOCK_OVERLAYDIR="$DIR_TO_DUMP_INITRAMFS"
extract_initrd_into_initoverlayfs
sudo mkdir -p "$UNLOCK_OVERLAYDIR/upper" "$UNLOCK_OVERLAYDIR/work"
# sudo valgrind /usr/sbin/initoverlayfs-setup
# sudo ln -sf initoverlayfs-setup $DIR_TO_DUMP_INITRAMFS/usr/sbin/init
# sudo ln -sf usr/bin/initoverlayfs-setup $DIR_TO_DUMP_INITRAMFS/init
# sudo valgrind /usr/sbin/initoverlayfs
# sudo ln -sf initoverlayfs $DIR_TO_DUMP_INITRAMFS/usr/sbin/init
# sudo ln -sf usr/bin/initoverlayfs $DIR_TO_DUMP_INITRAMFS/init
if [ $fs == "erofs" ]; then
sudo mkfs."$fs" /boot/initoverlayfs-"$release".img /run/initoverlayfs/
fi
#sudo losetup -fP /boot/initoverlayfs-"$release".img
# ln -s init /usr/sbin/initoverlayfs-setup
# ln -s init /usr/sbin/initoverlayfs
initramfs=$(sudo ls /boot/initramfs-* | grep -v rescue | tail -n1)
sudo du -sh "$initramfs"
#sudo dracut -v -f --strip $initramfs -M
Expand All @@ -129,14 +129,14 @@ sudo rm -rf /usr/lib/dracut/modules.d/*pre-initoverlayfs

set -x

sudo clang -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs-setup.c -o /usr/sbin/initoverlayfs-setup
sudo gcc -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token -fanalyzer initoverlayfs-setup.c -o /usr/sbin/initoverlayfs-setup
#sudo dracut $decompressor_dracut -v -m "kernel-modules udev-rules initoverlayfs-setupramfs" -f --strip -M -o "nss-softokn bash i18n kernel-modules-extra rootfs-block dracut-systemd usrmount base fs-lib shutdown systemd systemd-initrd" # systemd-initrd (req by systemd)
sudo clang -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token initoverlayfs.c -o /usr/sbin/initoverlayfs
sudo gcc -O3 -pedantic -Wall -Wextra -Werror -Wno-language-extension-token -fanalyzer initoverlayfs.c -o /usr/sbin/initoverlayfs
#sudo dracut $decompressor_dracut -v -m "kernel-modules udev-rules initoverlayfsramfs" -f --strip -M -o "nss-softokn bash i18n kernel-modules-extra rootfs-block dracut-systemd usrmount base fs-lib shutdown systemd systemd-initrd" # systemd-initrd (req by systemd)
boot_partition=$(mount | grep "on /boot type" | awk '{print $1}')
sudo /bin/bash -c "echo -e \"bootfs $boot_partition\nbootfstype ext4\n\" > /etc/initoverlayfs.conf"
sudo dracut $decompressor_dracut -v -f --strip -M
sudo du -sh /boot/initramfs*
sudo lsinitrd | grep "initoverlayfs-setup"
sudo lsinitrd | grep "initoverlayfs"
sudo du -sh "$initramfs"
# sed -i '/^initrd /d' /boot/loader/entries/9c03d22e1ec14ddaac4f0dabb884e434-$release.conf

Expand All @@ -145,7 +145,7 @@ bls_file=$(sudo ls /boot/loader/entries/ | grep -v rescue | tail -n1)
#uuid=$(grep "boot.*ext4" /etc/fstab | awk '{print $1}' | sed s/UUID=//g)
#sudo sed -i '/boot.*ext4/d' /etc/fstab
sudo systemctl daemon-reload
#sudo sed -i "s#options #options initoverlayfs=UUID=$uuid initoverlayfstype=ext4 rdinit=/usr/sbin/initoverlayfs-setup #g" /boot/loader/entries/$bls_file
#sudo sed -i "s#options #options initoverlayfs=$boot_partition initoverlayfstype=ext4 rdinit=/usr/sbin/initoverlayfs-setup #g" /boot/loader/entries/$bls_file
#sudo sed -i "s#options #options initoverlayfs=UUID=$uuid initoverlayfstype=ext4 rdinit=/usr/sbin/initoverlayfs #g" /boot/loader/entries/$bls_file
#sudo sed -i "s#options #options initoverlayfs=$boot_partition initoverlayfstype=ext4 rdinit=/usr/sbin/initoverlayfs #g" /boot/loader/entries/$bls_file
sudo sed -i "s/ quiet/ console=ttyS0/g" /boot/loader/entries/$bls_file
sudo cat /boot/loader/entries/$bls_file
Loading