troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
634 stars 64 forks source link

fsck in finit? #238

Closed hongkongkiwi closed 2 years ago

hongkongkiwi commented 2 years ago

So currently in finit fstab is mounted automatically as part of a plugin.

So, when using finit in this way, how can we handle fsck in an ext4 mount? In other systems (say debian) I think fsck is handled by systemd along with mounting.

Ideally I would like fsck to be run and automatically fix any errors that prevent mounting. Do you think the best way is to simply have an fsck plugin and run it before fstab plugin?

troglobit commented 2 years ago

Finit actually has support for fsck already (natively, not in a plugin), it's one of the first duties when entering runlevel S, before calling mount -na, in PASS order as specified in /etc/fstab. So, it should work as-is, although there's no automatic tests for it, I've verified it in my manual tests.

Or was there something else you were looking for?

See here: https://github.com/troglobit/finit/blob/f39626f13279e23e04c98a5df214fec97872cfc3/src/finit.c#L112-L175

hongkongkiwi commented 2 years ago

Ah, that's great! I didn't know about this functionality but it's exactly what I want (with one caveat).

I think this is where #224 comes back to bite me because the filesystems I want to fsck are actually in /etc/fstab.slot which is called via a helper so finit isn't aware of it.

So, I guess being able to pass an alternative fstab file would be great because then I can put everything for one slot in an fstab file and have finit be able to fsck it.

I guess the only solution until then is to have my mount helper do the fsck (not great I guess!).

troglobit commented 2 years ago

Ah, of course! Yeah, that's definitely the issue here, good catch didn't even think about that myself. This is also nothing Finit can take into account, other than having an alt. fstab passed on the command like as specified in #224.

Side note, I always found it odd that mount (-a) didn't call fsck itself, I mean it is the system responsible UNIX program for /etc/fstab after all ... oh well, can't have everything I guess.

Doing the fsck in the mount helper isn't bad, as long as it runs early, before all the file systems you want to check, you're fine. The mount helpers run in strict sequence, line by line.

I guess we can close this issue then? Maybe we can use Discussions for future questions of this form? I don't mind answering them, quite the contrary, and Discussions are left open and possibly easier for other users to find what they are looking for. And on the off chance a question turns into a bug it can be converted to an issue :smiley:

hongkongkiwi commented 2 years ago

Yes, that can be closed, thanks! I totally didn't realise that fsck was included in the box ;)