Service on Startup not working on jetson agx

Hi,
I am referring these docs to make startup script but since my *launch.sh file is on SD card.
so the mavros.service starts before the mounting service. to counter this I added

[Unit]
After=media-agx-navigation.mount
Requires=media-agx-navigation.mount (reference)

but still, the same problem is happening.

hello shubham.shah09,

please refer to /etc/systemd/system/ for default initial services.
could you please modify your script to make it runs after nvpmodel.service

okay, ill add nvpmodel.service in After = media-agx-navigation.mount nvpmodel.service

Still the problem is persisting

could you please share the content for reference, thanks

the contents of mavros.service are

[Unit]
Description=mavros
Requires=media-agx-navigation.mount nvpmodel.service
After=media-agx-navigation.mount nvpmodel.service

[Service]
Type=forking
ExecStart=/home/odroid/scripts/startup_launch.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

@JerryChang

could you please confirm this is actually executed?

hello shubham.shah09,

could you please briefly describe the use-case, what’s the scenario for running this script.
are you able to run the script file, /home/odroid/scripts/startup_launch.sh manually?

Hi, yes I can run the script file manually. and if I manually start the service, it works in that case as well. the use case is to start the mavros service

thanks

systemctl status media-agx-navigation.mount shows me that it is working

hello shubham.shah09,

will this works? please have a try, thanks

After=nvpmodel.service media-agx-navigation.mount 
Requires=media-agx-navigation.mount

I tried, same problem is persisting

Hi, any update?

hello shubham.shah09,

since you can run the script file manually, please try google it around for related system level configurations.

Hi, the problem is, the service is called before SD card is mounted, since other SBC’s are booted from SD card self (Raspberry Pi) less info is available for this problem

help is appreciated

thanks

I’ve not worked on this, but here is a command you’ll be interested in looking at:
systemctl list-units | egrep -i 'mount'

On a TX2 (might differ from AGX, but likely is the same) I see:

# systemctl list-units | egrep -i mount
  proc-sys-fs-binfmt_misc.automount                                                   loaded active running   Arbitrary Executable File Formats File System Automount Point                
  -.mount                                                                             loaded active mounted   Root Mount                                                                   
  dev-hugepages.mount                                                                 loaded active mounted   Huge Pages File System                                                       
  dev-mqueue.mount                                                                    loaded active mounted   POSIX Message Queue File System                                              
  proc-sys-fs-binfmt_misc.mount                                                       loaded active mounted   Arbitrary Executable File Formats File System                                
  run-rpc_pipefs.mount                                                                loaded active mounted   RPC Pipe File System                                                         
  run-user-0.mount                                                                    loaded active mounted   /run/user/0                                                                  
  run-user-120.mount                                                                  loaded active mounted   /run/user/120                                                                
  sys-kernel-config.mount                                                             loaded active mounted   Kernel Configuration File System                                             
  sys-kernel-debug.mount                                                              loaded active mounted   Kernel Debug File System                                                     
  systemd-remount-fs.service                                                          loaded active exited    Remount Root and Kernel File Systems   

The ones you will be interested in for an SD card might be run one of two ways:

  • As an individual user (the service mounts under “/run/user/<user ID>”), or
  • As the system (no “/run” file, part of fstab).

Note that mounting as an individual user occurs later than regular mount, and is typical of an SD card which is not the root filesystem. Probably this is what happens in your case.

If this runs as an individual user, then the mount point is the user’s ID number (UID) as the subdirectory of “/run/user”. So if a mount shows up under “/run/user/0”, then this is a late mount by user root; if this is showing up as a numeric ID other than 0, then this is running as that user. On the system I am looking at the Gnome Display manager has UID 120:

# grep 120 /etc/passwd
gdm:x:120:124:Gnome Display Manager:/var/lib/gdm3:/bin/false

(and thus exists “/run/user/120/”)

Did you add an fstab entry (in “/etc”) for the partition to mount? Or is this being auto-mounted as a user?

It is being auto mounted under /media/agx/myfolder

Thus this is an automount based on the user logging in to the desktop. This needs to instead be mounted via “fstab” so that it can mount earlier. One problem is that sometimes automount needs to be disabled if you are mounting via fstab (sometimes automount will incorrectly mount the SD card twice). When the SD is mounted automatically, what do you see from:
df -H -T /media/agx/myfolder

Also, what do you see from:
lsblk -f

From the above we can find out the best way to add an entry to fstab.