Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] dm-crypt without modules?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
thelordi
n00b
n00b


Joined: 16 Sep 2023
Posts: 16

PostPosted: Wed Oct 25, 2023 6:09 pm    Post subject: [Solved] dm-crypt without modules? Reply with quote

Hello everyone, I wanted to increase the security of my computer by removing modules from the kernel. I have a configuration without modules that could boot, however, I still need an initramfs (and through it, modules) because I have an encrypted / partition and an encrypted /home partition. In the wiki section it says to enable loadable module support when using dm-crypt, even when including it in the kernel. So my question is: (How) can I get dm-crypt to work without needing to rely on kernel modules and to some extent dracut (because I have not yet tried to integrate the dm-crypt module in the kernel without an initramfs but as a module)?

Last edited by thelordi on Thu Oct 26, 2023 8:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4162
Location: Bavaria

PostPosted: Wed Oct 25, 2023 6:43 pm    Post subject: Reply with quote

If you have an encrypted root partition you will need always an initramfs doing the job of decryption.

Which modules you will need depends also on your used cryptographic algorithms. Because I am using also a kernel without modules support, you might look at these settings when using aes-xts-plain64:
https://forums.gentoo.org/viewtopic-p-8457358.html#8457358

Another way to get all needed modules is a look into "lsmod" ... ;-)

If you want an UKI (unified kernel image) you can embed your external CPIO (initramfs) into your kernel, with this method:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Initramfs_Overview#Special_Case:_Building_an_embedded_initramfs_with_a_CPIO_archive
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21639

PostPosted: Wed Oct 25, 2023 6:46 pm    Post subject: Reply with quote

When referring to a Wiki page, please link to it so we can check what you read. In this case, I can tell you that it is possible to have a kernel with (1) no module support, (2) dm-crypt support built-in, and (3) an initramfs that can unlock and mount an encrypted root filesystem. In almost all cases, the advice to make something a module when it is permanently used is because making it a module affects the order of when it activates, which can avoid the need to sequence components correctly and avoid the need to have the required components ready as early in the boot process. This advice most often comes up with firmware.

I cannot say whether dracut can handle this correctly, but I think it should be able to do so.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54259
Location: 56N 3W

PostPosted: Wed Oct 25, 2023 7:59 pm    Post subject: Reply with quote

thelordi,

The initrd need only contain the user space tools required to expose root and mount it.

See https://wiki.gentoo.org/wiki/PC_Boot_Process and https://wiki.gentoo.org/wiki/Initramfs_-_make_your_own
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 222
Location: Pennsylvania, USA

PostPosted: Thu Oct 26, 2023 2:15 am    Post subject: Re: dm-crypt without modules? Reply with quote

thelordi wrote:
So my question is: (How) can I get dm-crypt to work without needing to rely on kernel modules and to some extent dracut (because I have not yet tried to integrate the dm-crypt module in the kernel without an initramfs but as a module)?
Can't you do a make localyesconfig and rebuild the kernel ? That will turn all the modules that are loaded at the time into builtin drivers, and deselect the rest.

(Don't forget to embed the firmware needed by your drivers.)
Back to top
View user's profile Send private message
thelordi
n00b
n00b


Joined: 16 Sep 2023
Posts: 16

PostPosted: Thu Oct 26, 2023 8:04 pm    Post subject: Reply with quote

Thank you very much for all the help!
After now understanding the initramfs and modules a fair bit better, I was able to get it working without modules, until I managed to screw a fair few things up with dmcrypt. I now use an unencrypted / but still an encrypted /home, so I no longer need the initramfs as well.
And thank you pietinger for your guide, that was actually very much what I was looking for!
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4162
Location: Bavaria

PostPosted: Thu Oct 26, 2023 8:10 pm    Post subject: Reply with quote

thelordi wrote:
And thank you pietinger for your guide, that was actually very much what I was looking for!

You a very Welcome ! :D

Have fun with Gentoo ! 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum