-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for ZFS datasets as jail directories #113
Added support for ZFS datasets as jail directories #113
Conversation
Added support for using existing ZFS datasets as jail directories. - Allows creation of jails in existing folders/directories that can be ZFS datasets - The script now checks if a jail exists by checking for the config file rather than the directory - The script now lists jails also based on the config file existing rather than the directory - When deleting and the directory is a ZFS dataset, it will delete the config file and rootfs directory rather than deleting the directory
Cool! Can you please edit the pull request to merge into the develop branch? I'll try to look at this on Sunday. |
One question though: |
Done
That's a valid point. Alternatively one could implement a check to see if the folder is not a dataset during jail creation and store it as a flag somewhere and only delete jail specific content during deletion... but I think that's overcomplicating things for no reason. |
Thanks for providing this Pull Request :) It's a good start but I was hoping you could make it a little more complete. Would you be able to add the following? Pseudo code during jail create:
Then during cleanup you can check once more if "jailmaker/jails/jailname" is a zfs dataset. If it is you can destroy this dataset, else just What do you think? |
Hey, Yeah, this sounds very similar to how I initially wanted to do it. The reason I didn't and said "let the user manually create/delete datasets" is because while creating a ZFS dataset is easy, deleting may get complicated because you need to decide how snapshots are going to be handled during deletion. In order to destroy (delete) a dataset, you need to first delete snapshots or delete the dataset with snapshots recursively. My suggestion is and this is probably how I'll implement it (probably next week unless someone beats me to it):
|
Glad to hear you want to work on this feature some more :)
I think this is what needs to happen. If the user wants to keep snapshots, then just don't remove the jail. The What do you think? |
By the way I don't think the user should manually create or delete datasets. I think the default, for new users, should be to create the "jails" dir as a dataset automatically. And then for each jail a new dataset should be created automatically and this dataset should be removed automatically (with snapshots) if the user confirms the For existing users jailmaker should continue to create plain directories inside the "jails" dir. I prefer to keep these 2 cases consistent (all jails are in plain directories or all jails are in their own dataset). Merging the PR in its current state would mean, for a single user, some jails may be in datasets while others are in plain directories. While I appreciate your approach and its simplicity I don't think it would be good to mix these cases. |
I agree with you, yes it makes sense.
The only problem is that this would technically be a breaking change for updating, requiring users to create datasets in place of the folders and move the contents of jails/jailmaker into those datasets to continue using it. However, I absolutely agree with this approach - when I first used jailmaker I thought it already was like this. So by default, I should rewrite the code to required the jailmaker directory and the jails directory to be zfs datasets, along with jails being created as datasets, right? |
It doesn't have to be a breaking change if implemented in a backwards compatible way, as suggested here. You could treat the "jails" dir a bit like a boolean. If it is a plain directory (no dataset), then skip creating a dataset for a new jail (just make a plain directory like jailmaker currently does). If the "jails" dir is a dataset (which won't be the case for any existing users), then do create a dataset when creating a new jail. If the "jails" dir doesn't exist, then create it as a dataset, as the new default for new users. The changes to Existing users may migrate to the new default manually, by stopping all running jails and then renaming the "jails" dir to e.g. "jails_old". Then they could update to the latest
Yes, but keep in mind the backwards compatibility. And you make a good point. The "jailmaker" directory itself needs to be a dataset too for this to work I suppose. Currently jailmaker doesn't check for this. So some users may have |
Yeah I agree, this makes absolute sense. So: -> Jailmaker directory is plain -> create plain jail directory Similarly with removing jails. :) Hopefully I'll get to this this week, this also makes things a lot easier for my own use case |
Closed in Favor of #118 |
Added support for using existing ZFS datasets as jail directories.