Start jail from command line

Status
Not open for further replies.

flanello

Cadet
Joined
Apr 8, 2014
Messages
6
How can a jail be started and stopped form the command line?


The following doesn't work:
Code:
service jail start <Jail_Name>
service jail stop <Jail_Name>
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Be careful with even considering this.. you're doing it behind the back of the WebGUI, and it can get upset and do nasty things...
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Not a developer so I'm not sure. But, 99% of what people do from the CLI, if it's anymore more than looking at things(ie checking SMART status, time check, permissions, etc.) it's something that can go badly without warning. Generally, if the manual doesn't tell you to do it you probably shouldn't. The WebGUI does things and expect nothing to be done behind it's back. If you start doing things behind it's back it'll get upset. It's caused tons of problems for people.

When give a choice between FreeNAS trashing your jail(s) and just not doing this from the CLI, guess what the conservative choice is? ;)

This is partly why the FreeNAS API was created. Too many people wanted to do things behind the WebGUI's back and it ended badly. We've had lost pools from bad CLI choices before. You should be using the WebGUI or the API ONLY unless you are 100% sure what you are doing is safe. Even innocuous things have proven fatal to configurations in the past. So don't be fooled because it seems pretty minor to do something from the CLI.
 

panz

Guru
Joined
May 24, 2013
Messages
556
Or, if you like experimenting, setup a VM and play with that!
 

flanello

Cadet
Joined
Apr 8, 2014
Messages
6
Thanks for the information.
Using the API seems to be a good idea, although it could be a bit difficult using it the first time.
 

ajohnson

Dabbler
Joined
Feb 25, 2013
Messages
18
I'm necroing this thread for the future reference of others, here's how you can do this through the API from the command line:
Code:
curl -v -u username:password -X POST http://localhost/api/v1.0/jails/jails/<jailid>/start/


Replace username : password with your freenas root username/password. Replace <jailid> with the jail number.
I don't have many jails, so I just tried a few different ones until I got the right one. I'm sure there's a better way to find it, though (maybe "jls" command on the command line will show it).

Stop is /stop/ instead of /start/. I didn't try stop though, as I have no need for it.
 

nilsb

Dabbler
Joined
Dec 31, 2016
Messages
10
Replace username : password with your freenas root username/password. Replace <jailid> with the jail number.
I don't have many jails, so I just tried a few different ones until I got the right one. I'm sure there's a better way to find it, though (maybe "jls" command on the command line will show it).
Code:
sudo warden list -v | egrep "(id:|host:)" # to get the jailid's

jls will work too
 
Status
Not open for further replies.
Top