How to disable zpool auto-import?

morphin

Dabbler
Joined
Jun 27, 2023
Messages
31
Hello.

I want to disable zpool auto-import and import pools manually after reboots.
How can I do that?
Also which service is responsible for importing pools in Truenas Scale?
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
The first thing that comes to mind is to export the pool before every reboot. This should be straight forward enough to test. On reboot, I don't think the software will automatically import the pool. Then, you log into the GUI and import the pool.

Next, I think their are options for shutdown scripts. So, perhaps exporting the pool before the NAS software does so will work. Then, a startup script to do the import after a delay or trigger condition, (like the drives being available).

Note that when I mean export or import the pool, it is always through either the GUI, or the CLI, which is the NAS command line interpreter. Using the NAS software allows the NAS software to start or stop sharing any datasets from the affected pool. Using the Unix SHELL command zpool to import or export the pool hides that action from the NAS software.


This may be annoying to do, but in your case, it may be needed until a solution can be found for your unavailable drive issue. (I am following that other thread.)
 

morphin

Dabbler
Joined
Jun 27, 2023
Messages
31
The first thing that comes to mind is to export the pool before every reboot. This should be straight forward enough to test. On reboot, I don't think the software will automatically import the pool. Then, you log into the GUI and import the pool.

Next, I think their are options for shutdown scripts. So, perhaps exporting the pool before the NAS software does so will work. Then, a startup script to do the import after a delay or trigger condition, (like the drives being available).

Note that when I mean export or import the pool, it is always through either the GUI, or the CLI, which is the NAS command line interpreter. Using the NAS software allows the NAS software to start or stop sharing any datasets from the affected pool. Using the Unix SHELL command zpool to import or export the pool hides that action from the NAS software.


This may be annoying to do, but in your case, it may be needed until a solution can be found for your unavailable drive issue. (I am following that other thread.)

Hello Arwen, thank you for the answer.

1- I think the export & reboot will no effect on my case but I will try.
2- To be able to manual import after reboot, I need to find the auto-import and disable it. This is why I opened this thread.
3- Putting delay for zpool import also may work on my case but this thread does not related with this.

I read the dmesg output line by line and shared my review on the other thread, lets continue there to discuss issue and leave this thread for only disabling auto-import pools.
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
This idea exists to solve a problem that should not be solved with this idea.

that said, the only way to work around the middleware and how it is set up (to do something that every single user of TrueNAS wants... and should always want)... to import known pools on startup.. is to either: encrypt the pool with a passphrase (meaning it can't be "mounted" until the passphrase is entered), or use the API to disconnect the pool on shutdown, meaning it will not be in the config database and hence not there to be automatically imported on startup.

The API call involved with that would be:

pool.export (https://www.truenas.com/docs/api/scale_websocket_api.html#pool)

you would then need to ensure the resulting job is completed (also in the API docs) before completing the shutdown script.

I don't recommend going down this road at all.
 

morphin

Dabbler
Joined
Jun 27, 2023
Messages
31
This idea exists to solve a problem that should not be solved with this idea.

that said, the only way to work around the middleware and how it is set up (to do something that every single user of TrueNAS wants... and should always want)... to import known pools on startup.. is to either: encrypt the pool with a passphrase (meaning it can't be "mounted" until the passphrase is entered), or use the API to disconnect the pool on shutdown, meaning it will not be in the config database and hence not there to be automatically imported on startup.

The API call involved with that would be:

pool.export (https://www.truenas.com/docs/api/scale_websocket_api.html#pool)

you would then need to ensure the resulting job is completed (also in the API docs) before completing the shutdown script.

I don't recommend going down this road at all.

I agree with you.
This is still a test box and I just wanted to try to see the result and narrow the problem one step further.

It is sad to hear that, the api call seems hard way to go and I don't wanna spend time on this.
Changing zpool name will not work right? The right way to import a pool is the pool id not the name. But if the Truenas does only use name, then it will work maybe.

The password solution is not good because it includes a import try and maybe it will generate different problems.
My whole point is not auto import or import with some delay and wait kernel boot sequence complete.
 

morphin

Dabbler
Joined
Jun 27, 2023
Messages
31
This idea exists to solve a problem that should not be solved with this idea.

that said, the only way to work around the middleware and how it is set up (to do something that every single user of TrueNAS wants... and should always want)... to import known pools on startup.. is to either: encrypt the pool with a passphrase (meaning it can't be "mounted" until the passphrase is entered), or use the API to disconnect the pool on shutdown, meaning it will not be in the config database and hence not there to be automatically imported on startup.

The API call involved with that would be:

pool.export (https://www.truenas.com/docs/api/scale_websocket_api.html#pool)

you would then need to ensure the resulting job is completed (also in the API docs) before completing the shutdown script.

I don't recommend going down this road at all.


I found an easy way:
Code:
systemctl disable ix-zfs.service
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
found an easy way:
Code:
systemctl disable ix-zfs.service
But why?

If the pool is not imported on shutdown it will not be re-imported on startup. Simple as that.
 
Top