]> git.proxmox.com Git - pve-container.git/commitdiff
mkfs: make less noisy
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 25 Jan 2021 19:15:24 +0000 (20:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 25 Jan 2021 19:15:26 +0000 (20:15 +0100)
Easiest and cleanest would be to pass the -q quiet parameter, but
that drops also possible relevant information when rescuing such a
filesystem (super block backup positions, UUID, ...)

Will let thorugh something like:

> Creating filesystem with 262144 4k blocks and 65536 inodes
> Filesystem UUID: 3a6f3548-baf6-45fa-93d2-b61212668d23
> Superblock backups stored on blocks:
>  32768, 98304, 163840, 229376

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC.pm

index 5de5c80d32465ad46ce4fe520cf48f01f04b78c1..0b4ab069bf9f92a717fee255c61ad4fdebd5e39c 100644 (file)
@@ -1793,9 +1793,27 @@ sub get_staging_tempfs() {
 sub mkfs {
     my ($dev, $rootuid, $rootgid) = @_;
 
-    run_command(['mkfs.ext4', '-O', 'mmp',
-                            '-E', "root_owner=$rootuid:$rootgid",
-                            $dev]);
+    run_command(
+       [
+           'mkfs.ext4',
+           '-O',
+           'mmp',
+           '-E',
+           "root_owner=$rootuid:$rootgid",
+           $dev,
+       ],
+       outfunc => sub {
+           my $line = shift;
+           # a hack to print only the relevant stuff, i.e., the one which could help on repair
+           if ($line =~ /^(Creating filesystem|Filesystem UUID|Superblock backups|\s+\d+, \d)/) {
+               print "$line\n";
+           }
+       },
+       errfunc => sub {
+           my $line = shift;
+           print STDERR "$line\n" if $line && $line !~ /^mke2fs \d\.\d/;
+       }
+    );
 }
 
 sub format_disk {