From f720f6c4405db1dea02929c51ebefedd7593d646 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Wed, 16 Sep 2020 14:14:19 +0200 Subject: [PATCH] Disks: instantiate import unit for created zpool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Stoiko Ivanov --- 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',