Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
binfmt_misc: How 2 stop automatic load @kernel boot?[solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Mon Mar 02, 2020 10:39 am    Post subject: binfmt_misc: How 2 stop automatic load @kernel boot?[solved] Reply with quote

binfmt_misc set as module here.
I guess the question sounds silly to many.
Still kernel boot automatically loads it.
Since qemu is only very occasionally used here and requires a little command sequence, it would be preferable to avoid such a default loading.
Can't figure how to manage it... :( Any idea?
Thks 4 ur attention, interest & support.


Last edited by CaptainBlood on Tue Mar 03, 2020 6:38 am; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Mon Mar 02, 2020 10:56 am    Post subject: Reply with quote

Assuming openrc (I'd bet systemd does something similar), it's likely the /etc/init.d/procfs script:
Code:
start()
{
        # Setup Kernel Support for miscellaneous Binary Formats
        if [ -d /proc/sys/fs/binfmt_misc ] &&
                [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
                if ! grep -qs binfmt_misc /proc/filesystems &&
                        modprobe -q binfmt-misc; then
Could always remove the section with a openrc patch (Edit: although seems need more setting up than just auto-loading the module, notably a mount point, so it's technically needed if ever used). Personally never use binfmt_misc and prefer to use full commands or wrappers/alias, so I don't even have it as a module.

Last edited by Ionen on Mon Mar 02, 2020 10:57 am; edited 1 time in total
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Mon Mar 02, 2020 1:35 pm    Post subject: Reply with quote

Ionen wrote:
Personally never use binfmt_misc and prefer to use full commands or wrappers/alias, so I don't even have it as a module.
Here's openrc.
Maybe I should try to follow that path, if applicable to qemu used for an architecture # to host's.
Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7368

PostPosted: Mon Mar 02, 2020 6:48 pm    Post subject: Reply with quote

You shouldn't patch procfs, it will be lost after an update
Go with openrc strengh it's better, and you could conditionaly load it, in my example, if kernel have some "qemu" name in it, it continue trying to load the modules, else it just stop ; upto you to have an entry with a kernel name with some "qemu" in it to use qemu and another entry without that keyword

create this in /etc/conf.d/procfs
Code:
procfs_start=
{
   if [[ "$(uname -a)" != *"qemu"* ]]; then
      return 0
      fi
   # Setup Kernel Support for miscellaneous Binary Formats
   if [ -d /proc/sys/fs/binfmt_misc ] &&
      [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
      if ! grep -qs binfmt_misc /proc/filesystems &&
         modprobe -q binfmt-misc; then
         ewarn "The binfmt-misc module needs to be loaded by" \
            "the modules service or built in."
      fi
      if grep -qs binfmt_misc /proc/filesystems; then
         ebegin "Mounting misc binary format filesystem"
         mount -t binfmt_misc -o nodev,noexec,nosuid \
            binfmt_misc /proc/sys/fs/binfmt_misc
            eend $?
      fi
   fi
   return 0
}
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Mon Mar 02, 2020 7:36 pm    Post subject: Reply with quote

Very interesting.
I see your script loads binfmt-misc module under specified conditions.
Lonen refers to /etc/init.d/procfs which is declared in rc-update scripts list.
Should I remove it from rc-update, does your script inihibits /etc/init.d/procfs or should your script be adapted to unload bindmt-misc module?
Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Mon Mar 02, 2020 7:49 pm    Post subject: Reply with quote

krinn wrote:
You shouldn't patch procfs, it will be lost after an update
By patch, I meant a patch to openrc rather than procfs, aka a /etc/portage/patches/ which isn't lost with updates. I find it simpler if it's just to change one line or similar rather than have a copy of the whole function in conf.d. Patch failure is also a nice reminder that you should probably check/update rather than changes going unnoticed and your conf.d function staying outdated.

That aside, conf.d is a nice solution if you just don't like using patches (or can't, like on a binary gentoo).
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Mon Mar 02, 2020 8:04 pm    Post subject: Reply with quote

I'm used to /etc/portage/patches/xxx so that path shouldn't be an issue.
I'm wondering still how /etc/init.d/procfs got installed in rc-update script list.
I'm relunctant to remove it as I have no emergency media to set it back should it brakes (silly me).
Thks 4 ur attention, interest & support.


Last edited by CaptainBlood on Mon Mar 02, 2020 9:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Mon Mar 02, 2020 8:12 pm    Post subject: Reply with quote

I actually was under the impression that script was doing more things given it says "misc filesystemS" (I didn't look beyond the modprobe line :lol:). I guess it may be a placeholder to do more things if ever needed.

If that's all it does, you could turn it off (I feel like I should remove it too, does nothing for me). Although you'll need to start it to mount /proc/sys/fs/binfmt_misc normally if you ever want to use binfmt_misc.
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Mon Mar 02, 2020 9:35 pm    Post subject: Reply with quote

Ionen wrote:
(I didn't look beyond the modprobe line :lol:)
I indeed didn't, and feel quite ashamed about it.
It indeed doesn't do anything more that what you reported.
Currently building an emergency USB key though (easy2boot here).
Will only try to remove once validated precaution measures have been taken.

My best to all of you, as I feel great having linux talks somehow beyond 'couldn't emerge package xxxx' stanza.
Plz note I'm not blaming those as such, as I did my share there for the last a decade now.
Becoming a little more mature though with the help of guys such as you.

Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1449

PostPosted: Tue Mar 03, 2020 6:36 am    Post subject: Reply with quote

Removed from rc-update list scripts.
Fine boot here.
Thks 4 ur attention, interest & support
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7368

PostPosted: Tue Mar 03, 2020 11:31 am    Post subject: Reply with quote

it was more an example of openrc strengh rather than simply disabling procfs ; for the beauty :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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