[pbs-devel] [RFC storage 1/1] Disks: instantiate import unit for created zpool

Stoiko Ivanov s.ivanov at proxmox.com
Wed Sep 16 14:14:19 CEST 2020


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 at .service' in
the zfsonlinux repository.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at 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






More information about the pbs-devel mailing list