[pve-devel] [PATCH v2 container] pct fstrim: add 'ignore-mountpoints' parameter

Oguz Bektas o.bektas at proxmox.com
Thu Oct 29 11:09:21 CET 2020


parameter to ignore mountpoints when doing fstrim on a container

root at 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 at pve:~# pct fstrim 123 --ignore-mountpoints
/var/lib/lxc/123/rootfs/: 338.7 MiB (355094528 bytes) trimmed

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---

thanks thomas for the review :)

v1->v2:
* change to kebab casing
* add description
* revert the 'warn' change
* use the regex in //



 src/PVE/CLI/pct.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index df4e9f8..ff02112 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -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);
 	    });
-- 
2.20.1





More information about the pve-devel mailing list