Jump to content

On Linux startup: count 10 seconds, then start Steam (application)

Welp, Stack Overflow is full of unimaginative elitist. So I'm posting this here and hoping that from seeing how LMG's community interacts with one another that things will turn out different...

 

The issue:

My system drive is too fast at getting the initial startup out of the way. So when it goes to launch Steam on startup as the application is setup to do, it does so before my other mounted drives have a chance to be recognized by the system. This causes the application to think that the drives weren't there to begin with.

 

My knowledge:

Being extremely new to Linux, I really haven't tried anything besides trying to research the equivalent of Windows batch scripting.

If I were to set this up on Windows, I'd write a batch script that would startup, run timer for 10 seconds, the start Steam. Allowing for plenty of time for the other drives to be recognized and mounted prior to any other program trying to interact with them.

Link to comment
Share on other sites

Link to post
Share on other sites

You can easily do that on Linux. Here's a basic overview: https://www.baeldung.com/linux/run-script-on-startup

 

I think the rc.local option is likely the simplest.

 

So you would need to remove Steam from the list of startup applications so that it doesn't try to launch twice, then write your script.

 

The script is basically just going to be:

#!/bin/sh

sleep 10

steam

 

That just means sleep (wait) for 10 seconds then run the "steam" command, which should launch Steam.

 

Hopefully that works for you.

Link to comment
Share on other sites

Link to post
Share on other sites

55 minutes ago, Bryan1992345 said:

So when it goes to launch Steam on startup as the application is setup to do, it does so before my other mounted drives

Have you added the drives into the /etc/fstab flie?

 

You can follow the format of existing  devices listed in the file, and to get UUID:

 

sudo blkid /dev/ name of storage device.  I don't have nvme, but it is usually not listed as sda but something else, like nwme0.

 

To get a list of all devices:

 

lsblk

 

It lists all storage devices.  You could also open KDE partition manager, and click devices in the menu.  Or disks in gnome.  Right clicking properties in a file manager in a folder will also list a uuid value, but it is not for that whole device, but rather, the partition uuid, which is different, so don't use that.

 

In the /etc/fstab file, the last two 0 digits are important.  For your boot device, I suggest setting the last 0 to 1.

 

The first 0 is very antiquated, and no longer used by most, something to do with backup.  Leave it as 0.

 

The second digit is for a file system check, and 1 means to check it at every boot.  2 means at every other boot.  I would like to see this file receive much better documentation, as it is still a critical part of the system.  Redhat does a good job explaining it:

 

https://www.redhat.com/sysadmin/etc-fstab

: JRE #1914 Siddarth Kara

How bad is e-waste?  Listen to that Joe Rogan episode.

 

"Now you get what you want, but do you want more?
- Bob Marley, Rastaman Vibration album 1976

 

Windows 11 will just force business to "recycle" "obscolete" hardware.  Microsoft definitely isn't bothered by this at all, and seems to want hardware produced just a few years ago to be considered obsolete.  They have also not shown any interest nor has any other company in a similar financial position, to help increase tech recycling whatsoever.  Windows 12 might be cloud-based and be a monthly or yearly fee.

 

Software suggestions


Just get f.lux [Link removed due to forum rules] so your screen isn't bright white at night, a golden orange in place of stark 6500K bluish white.

released in 2008 and still being improved.

 

Dark Reader addon for webpages.  Pick any color you want for both background and text (background and foreground page elements).  Enable the preview mode on desktop for Firefox and Chrome addon, by clicking the dark reader addon settings, Choose dev tools amd click preview mode.

 

NoScript or EFF's privacy badger addons can block many scripts and websites that would load and track you, possibly halving page load time!

 

F-droid is a place to install open-source software for android, Antennapod, RethinkDNS, Fennec which is Firefox with about:config, lots of performance and other changes available, mozilla KB has a huge database of what most of the settings do.  Most software in the repository only requires Android 5 and 6!

 

I recommend firewall apps (blocks apps) and dns filters (redirect all dns requests on android, to your choice of dns, even if overridden).  RethinkDNS is my pick and I set it to use pi-hole, installed inside Ubuntu/Debian, which is inside Virtualbox, until I go to a website, nothing at all connects to any other server.  I also use NextDNS.io to do the same when away from home wi-fi or even cellular!  I can even tether from cellular to any device sharing via wi-fi, and block anything with dns set to NextDNS, regardless if the device allows changing dns.  This style of network filtration is being overridden by software updates on some devices, forcing a backup dns provuder, such as google dns, when built in dns requests are not connecting.  Without a complete firewall setup, dns redirection itself is no longer always effective.

Link to comment
Share on other sites

Link to post
Share on other sites

What distro are you using and how are you starting Steam? The "Startup applications" app present on a bunch of distros already has a configurable delay.

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Kilrah said:

What distro are you using and how are you starting Steam? The "Startup applications" app present on a bunch of distros already has a configurable delay.

