I essentially created a self-loading shutdown script - HELP!

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
I write and run a fan control script that starts up automatically when TrueNAS starts. I was experimenting with adding a shutdown command that would shut down the system if temperatures got too high. I cleverly tested it by configuring the threshold very low, I think 22 C. It worked.

Obviously, I didn't think this through. Now the server shuts down right after the startup ritual. Is there any way, maybe via IPMI, to prevent it from loading that script during startup?
 
Joined
Oct 22, 2019
Messages
3,641
You could technically load up a config file from before you made this change. (Or even boot into a live USB of a Linux distro that supports ZFS, and grab an earlier "daily" config backup from the System Dataset.)
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
You could technically load up a config file from before you made this change. (Or even boot into a live USB of a Linux distro that supports ZFS, and grab an earlier "daily" config backup from the System Dataset.)
Thanks for the reply. I'm not sure how to load up a config file to a machine that isn't running. More importantly, I don't see how a config file from before I changed the script would change anything. The script has been auto-loading for years, and would continue to do so I think with any config file I could access.
 
Joined
Oct 22, 2019
Messages
3,641
I'm not sure how to load up a config file to a machine that isn't running.
You'd install a fresh instance of TrueNAS, then load the config.


The script has been auto-loading for years, and would continue to do so I think with any config file I could access.
I thought you recently made a "test" script and set the "shutdown trigger" to 22C?


How did you enable this "script" in the first place? I'm assuming via the Cron Tasks GUI? If so, then yes, it is saved with your (exported) config.
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
I didn't recently make the script. I recently edited a script that has been auto-loading for years. Yes, it is some GUI setting for startup scripts, but that hasn't changed in years.

However, if I can install a fresh instance of TrueNAS CORE, and import the pool, I guess I could re-edit the script so it won't shut down the system. I'm not sure how to install a fresh instance. I guess if I could, after I edit the script, I could then import my last-saved system configuration?
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
Where is the script stored? In your pool? Root home directory?

Mount that drive. Edit the script.
 
Joined
Oct 22, 2019
Messages
3,641
I didn't recently make the script. I recently edited a script that has been auto-loading for years.
Where is this script stored? On some dataset in your ZFS pool?

You can boot the system into a *live USB (such as Ubuntu), and then import the pool, edit the script, and then safely export the pool. Then you can try booting back into TrueNAS.

* You'll need an attached keyboard, mouse, and monitor.

** You might get a "warning" that the ZFS pool was not properly "exported" from its previous host.

*** I don't recall if ZFS is included with an Ubuntu live USB. You'd probably have to install the ZFS packages, if not. However, you can always boot into a live FreeBSD USB, and just use the command-line to edit the script. Apparently, the latest Ubuntu live ISOs ship with ZFS by default. :smile:

**** I felt like adding another note because I've already added three. It's kind of fun.
 
Last edited:

somethingweird

Contributor
Joined
Jan 27, 2022
Messages
183
dumb solution/answer: dry ice the server.
 
Joined
Oct 22, 2019
Messages
3,641
dumb solution/answer: dry ice the server.
"HDD temps have increased to 20C. Hurry! HURRY! EDIT THE SCRIPT! OH NO! Temps are at 21C now! BRING ME MORE ICE!"

AD-COMPOSITE-Ice-Cube-Fan.jpg
 

somethingweird

Contributor
Joined
Jan 27, 2022
Messages
183
"HDD temps have increased to 20C. Hurry! HURRY! EDIT THE SCRIPT! OH NO! Temps are at 21C now! BRING ME MORE ICE!"
Wouldn't need it if you use enough liquid nitrogen
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
I'm so happy to provide such amusement ;-)
But @Stux , "Mount that drive". Could I hear your advice how to do that? The script is in a pool, in my home dataset.
 
Joined
Oct 22, 2019
Messages
3,641
See post #7 above.

This requires some knowledge of the command-line and ZFS commands.

An overview is something like this:
  1. Boot into Ubuntu live ISO
  2. Import the pool with "zpool import". (The datasets should automatically mount if they are not encrypted.)
  3. Browse to the path with the script file, and edit it.
  4. Export the pool with "zpool export", shutdown, and remove the live USB.
  5. Boot back into TrueNAS like normal.
 
Last edited:

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
Joined
Oct 22, 2019
Messages
3,641
If TrueNAS Core has a "live" option, then that works too. But then you might as well boot into a FreeBSD live ISO. (Since you won't be using the middleware or web GUI components.)
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
If TrueNAS Core has a "live" option, then that works too. But then you might as well boot into a FreeBSD live ISO. (Since you won't be using the middleware or web GUI components.)
Pretty much if you install onto a USB, that USB is a live install. That’s how truenas works.

But by using a non truenas os you avoid anything confusing your original install when you switch to back to it.

So, you should just be able to boot Ubuntu. Import the pool. Edit the script. Export the pool. And then reboot back into truenas
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
Pretty much if you install onto a USB, that USB is a live install. That’s how truenas works.

But by using a non truenas os you avoid anything confusing your original install when you switch to back to it.

So, you should just be able to boot Ubuntu. Import the pool. Edit the script. Export the pool. And then reboot back into truenas
Actually.

You could just unplug your pool and restart. After all, the script is stored on the pool.

Then after it’s started, disable the init cmd and reconnect/reboot/import your pool
 
Joined
Oct 22, 2019
Messages
3,641
You could just unplug your pool and restart. After all, the script is stored on the pool.
This is where TrueNAS makes things weird. If the "System Dataset" is on the storage pool, it might cause an unintended issue with "phantom" folders and mounts.
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
Brilliant idea, @Stux . I pulled the pool physically and booted. But it didn't work, maybe for the System Dataset reason. Booting froze in the early stages, at the point below. (I'm doing this over iKVM so can't copy the text, just images)
freeze truenas boot.jpg


I put the disks back in, and managed to set up a FreeBSD image on USB stick. It gives the option to work live instead of install. Problem there is, it will import the pool, but no datasets (there is no encryption). I tried with simple zpool import Ark, and then with more explicit zpool import -f -R /mnt Ark. Same result:
freebsd import fail mount.jpg

So I'm stuck now. ????
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
With zfs list I can see the dataset I want, but zfs mount won't mount it. Using the -f option doesn't change that.
Screenshot 2024-03-24 at 08.25.11.jpg
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
Finally got through that problem. It seems /mnt is read-only when your on a live OS, so I made a directory /tmp/mypoint, then did zpool import, specifying that mountpoint. I edited out my errors and rebooted. Back in business! Thanks for your help @winnielinnie and @Stux .
 
Top