Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Problem creating a service to start at boot

  1. #1

    Question Problem creating a service to start at boot

    Hello everyone,
    I need to insert some kernel modules and then run a few programs in user space that use these kernel modules. All this has to happen at boot time. The way I have done it in the past in opensuse Linux has been to create a service script placed in file called /etc/init.d/myService – this script was created by modifying the “skeleton” example file found in that /etc/init.d/ directory. I added the pathname to the kernel modules to be inserted to a file called /etc/ld.so.conf.d/myService.conf and ran command: ldconfig to ensure the pathnames were picked up.
    The service was enabled using command: chkconfig myService on
    All environment variables needed were added to /etc/profile.local to ensure they were available early during the boot process.
    The problem is that none of the above now works in Tumbleweed. In Yast I can see my service is present and enabled but fails to run and the log says: “myService.service: Failed to execute command: No such file or directory” even though all programs and .ko modules to run are at the correct specified location so I don’t know what the problem is.
    I don’t mind separating the insertion of kernel modules from running the programs needed – but they have to happen during boot. I have done a lot of searching on the internet and found many different ways of boot time insertion of modules and running programs but none of them have worked.
    I would be grateful for and advise or help.
    Last edited by malcolmlewis; 04-Dec-2018 at 17:01. Reason: Fix test double up

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    24,998
    Blog Entries
    15

    Default Re: Problem creating a service to start at boot

    Hi and welcome to the Forum
    You can add your kernel modules to load in /etc/modules-load.d/ with a format of the kernel module name and then in the file the kernel module name, eg;

    Code:
    cat /etc/modules-load.d/it87.conf
    
    it87
    Environment variables can be exported in your ~/.profile

    You need to look at converting your deprecated sysvinit script to a systemd service, perhaps if you post the script and systemd service can be run instead
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: Problem creating a service to start at boot

    Hello Malcolm, thanks for your reply. I have to insert 16 kernel modules. I previously used a shell script with 16 lines of insmod commands. This script was called from myService service script. Does it mean I now need 16 files in the /etc/modules-load.d directory? One of the modules need an argument, I have used following command to insert it:
    insmod /usr/realtime/modules/rtai_netrpc.ko ThisNode="127.0.0.1"
    What would be the filename for this module and how would the argument be passed?
    If I don’t need to specify the full pathname in these files how would the system know the modules are in /usr/realtime/modules/ directory?
    BTW for your information my Tumbleweed is 32-bit but I am sure it is irrelevant.
    Many thanks again for your help!

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    24,998
    Blog Entries
    15

    Default Re: Problem creating a service to start at boot

    Quote Originally Posted by areft View Post
    Hello Malcolm, thanks for your reply. I have to insert 16 kernel modules. I previously used a shell script with 16 lines of insmod commands. This script was called from myService service script. Does it mean I now need 16 files in the /etc/modules-load.d directory? One of the modules need an argument, I have used following command to insert it:
    insmod /usr/realtime/modules/rtai_netrpc.ko ThisNode="127.0.0.1"
    What would be the filename for this module and how would the argument be passed?
    If I don’t need to specify the full pathname in these files how would the system know the modules are in /usr/realtime/modules/ directory?
    BTW for your information my Tumbleweed is 32-bit but I am sure it is irrelevant.
    Many thanks again for your help!
    Hi
    No, you can leave your script to run, just need to create a systemd service to run it, though if the hardware is present it should just load if the modules are installed in the correct place...?

    Then one that needs options could be done via /etc/modprobe.d (look at existing ones for an example);

    <some_kmp> <some option>

    Add a simple systemd file called say /etc/systemd/system/mymoduleload.service

    Code:
    # /etc/systemd/system/mymoduleload.service
    #
    
    [Unit]
    Description=Load my modules
    
    [Service]
    Type=simple
    ExecStart=/bin/bash -c '/path to your script/script_name'
    
    [Install]
    WantedBy=multi-user.target
    Test;
    Code:
    systemctl status mymoduleload.service
    systemctl start mymoduleload.service
    systemctl status mymoduleload.service
    
    if all ok (as in success), you might need to change to oneshot or forking for the 'type'.
    
    systemctl enable mymoduleload.service
    Reboot and see it all works....
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5

    Default Re: Problem creating a service to start at boot

    Hi,
    You mentioned “...though if the hardware is present it should just load if...”.
    Just in case your suggestions may be affected by what I am trying to do I think I should clarify; these modules are RTAI modules required to create a real-time pre-emptive Linux environment, so they are not related to any particular hardware. As mentioned I have already done this with an old OpenSUSE Linux quite successfully.
    So in brief I need to convert my service script to a system one and can still call the old shell script to insert the modules I need with full pathnames specified for each?

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    24,998
    Blog Entries
    15

    Default Re: Problem creating a service to start at boot

    Quote Originally Posted by areft View Post
    Hi,
    You mentioned “...though if the hardware is present it should just load if...”.
    Just in case your suggestions may be affected by what I am trying to do I think I should clarify; these modules are RTAI modules required to create a real-time pre-emptive Linux environment, so they are not related to any particular hardware. As mentioned I have already done this with an old OpenSUSE Linux quite successfully.
    So in brief I need to convert my service script to a system one and can still call the old shell script to insert the modules I need with full pathnames specified for each?
    Hi
    Yes, if built as KMP's (kernel module packages), they would be built and installed in /lib/modules/<kernel>/updates, so even out of tree become part of the kernel, if manually put there, AFAIK running a depmod would add them.

    Here's an example (see the spec file);
    https://build.opensuse.org/package/s...STING/elan_i2c

    Yes, your correct, just need a service file and carry on with your script
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7

    Default Re: Problem creating a service to start at boot

    Hi Malcolm and many thanks for your help. I now have to try out these suggestions and see what happens!
    But one important thing I never mentioned is that; I started this thread by asking “why my service didn’t work” but my problem is something else and quite simple, I am just complicating the matters because I only want to insert a few RTAI kernel modules followed by running an RTAI application that needs them at boot time.

    In the old days the only way I could do this or found how to do this was doing it as a Linux service. If I could do the above differently then I wouldn’t need the service script and wouldn’t have to convert it to systemd format and get involved how services work, etc., etc.

    So the REAL question is; in openSUSE Tumbleweed or indeed Leap, how do I insert a few kernel modules and run a program during boot before login appears?
    Many thanks again for your time.

  8. #8
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    24,998
    Blog Entries
    15

    Default Re: Problem creating a service to start at boot

    Quote Originally Posted by areft View Post
    Hi Malcolm and many thanks for your help. I now have to try out these suggestions and see what happens!
    But one important thing I never mentioned is that; I started this thread by asking “why my service didn’t work” but my problem is something else and quite simple, I am just complicating the matters because I only want to insert a few RTAI kernel modules followed by running an RTAI application that needs them at boot time.

    In the old days the only way I could do this or found how to do this was doing it as a Linux service. If I could do the above differently then I wouldn’t need the service script and wouldn’t have to convert it to systemd format and get involved how services work, etc., etc.

    So the REAL question is; in openSUSE Tumbleweed or indeed Leap, how do I insert a few kernel modules and run a program during boot before login appears?
    Many thanks again for your time.
    Hi
    Well, I'm assuming your building these modules against the current kernel? If so, then consider building and installing as kernel modules and then you could just have a file in /etc/modules-load.d to insert them at boot time. You could try adding the full path to them and see how it goes?

    Then the service file can run your script...

    There is also dracut to use so they get automatically built on a kernel upgrade.

    Many things have changed with the deprecation of sysvinit, unfortunately (just like cron jobs and moving to systemd timers) it's time to get up to speed with current practices as the transition time has passed and old stuff is getting dropped...

    So you have the sources for these kernel modules, are they open source?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  9. #9

    Default Re: Problem creating a service to start at boot

    Hi, for RTAI I have configured and used vanilla kernel version 4.9.80 - Tumbleweed is running on this cut-down version without any problem and the modules are built against this kernel.
    The kernel modules specified in a .conf file placed in /etc/module-laod.d/ are expected to be in the standard lib directory whereas my modules are in /usr/realtime/modules/ - therefore the question simply boils down to this; how to run a shell script containing the following commands at boot time, bearing in mind that the order of insertion is important:

    #!/bin/bash
    insmod /usr/realtime/modules/rtai_hal.ko
    insmod /usr/realtime/modules/rtai_sched.ko
    insmod /usr/realtime/modules/rtai_fifos.ko
    insmod /usr/realtime/modules/rtai_sem.ko
    insmod /usr/realtime/modules/rtai_mbx.ko
    insmod /usr/realtime/modules/rtai_msg.ko
    insmod /usr/realtime/modules/rtai_netrpc.ko ThisNode="127.0.0.1"
    insmod /usr/realtime/modules/rtai_shm.ko

    Without worrying about services etc.?

  10. #10
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    24,998
    Blog Entries
    15

    Default Re: Problem creating a service to start at boot

    Quote Originally Posted by areft View Post
    Hi, for RTAI I have configured and used vanilla kernel version 4.9.80 - Tumbleweed is running on this cut-down version without any problem and the modules are built against this kernel.
    The kernel modules specified in a .conf file placed in /etc/module-laod.d/ are expected to be in the standard lib directory whereas my modules are in /usr/realtime/modules/ - therefore the question simply boils down to this; how to run a shell script containing the following commands at boot time, bearing in mind that the order of insertion is important:

    #!/bin/bash
    insmod /usr/realtime/modules/rtai_hal.ko
    insmod /usr/realtime/modules/rtai_sched.ko
    insmod /usr/realtime/modules/rtai_fifos.ko
    insmod /usr/realtime/modules/rtai_sem.ko
    insmod /usr/realtime/modules/rtai_mbx.ko
    insmod /usr/realtime/modules/rtai_msg.ko
    insmod /usr/realtime/modules/rtai_netrpc.ko ThisNode="127.0.0.1"
    insmod /usr/realtime/modules/rtai_shm.ko

    Without worrying about services etc.?
    Hi
    Well easiest way is the simple systemd service as indicated with the exec your script wherever it is. Else it depends on what part of the system startup, eg if some piece of equipment gets plugged in, then a udev rule, a user logs in the a ~/.profile call to the script should suffice.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •