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

feature request: automatic detection of root device #32

Open
apprehensions opened this issue Jul 16, 2022 · 2 comments
Open

feature request: automatic detection of root device #32

apprehensions opened this issue Jul 16, 2022 · 2 comments

Comments

@apprehensions
Copy link

apprehensions commented Jul 16, 2022

would this be possible?

also:
since root device can be automatically detected, so can the file system module for it.

this could allow for configuration-less tinyramfs.

@apprehensions apprehensions changed the title automatic detection of root device feature request: automatic detection of root device Jul 16, 2022
@illiliti
Copy link
Owner

It is possible, but that would be unreliable.

root device autodetection implies that we have to iterate over disk devices, mount them and then check /sbin/init. if it exist - switch_root into it, if not - continue.

It is unreliable because mount can fail due to fs module not being loaded. mount can also fail because disk device could be encrypted, so have to implement fs type checking. There're also more complex file systems like zfs or btrfs, which may have nested file systems/partitions/pools...

This is pretty hard to do properly. I'd rather have only static configuration defined by user. This is more reliable than being too smart and autodetect everything.

since root device can be automatically detected, so can the file system module for it.

Tinyramfs already autodetects filesystem module for rootfs:

tinyramfs/tinyramfs

Lines 112 to 120 in 6b9f73d

if [ "$root_type" ]; then
copy_kmod "$root_type"
else
while read -r _ _dir _type _; do
[ "$_dir" = / ] && break
done < /proc/mounts || panic 'unable to detect rootfs module'
copy_kmod "$_type"
fi

But again, it is unreliable. It might be removed in the future because it doesn't work in live usb environment and environment where /proc isn't mounted.

@apprehensions
Copy link
Author

not exactly what i meant, what i meant was that at configuring time when tinyramfs is building the initramfs. i wouldn't think this is that hard because it can simply check what device is /.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants