summaryrefslogtreecommitdiffstats
path: root/rescue/tree/etc/oem
diff options
context:
space:
mode:
Diffstat (limited to 'rescue/tree/etc/oem')
-rwxr-xr-xrescue/tree/etc/oem62
1 files changed, 50 insertions, 12 deletions
diff --git a/rescue/tree/etc/oem b/rescue/tree/etc/oem
index 01f76805b..e1a546531 100755
--- a/rescue/tree/etc/oem
+++ b/rescue/tree/etc/oem
@@ -80,7 +80,31 @@ foreach (keys %options) {
#- if only a fat partition is found, resize it do include the above partition.
#- other combination are really dangerous and are not supported, ask
#- the user that all data on the disk will be erased and go on.
-my ($hd_size, @hd_parts);
+my ($heads, $sectors, $cylinders, $hd_size, @hd_parts);
+sub correct_start_end {
+ my ($rstart, $end, $keep_start) = @_;
+ my ($cylinder_size, $c_start, $c_end) = ($sectors*$heads*512/1024/1024, undef, undef);
+ if (abs($cylinder_size*$cylinders-$hd_size)/$hd_size < 0.01) {
+ $c_start = $$rstart+($keep_start ? 0 : $cylinder_size/$heads);
+ $c_end = $cylinder_size*int(1/2+$end/$cylinder_size);
+ $c_end > $hd_size and $c_end = $hd_size;
+ $$rstart = $c_end;
+ } else {
+ $c_start = $$rstart;
+ $c_end = $end;
+ $c_end > $hd_size and $c_end = $hd_size;
+ $$rstart = $c_end+5; #- fall back to use a problable safe method.
+ }
+ $c_start >= $c_end and die "no space left for partitionning\n";
+ ($c_start, $c_end);
+}
+open F, "fdisk -l /dev/$hd |";
+while (<F>) {
+ /(\d+)\s*heads/ and $heads = $1;
+ /(\d+)\s*sectors/ and $sectors = $1;
+ /(\d+)\s*cylinders/ and $cylinders = $1;
+}
+close F;
for (1..2) {
open F, "parted /dev/$hd print |";
while (<F>) {
@@ -112,8 +136,7 @@ if (@hd_parts == 1 && $hd_parts[$fat_pos = 0]{fstype} eq 'FAT' ||
@hd_parts == 2 && $hd_parts[0]{type} eq 'primary' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
@hd_parts == 3 && $hd_parts[0]{type} eq 'primary' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 2]{fstype} eq 'FAT' ||
@hd_parts == 2 && $hd_parts[0]{type} eq 'extended' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'extended' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 5]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'primary' && $hd_parts[1]{type} eq 'extended' && $hd_parts[$fat_pos = 5]{fstype} eq 'FAT') {
+ @hd_parts == 3 && $hd_parts[0]{type} eq 'extended' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 5]{fstype} eq 'FAT') {
if ($hd_size - $hd_parts[$fat_pos]{end} > $min_size) {
#- check first if there are some available space left on the disk.
#- so we are using it, root_size is fixed to match hard disk size.
@@ -145,7 +168,7 @@ if (defined $resize_fat_size) {
print "
!!An existing Windows partition has been found and will be kept.
-Additional Linux partition will be created!!
+Additional Linux partitions will be created!!
Type \`\`yes'' and [enter] to go on\n"
} while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
@@ -154,8 +177,8 @@ Type \`\`yes'' and [enter] to go on\n"
#- 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} + $resize_fat_size;
- printf F "resize %d %s %s\n", $hd_parts[$fat_pos]{minor}, $hd_parts[$fat_pos]{start}, $point;
+ $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');
} else {
$point = $hd_parts[$fat_pos]{end};
}
@@ -176,7 +199,7 @@ Type \`\`yes'' and [enter] to go on\n"
}
#- at this point, the partition are created.
-my ($instz, $inst, $swap, $root, $var) = ($minor-1, $minor, $minor+1, $minor+2, undef);
+my ($instz, $inst, $swap, $root, $var, $home) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef);
#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
if ($minor == 5) {
@@ -186,16 +209,20 @@ if ($minor == 5) {
$point = $hd_parts[0]{start};
print F "resize $hd_parts[0]{minor} $point $hd_size\n";
}
-printf F "mkpart logical ext2 %s %s\n", $point, $point+$inst_size; $point+=$inst_size+5;
-printf F "mkpart logical linux-swap %s %s\n", $point, $point+$swap_size; $point+=$swap_size+5;
-printf F "mkpart logical ext2 %s %s\n", $point, $point+$root_size < $hd_size ? $point+$root_size : $hd_size; $point+=$root_size+5;
+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 ext2 %s %s\n", correct_start_end(\$point, $point+$root_size);
if (exists $options{server}) {
my $var_size = ($hd_size - $point) / 2;
if ($var_size > 1500) {
- $var = $minor+3;
- printf F "mkpart logical ext2 %s %s\n", $point, $point+$var_size < $hd_size ? $point+$var_size : $hd_size;
+ $var = $root+1;
+ printf F "mkpart logical ext2 %s %s\n", correct_start_end(\$point, $point+$var_size);
}
}
+if ($hd_size - $point > 100) {
+ $home = ($var || $root) + 1;
+ printf F "mkpart logical ext2 %s %s\n", correct_start_end(\$point, $hd_size);
+}
print F "quit\n";
close F or die "unable to partition the disk $hd";
@@ -213,6 +240,10 @@ if ($var) {
print "Formatting /dev/$hd$var partition\n";
system "mkfs.ext2", "/dev/$hd$var";
}
+if ($home) {
+ print "Formatting /dev/$hd$home partition\n";
+ system "mkfs.ext2", "/dev/$hd$home";
+}
print "Mounting partitions\n";
mkdir "/hd";
@@ -223,6 +254,10 @@ if ($var) {
mkdir "/mnt/var";
system "mount", "-t", "ext2", "/dev/$hd$var", "/mnt/var";
}
+if ($home) {
+ mkdir "/mnt/home";
+ system "mount", "-t", "ext2", "/dev/$hd$home", "/mnt/home";
+}
print "Copying installation on hard drive\n";
if (-e "/boot/vmlinuz" && -e "/boot/hd.rdz" || -e "/cdrom/boot/vmlinuz" && -e "/cdrom/boot/hd.rdz") {
@@ -384,6 +419,9 @@ print F "/dev/$hd$root / ext2 defaults 1 1\n";
if ($var) {
print F "/dev/$hd$var /var ext2 defaults 1 2\n";
}
+if ($home) {
+ print F "/dev/$hd$home /home ext2 defaults 1 2\n";
+}
close F;
open F, ">/mnt/etc/sysconfig/i18n";
print F "LANG=$lang\n";