Skip to content
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

zpool: add option to mount zpool not at / #211

Merged
merged 1 commit into from
Apr 29, 2023
Merged

zpool: add option to mount zpool not at / #211

merged 1 commit into from
Apr 29, 2023

Conversation

SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Apr 20, 2023

Otherwise creating and mounting the zpool in a live image removes the root disk of the live image.

Tested on physical hardware.

@@ -55,7 +66,7 @@
default = _: ''
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
zpool create ${config.name} \
${config.mode} \
-R ${config.mountRoot} ${config.mode} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man zpool-create suggests that implicitly sets cachefile=none and altroot properties on the pool, even if no alt-root is used. Do we want this or should we use lib.optionalString here?

Copy link
Member Author

@SuperSandro2000 SuperSandro2000 Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just set / to keep backwards compatibility but it doesn't make much sense as it will most likely overwrite the system that the command is run from.

We don't need to worry about altroot and since at this stage the system is not fully configured yet, the missing cachefile should not make a big difference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, did a bit more docs reading, cachefile=none seems harmless.

I'd still prefer to only set -R if actually used, but don't care too much :)

@@ -70,7 +81,8 @@
in
{
dev = ''
zpool list '${config.name}' >/dev/null 2>/dev/null || zpool import '${config.name}'
zpool list '${config.name}' >/dev/null 2>/dev/null || \
zpool import -R ${config.mountRoot} '${config.name}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that you set the altroot here, during import, is it even necessary to do so above, during creation, as well? The remark about cachefile=none still applies here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because zpool create mounts the pool already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I am missing something, but why do we need to set altroot during creation? Shouldn't the import suffice to mount it in a live system? I'll try to do a practice test tomorrow

Copy link
Contributor

@oddlama oddlama Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to have -R on create too, otherwise any datasets that have option.mountpoint set will be mounted on top of the live system when they are created. Not setting -R shadows existing mountpoints like /, which would be fatal.

@oddlama
Copy link
Contributor

oddlama commented Apr 29, 2023

LGTM. I'm already relying on this fork to make disko work from a live environment. This is a very important change to support the non-legacy mountpoints.

@Lassulus Lassulus merged commit 617c77a into nix-community:master Apr 29, 2023
@SuperSandro2000 SuperSandro2000 deleted the zpool-R branch May 7, 2023 16:52
@SuperSandro2000
Copy link
Member Author

Shouldn't this use disko.rootMountPoint? #238

@Lassulus
Copy link
Collaborator

disko.rootMountPoint is the location where disko mounts the whole device tree with the mountScript (usually /mnt), this option tells where to mount the zpool to, which can be any folder, this gets appended to the rootMountPoint only when running the mountScript

@SuperSandro2000
Copy link
Member Author

This setting is basically duplicated with disko.rootMountPoint because I didn't know about it when I implemented this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants