summaryrefslogtreecommitdiffstats
path: root/rescue/tree/etc/oem
diff options
context:
space:
mode:
Diffstat (limited to 'rescue/tree/etc/oem')
-rwxr-xr-xrescue/tree/etc/oem44
1 files changed, 29 insertions, 15 deletions
diff --git a/rescue/tree/etc/oem b/rescue/tree/etc/oem
index 1bb35aa12..eef09b484 100755
--- a/rescue/tree/etc/oem
+++ b/rescue/tree/etc/oem
@@ -253,10 +253,9 @@ Type \`\`yes'' and [enter] to go on\n"
#- keep the current partition table, and try to resize the fat partition
#- if the size is not 0.
#- KEEP IN MIND there is only one partition defined.
- open F, "| parted -s /dev/$hd";
if ($resize_fat_size) {
$point = $hd_parts[$fat_pos]{start};
- printf F "resize %d %s %s\n", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
+ push @commands, sprintf "resize %d %s %s", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
} else {
$point = $hd_parts[$fat_pos]{end};
}
@@ -273,37 +272,52 @@ Type \`\`yes'' and [enter] to go on\n"
} while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
}
#- build a new disk label here.
- open F, "| parted -s /dev/$hd";
- print F "mklabel msdos\n";
+ push @commands, "mklabel msdos";
}
#- at this point, the partition are created.
-my ($instz, $inst, $swap, $root, $var, $home) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef);
+my ($instz, $inst, $swap, $root, $var, $home, $free) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef, undef);
#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
+my $free_point = $point;
if ($minor == 5) {
- print F "mkpart extended $point $hd_size\n";
+ push @commands, sprintf "mkpart extended %s %s", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
+ 'keepstart');
} else {
$hd_parts[0]{type} eq 'extended' or die "first partition assumed to be extended";
$point = $hd_parts[0]{start};
- print F "resize $hd_parts[0]{minor} $point $hd_size\n";
+ push @commands, sprintf "resize %s %s %s", $hd_parts[0]{minor}, correct_start_end(\$free_point,
+ $hd_size - ($options{free_primary} && $options{free_size}),
+ 'keepstart');
}
-printf F "mkpart logical ext2 %s %s\n", correct_start_end(\$point, $point+$inst_size);
-printf F "mkpart logical linux-swap %s %s\n", correct_start_end(\$point, $point+$swap_size);
-printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$root_size);
+push @commands, sprintf "mkpart logical ext2 %s %s", correct_start_end(\$point, $point+$inst_size);
+push @commands, sprintf "mkpart logical linux-swap %s %s", correct_start_end(\$point, $point+$swap_size);
+push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$root_size);
if (exists $options{server} && $hd !~ /^rd\//) {
my $var_size = ($hd_size - $point) / 2;
if ($var_size > 1500) {
$var = $root+1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$var_size);
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$var_size);
}
}
-if ($hd_size - $point > 100 && $hd !~ /^rd\//) {
+if ($hd_size - $point - $options{free_size} > 100 && $hd !~ /^rd\//) {
$home = ($var || $root) + 1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $hd_size);
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
+}
+if ($options{free_size} && $options{free_fs}) {
+ if ($options{free_primary}) {
+ $free = scalar(grep { $_->{type} eq 'primary' } @hd_parts) + 2;
+ if ($free > 4) {
+ $free = ($home || $var || $root) + 1;
+ delete $options{free_primary};
+ print "Unable to use primary partition for free partition, using logical partition.\n";
+ }
+ } else {
+ $free = ($home || $var || $root) + 1;
+ }
+ push @commands, sprintf "mkpart %s %s %s %s", $options{free_primary} ? 'primary' : 'logical', $options{free_fs} =~ /fat/ ? 'fat' : $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
}
-print F "quit\n";
-close F or die "unable to partition the disk $hd";
+system "parted", "-s", "/dev/$hd", @commands == 0 or die "unable to partition the disk $hd";
#- we have to build swap and mount it.
print "Setting swap\n";