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

Make /etc a subvolume that needs no mounting #59

Merged
merged 3 commits into from
Jul 24, 2024
Merged
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
34 changes: 34 additions & 0 deletions __frzr-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,40 @@ main() {
tar xfO ${IMG_FILE} | btrfs receive --quiet ${DEPLOY_PATH}
fi

if [ -d "${SUBVOL}/etc" ]; then
echo "System image ${NAME} will use the /etc overlay"
else
echo "System image ${NAME} will use an /etc subvolume"

# unlock the subvolume to be able to create a nested subvolume
btrfs property set -f -ts "${SUBVOL}/" ro false

# create the nested subvolume for /etc
btrfs subvolume create "${SUBVOL}/etc"

# create the nested subvolume for /snapshots
btrfs subvolume create "${SUBVOL}/snapshots"

# re-lock the subvolume. ${SUBVOL}/etc will remain R/W
btrfs property set -f -ts "${SUBVOL}/" ro true

btrfs subvolume create "${SUBVOL}/snapshots/etc"

# copy every stock /etc (that has been moved to /usr/etc) file to the actual /etc
cp -a ${SUBVOL}/usr/etc/* ${SUBVOL}/etc/

# copy the machine-id file: this was created by systemd the very first boot and identify the machine:
# changing this will also make ssh warn about machine not matching.
if [ -f "/etc/machine-id" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Do we have a mchine-id in our system image such that this would get overwritten? If we do, we should remove it.

Copy link
Contributor Author

@NeroReflex NeroReflex Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR, as the hibernation one, was superceeded by the upcoming frzr rework. Machine-id file is created at first boot by systemd on the first boot. I don't know if we have one in our image, but for sure it is something to investigate.

However I don't think we have one simply because systemd is not run from arch-chroot.

Moreover after a system restore the macchine changes id and SSH complains, so I think this is an indirect proof that wedon't ship such a file.

cp -a /etc/machine-id ${SUBVOL}/etc/
else
echo "WARNING: no /etc/machine-id -- new machine-id will be regenerated at next boot"
fi

# Make a snapshot of /etc so that this state can be restored
btrfs subvolume snapshot ${SUBVOL}/etc ${SUBVOL}/snapshots/etc/0
fi

mkdir -p ${MOUNT_PATH}/boot/${NAME}
cp ${SUBVOL}/boot/vmlinuz-linux ${MOUNT_PATH}/boot/${NAME}
cp ${SUBVOL}/boot/initramfs-linux.img ${MOUNT_PATH}/boot/${NAME}
Expand Down
Loading