From 06c7c7f15f5e5d06148bdf77d0d63050d314fb3d Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 25 Jan 2021 20:15:24 +0100 Subject: [PATCH] mkfs: make less noisy 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 --- src/PVE/LXC.pm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 5de5c80..0b4ab06 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -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 { -- 2.39.5