]> git.proxmox.com Git - pve-container.git/commitdiff
pct fstrim: add 'ignore-mountpoints' parameter
authorOguz Bektas <o.bektas@proxmox.com>
Thu, 29 Oct 2020 10:09:21 +0000 (11:09 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 29 Oct 2020 12:12:35 +0000 (13:12 +0100)
parameter to ignore mountpoints when doing fstrim on a container

root@pve:~# pct fstrim 123
/var/lib/lxc/123/rootfs/: 338.7 MiB (355094528 bytes) trimmed
/var/lib/lxc/123/rootfs/test: 8.9 GiB (9576009728 bytes) trimmed
root@pve:~# pct fstrim 123 --ignore-mountpoints
/var/lib/lxc/123/rootfs/: 338.7 MiB (355094528 bytes) trimmed

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
src/PVE/CLI/pct.pm

index df4e9f8f19dacc876a0795d96128bb3b52c8677e..ff021128534f4efdebea102453b36df331969b30 100755 (executable)
@@ -767,6 +767,11 @@ __PACKAGE__->register_method ({
        additionalProperties => 0,
        properties => {
            vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
+           'ignore-mountpoints' => {
+               description => 'ignore mountpoints when doing an fstrim operation for a container.',
+               optional => 1,
+               type => 'boolean',
+           },
        },
     },
     returns => { type => 'null' },
@@ -785,6 +790,7 @@ __PACKAGE__->register_method ({
            PVE::LXC::Config->foreach_volume($conf, sub {
                my ($name, $mp) = @_;
                $path = $mp->{mp};
+               return if $param->{'ignore-mountpoints'} && $name =~ /^mp\d+/;
                my $cmd = ["fstrim", "-v", "$rootdir$path"];
                PVE::Tools::run_command($cmd);
            });