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

gpt-auto-generator: Use volatile-root by default and automatic logic as fallback #20578

Merged
merged 1 commit into from Aug 31, 2021

Conversation

klausenbusk
Copy link
Contributor

@klausenbusk klausenbusk commented Aug 30, 2021

Previously volatile-root was only checked if "/" wasn't backed by a
block device, but the block device isn't necessarily original root block
device (ex: if the rootfs is copied to a ext4 fs backed by zram in the
initramfs), so we always want volatile-root checked.

So shuffle the code around so volatile-root is checked first and
fallback to the automatic logic.

Fix #20557


Tested in our Yocto image like so:

$ touch /sbin/fsck.vfat && chmod +x /sbin/fsck.vfat
$ mkdir /efi
$ ln -fs /dev/block/8:1 /run/systemd/volatile-root
$ ls -l /dev/block/8:1
lrwxrwxrwx    1 root     root             7 Aug 30 08:39 /dev/block/8:1 -> ../sda1
$ SYSTEMD_LOG_LEVEL=debug /lib/systemd/system-generators/systemd-gpt-auto-generator # daemon-reload is enough, but the log is a bit cleaner this way
[  185.594043] systemd-gpt-auto-generator[680]: Found container virtualization none.
[  185.597604] systemd-gpt-auto-generator[680]: Disabling root partition auto-detection, root= is defined.
[  185.601885] systemd-gpt-auto-generator[680]: Failed to chase block device '/', ignoring: No such file or directory
[  185.606744] systemd-gpt-auto-generator[680]: Failed to chase block device '/usr', ignoring: No such file or directory
[  185.611560] systemd-gpt-auto-generator[680]: sda1: Root device /dev/sda.
[  185.620360] systemd-gpt-auto-generator[680]: Reading EFI variable /sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
[  185.626288] systemd-gpt-auto-generator[680]: Adding /efi: /dev/sda1 fstype=vfat
$ systemctl daemon-reload
$ systemctl restart local-fs.target
$ ls /efi
EFI                                              bzImage                                          dm-verity-image-initramfs-genericx86-64.cpio.gz  loader

@poettering poettering added gpt-auto reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Aug 30, 2021
@poettering
Copy link
Member

Also, please update the man page of the generator to document the symlink. If this is now official API for other components too, then this must be documented. So far this was in internal interface only, thus had no docs.

@klausenbusk klausenbusk force-pushed the gpt-auto-generator-volatile-fs branch from f513b32 to f5830dc Compare August 30, 2021 10:59
@klausenbusk klausenbusk changed the title gpt-auto-generator: Also use volatile-root fallback when the originating device can't be found gpt-auto-generator: Use volatile-root by default and automatic logic as fallback Aug 30, 2021
@klausenbusk
Copy link
Contributor Author

I have shuffled the code around so volatile-root is used and automatic logic as fallback. I also tried updating the manpage, but I'm not the best writing documentation :)

@klausenbusk klausenbusk force-pushed the gpt-auto-generator-volatile-fs branch from f5830dc to f71c918 Compare August 30, 2021 11:46
…as fallback

Previously volatile-root was only checked if "/" wasn't backed by a
block device, but the block device isn't necessarily original root block
device (ex: if the rootfs is copied to a ext4 fs backed by zram in the
initramfs), so we always want volatile-root checked.

So shuffle the code around so volatile-root is checked first and
fallback to the automatic logic.

Fix systemd#20557
@klausenbusk klausenbusk force-pushed the gpt-auto-generator-volatile-fs branch from f71c918 to f8e7e84 Compare August 30, 2021 12:01
@poettering
Copy link
Member

lgtm

@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Aug 30, 2021
@yuwata
Copy link
Member

yuwata commented Aug 31, 2021

LGTM too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed gpt-auto
Development

Successfully merging this pull request may close these issues.

Provide a way to use systemd-gpt-auto-generator when the rootfs is a volatile file system
3 participants