When creating a new ZFS storage, also instantiate an import-unit for the pool.
This should help mitigate the case where some pools don't get imported during
boot, because they are not listed in an existing zpool.cache file.

This patch needs the corresponding addition of 'zfs-import@.service' in
the zfsonlinux repository.

Suggested-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com>
---
 PVE/API2/Disks/ZFS.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/API2/Disks/ZFS.pm b/PVE/API2/Disks/ZFS.pm
index 7a633a7..66b26e9 100644
--- a/PVE/API2/Disks/ZFS.pm
+++ b/PVE/API2/Disks/ZFS.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::Systemd;
 use PVE::API2::Storage::Config;
 use PVE::Storage;
 use PVE::Tools qw(run_command lock_file trim);
@@ -393,6 +394,11 @@ __PACKAGE__->register_method ({
                print "# ", join(' ', @$cmd), "\n";
                run_command($cmd);
 
+               my $importunit = 'zfs-import@'. 
PVE::Systemd::escape_unit($name, undef) . '.service';
+               $cmd = ['systemctl', 'enable', $importunit];
+               print "# ", join(' ', @$cmd), "\n";
+               run_command($cmd);
+
                if ($param->{add_storage}) {
                    my $storage_params = {
                        type => 'zfspool',
-- 
2.20.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to