[pve-devel] [PATCH container 1/3] Fix #791: warn when resize2fs fails

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Feb 5 08:49:04 CET 2016


At this point the underlying file has already been
successfully resized which means it makes sense to refelct
that change in the config, but the guest will not see the
effect of it, however, a subsequent resize command will
further increase the size relative to the 'new' size, so
after such an error the best option is to manually deal with
the error and perform the necessary resize steps.
---
 src/PVE/API2/LXC.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 09b71c8..dce851d 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1317,11 +1317,16 @@ __PACKAGE__->register_method({
 			# interestingly we don't need to e2fsck on mounted systems...
 			my $quoted = PVE::Tools::shellquote($path);
 			my $cmd = "mount --make-rprivate / && mount $quoted /tmp && resize2fs $quoted";
-			PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
+			eval {
+			    PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
+			};
 		    } else {
-			PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
-			PVE::Tools::run_command(['resize2fs', $path]);
+			eval {
+			    PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
+			    PVE::Tools::run_command(['resize2fs', $path]);
+			};
 		    }
+		    warn "Failed to update the container's filesystem: $@\n";
 		}
 	    };
 
-- 
2.1.4





More information about the pve-devel mailing list