]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/API2/Disks.pm
prune: mark renamed and protected backups differently
[pve-storage.git] / PVE / API2 / Disks.pm
index 6c20931d5d4cecca85c937005c076e50f9779981..25c9ded4eb7a273beaf0631cb8af92e40ce36742 100644 (file)
@@ -9,6 +9,7 @@ use HTTP::Status qw(:constants);
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::SafeSyslog;
+use PVE::Tools qw(run_command);
 
 use PVE::API2::Disks::Directory;
 use PVE::API2::Disks::LVM;
@@ -259,6 +260,7 @@ __PACKAGE__->register_method ({
 
        my $authuser = $rpcenv->get_user();
 
+       die "$disk is a partition\n" if PVE::Diskmanage::is_partition($disk);
        die "disk $disk already in use\n" if PVE::Diskmanage::disk_is_used($disk);
        my $worker = sub {
            PVE::Diskmanage::init_disk($disk, $param->{uuid});
@@ -302,7 +304,15 @@ __PACKAGE__->register_method ({
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
-       my $worker = sub { PVE::Diskmanage::wipe_blockdev($disk); };
+       my $worker = sub {
+           PVE::Diskmanage::wipe_blockdev($disk);
+
+           # FIXME: Remove once we depend on systemd >= v249.
+           # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
+           # udev database is updated.
+           eval { run_command(['udevadm', 'trigger', $disk]); };
+           warn $@ if $@;
+       };
 
        my $basename = basename($disk); # avoid '/' in the ID