I am running on Pop! os. Extremely new to it, and so far loving how lightweight this system is. I am also letting the Steam application startup on launch through the application settings.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Bryan1992345 said:

it does so before my other mounted drives have a chance to be recognized by the system

Obviously @YoungBlade's script does what is says, wait 10 seconds, then starts steam.

 

I do have "some processes" that require "other things" to be in place before continuing, and tend to use a until or while loop.

This is a quick hackey edit of one for my "wait for" scripts to suit your needs:

#!/bin/bash

wait_for(){
    limit=1
    until grep -q "$1" /proc/mounts;do
        if [[ $limit -gt 40 ]] ;then
            echo "Timeout waiting for $1!"
            exit 1
        else
            limit=$(( limit + 1 ))
        fi
    	sleep 0.25
    done
    echo "$1 mounted OK"
}

wait_for "/dev/sdb1"
wait_for "/dev/sdc1"

steam

The idea here being; the script will check if the listed drive is mounted, every 1/4 of a second until it is mounted, then move on to the next drive to check. How we reach the `10 second timeout value` is "if [[ $limit -gt 40 ]] ;then", 40 x 1/4 of a second = 10 seconds.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, E-waste said:

Have you added the drives into the /etc/fstab flie?

 

You can follow the format of existing  devices listed in the file, and to get UUID:

 

sudo blkid /dev/ name of storage device.  I don't have nvme, but it is usually not listed as sda but something else, like nwme0.

 

To get a list of all devices:

 

lsblk

 

It lists all storage devices.  You could also open KDE partition manager, and click devices in the menu.  Or disks in gnome.  Right clicking properties in a file manager in a folder will also list a uuid value, but it is not for that whole device, but rather, the partition uuid, which is different, so don't use that.

 

In the /etc/fstab file, the last two 0 digits are important.  For your boot device, I suggest setting the last 0 to 1.

 

The first 0 is very antiquated, and no longer used by most, something to do with backup.  Leave it as 0.

 

The second digit is for a file system check, and 1 means to check it at every boot.  2 means at every other boot.  I would like to see this file receive much better documentation, as it is still a critical part of the system.  Redhat does a good job explaining it:

 

https://www.redhat.com/sysadmin/etc-fstab

I have not done this yet. Back when I was running on Holoiso, I had to because it wasn't already mounting them. Pop! os finds them and mounts them for me, only difference was that I had to go into disk management and enable the "automation" (the "play" button on the partition). Am I wrong and Pop! os isn't automatically mounting my drives? Genuine question.

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Bryan1992345 said:

Am I wrong and Pop! os isn't automatically mounting my drives? Genuine question.

It can be, but they will be mounted purely in "userspace", usually in /run/user[id] somewhere. It may or may not be consistent (regarding naming and mount location), and is probably being run after you login as it needs your valid credentials to do so.

 

TBQH putting the relevant entries in /etc/fstab would probably solve the issue, as local filesystems are mounted early on in the boot process, this will also allow you to create consistant mount points.

Link to comment
Share on other sites

Link to post
Share on other sites

I will definitely be keeping this thread updated with what was tried from the suggestions made - you are all AWESOME!! Record level and comprehensive support.

Link to comment
Share on other sites

Link to post
Share on other sites

I will definitely be keeping this thread updated with what was tried from the suggestions made - you are all AWESOME!! Record level and comprehensive support.

 

(edit) Using two of the suggestions provided, I was able to get the result I was looking for.

 

@Ralphred & @E-waste, looking further into how Pop! os handles drives, it apparently already creates/edits the /etc/fstab file. So all I needed to do was enable the feature to mount my drives at startup (as the system calls it "automation" enabled).

 

@Ralphred, I tried your script but it wasn't doing anything on my system for some reason, so I went with @YoungBlade's suggestion. I had to edit it a fair amount otherwise terminal would stay running. After the minor edits, it ran flawlessly.

 

@Kilrah, this was another one of those very useful, hidden features of Linux that was unknown to me and now I'm glad I know it exists. I created a startup command to run the .sh file @YoungBlade suggested, which was set as an executable.

 

Now everytime I startup Pop! os, it gives ample time for the drive mounting automation to complete task prior to launching Steam. Steam starts up and doesn't have to look for missing drives anymore.

 

@Ralphred, I still think your script suggestion is an interesting one that would incorporate redundancy that I find appealing. I wouldn't mind still trying to figure out why that one didn't work.

 

Again, massive thanks to everyone who helped out, this was really cool to see, and reassuring that there is a community willing to help the blind find their way.

Link to comment
Share on other sites

Link to post
Share on other sites

41 minutes ago, Bryan1992345 said:

I wouldn't mind still trying to figure out why that one didn't work.

Just post the output of fstab; you need to edit the two drives it's checking for so they actually match yours.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×