summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/diskdrake/interactive.pm8
-rw-r--r--perl-install/fs/format.pm42
-rw-r--r--perl-install/install_steps_interactive.pm8
-rw-r--r--perl-install/loopback.pm2
-rw-r--r--perl-install/raid.pm2
5 files changed, 45 insertions, 17 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index be261c940..97118f376 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -1080,12 +1080,8 @@ sub format_ {
fs::format::check_package_is_installed($in->do_pkgs, $part->{fs_type}) or return;
}
$part->{isFormatted} = 0; #- force format;
- my $w;
- fs::format::part($all_hds->{raids}, $part, $::prefix, sub {
- my ($msg) = @_;
- $w ||= $in->wait_message('', $msg);
- $w->set($msg);
- });
+ my ($_w, $wait_message) = fs::format::wait_message($in);
+ fs::format::part($all_hds->{raids}, $part, $::prefix, $wait_message);
1;
}
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index c0f2f791f..7fd7d012e 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -49,12 +49,12 @@ sub part {
loopback::format_part($part, $prefix);
} else {
$wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
- part_raw($part);
+ part_raw($part, $wait_message);
}
}
sub part_raw {
- my ($part) = @_;
+ my ($part, $wait_message) = @_;
$part->{isFormatted} and return;
@@ -82,7 +82,15 @@ sub part_raw {
my ($_pkg, $cmd, @first_options) = @{$cmds{$fs_type} || die N("I do not know how to format %s in type %s", $part->{device}, $part->{fs_type})};
- run_program::raw({ timeout => 60 * 60 }, $cmd, @first_options, @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev);
+ my @args = ($cmd, @first_options, @options, devices::make($dev));
+
+ my $time = time();
+ if ($cmd eq 'mke2fs' && $wait_message) {
+ mke2fs($wait_message, @args) or die N("%s formatting of %s failed", $fs_type, $dev);
+ } else {
+ run_program::raw({ timeout => 60 * 60 }, @args) or die N("%s formatting of %s failed", $fs_type, $dev);
+ }
+ warn "$cmd took: ", formatTimeRaw(time() - $time);
if ($fs_type eq 'ext3') {
disable_forced_fsck($dev);
@@ -91,9 +99,37 @@ sub part_raw {
set_isFormatted($part, 1);
}
+sub mke2fs {
+ my ($wait_message, @args) = @_;
+
+ open(my $F, "@args |");
+
+ local $/ = "\b";
+ local $_;
+ while (<$F>) {
+ $wait_message->('', $1, $2) if m!^\s*(\d+)/(\d+)\b!;
+ }
+ return close($F);
+}
+
sub disable_forced_fsck {
my ($dev) = @_;
run_program::run("tune2fs", "-c0", "-i0", devices::make($dev));
}
+sub wait_message {
+ my ($in) = @_;
+
+ my $w;
+ $w, sub {
+ my ($msg, $current, $total) = @_;
+ if ($msg) {
+ $w ||= $in->wait_message('', $msg);
+ $w->set($msg);
+ } elsif ($total) {
+ $w->set("$current / $total");
+ }
+ };
+}
+
1;
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index a333c8405..407a909b6 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -367,13 +367,9 @@ sub choosePartitionsToFormat {
sub formatMountPartitions {
my ($o, $_fstab) = @_;
- my $w;
+ my ($w, $wait_message) = fs::format::wait_message($o);
catch_cdie {
- fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}, sub {
- my ($msg) = @_;
- $w ||= $o->wait_message('', $msg);
- $w->set($msg);
- });
+ fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}, $wait_message);
} sub {
$@ =~ /fsck failed on (\S+)/ or return;
$o->ask_yesorno('', N("Failed to check filesystem %s. Do you want to repair the errors? (beware, you can lose data)", $1), 1);
diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm
index a3610ddf0..ba862a14a 100644
--- a/perl-install/loopback.pm
+++ b/perl-install/loopback.pm
@@ -63,7 +63,7 @@ sub format_part {
my ($part, $prefix) = @_;
fs::mount_part($part->{loopback_device}, $prefix);
create($part, $prefix);
- fs::format::part_raw($part);
+ fs::format::part_raw($part, undef);
}
sub create {
diff --git a/perl-install/raid.pm b/perl-install/raid.pm
index 32a57f787..de74f55ef 100644
--- a/perl-install/raid.pm
+++ b/perl-install/raid.pm
@@ -134,7 +134,7 @@ sub format_part {
$part->{isFormatted} and return;
make($raids, $part);
- fs::format::part_raw($part);
+ fs::format::part_raw($part, undef);
set_isFormatted($_, 1) foreach @{$part->{disks}};
}