| 1 |
mt |
5379 |
2009-04-28 Michael Tautschnig <mt@debian.org> |
| 2 |
mt |
5287 |
|
| 3 |
mt |
5289 |
* setup-storage/Parser.pm, setup-storage/Sizes.pm, setup-storage/Volumes.pm: |
| 4 |
|
|
Added pseudo-disklabel gpt-bios to support GPT on systems with BIOS instead |
| 5 |
mt |
5295 |
of EFI. Also installs an additional partition to store whatever doesn't fit |
| 6 |
|
|
into MBR. |
| 7 |
mt |
5287 |
Index: trunk/lib/setup-storage/Commands.pm |
| 8 |
|
|
=================================================================== |
| 9 |
|
|
--- trunk.orig/lib/setup-storage/Commands.pm |
| 10 |
|
|
+++ trunk/lib/setup-storage/Commands.pm |
| 11 |
mt |
5323 |
@@ -673,16 +673,17 @@ |
| 12 |
mt |
5289 |
# the list of partitions that must be preserved |
| 13 |
|
|
my @to_preserve = &FAI::get_preserved_partitions($config); |
| 14 |
|
|
|
| 15 |
|
|
+ my $label = $FAI::configs{$config}{disklabel}; |
| 16 |
|
|
+ $label = "gpt" if ($label eq "gpt-bios"); |
| 17 |
|
|
# A new disk label may only be written if no partitions need to be |
| 18 |
|
|
# preserved |
| 19 |
|
|
- (($FAI::configs{$config}{disklabel} eq |
| 20 |
|
|
- $FAI::current_config{$disk}{disklabel}) |
| 21 |
|
|
+ (($label eq $FAI::current_config{$disk}{disklabel}) |
| 22 |
|
|
|| (scalar (@to_preserve) == 0)) |
| 23 |
|
|
or die "Can't change disklabel, partitions are to be preserved\n"; |
| 24 |
|
|
|
| 25 |
|
|
# write the disklabel to drop the previous partition table |
| 26 |
|
|
- &FAI::push_command( "parted -s $disk mklabel " . |
| 27 |
|
|
- $FAI::configs{$config}{disklabel}, "exist_$disk", "cleared1_$disk" ); |
| 28 |
|
|
+ &FAI::push_command( "parted -s $disk mklabel $label", "exist_$disk", |
| 29 |
|
|
+ "cleared1_$disk" ); |
| 30 |
|
|
|
| 31 |
|
|
&FAI::rebuild_preserved_partitions($config, \@to_preserve); |
| 32 |
|
|
|
| 33 |
mt |
5323 |
@@ -785,9 +786,8 @@ |
| 34 |
mt |
5289 |
|
| 35 |
|
|
# write the disklabel again to drop the partition table and create a new one |
| 36 |
|
|
# that has the proper ids |
| 37 |
|
|
- &FAI::push_command( "parted -s $disk mklabel " . |
| 38 |
|
|
- $FAI::configs{$config}{disklabel}, "cleared1_$disk$pre_all_resize", |
| 39 |
|
|
- "cleared2_$disk" ); |
| 40 |
|
|
+ &FAI::push_command( "parted -s $disk mklabel $label", |
| 41 |
|
|
+ "cleared1_$disk$pre_all_resize", "cleared2_$disk" ); |
| 42 |
|
|
|
| 43 |
|
|
my $prev_id = -1; |
| 44 |
|
|
# generate the commands for creating all partitions |
| 45 |
mt |
5323 |
@@ -837,6 +837,14 @@ |
| 46 |
mt |
5287 |
&FAI::make_device_name($disk, $FAI::configs{$config}{bootable}), |
| 47 |
|
|
"boot_set_$disk" ); |
| 48 |
|
|
} |
| 49 |
mt |
5295 |
+ |
| 50 |
|
|
+ # set the bios_grub flag on BIOS compatible GPT tables |
| 51 |
|
|
+ if ($FAI::configs{$config}{disklabel} eq "gpt-bios") { |
| 52 |
|
|
+ &FAI::push_command( "parted -s $disk set " . |
| 53 |
|
|
+ $FAI::configs{$config}{gpt_bios_part} . " bios_grub on", "exist_" . |
| 54 |
|
|
+ &FAI::make_device_name($disk, $FAI::configs{$config}{gpt_bios_part}), |
| 55 |
|
|
+ "bios_grub_set_$disk" ); |
| 56 |
|
|
+ } |
| 57 |
|
|
} |
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
mt |
5287 |
Index: trunk/lib/setup-storage/Parser.pm |
| 61 |
|
|
=================================================================== |
| 62 |
|
|
--- trunk.orig/lib/setup-storage/Parser.pm |
| 63 |
|
|
+++ trunk/lib/setup-storage/Parser.pm |
| 64 |
|
|
@@ -431,7 +431,7 @@ |
| 65 |
|
|
$FAI::configs{$FAI::device}{partitions}{$_}{size}{resize} = 1 foreach (split(",", $1)); |
| 66 |
|
|
$FAI::configs{$FAI::device}{preserveparts} = 1; |
| 67 |
|
|
} |
| 68 |
|
|
- | /^disklabel:(msdos|gpt)/ |
| 69 |
mt |
5288 |
+ | /^disklabel:(msdos|gpt-bios|gpt)/ |
| 70 |
mt |
5287 |
{ |
| 71 |
|
|
# set the disk label - actually not only the above, but all types |
| 72 |
|
|
# supported by parted could be allowed, but others are not implemented |
| 73 |
|
|
Index: trunk/lib/setup-storage/Sizes.pm |
| 74 |
|
|
=================================================================== |
| 75 |
|
|
--- trunk.orig/lib/setup-storage/Sizes.pm |
| 76 |
|
|
+++ trunk/lib/setup-storage/Sizes.pm |
| 77 |
mt |
5328 |
@@ -353,7 +353,8 @@ |
| 78 |
mt |
5287 |
} |
| 79 |
|
|
|
| 80 |
|
|
# on gpt, ensure that the partition ends at a sector boundary |
| 81 |
|
|
- if ($FAI::configs{$config}{disklabel} eq "gpt") { |
| 82 |
|
|
+ if ($FAI::configs{$config}{disklabel} eq "gpt" || |
| 83 |
|
|
+ $FAI::configs{$config}{disklabel} eq "gpt-bios") { |
| 84 |
|
|
(0 == ($current_disk->{partitions}{$part_id}{end_byte} + 1) |
| 85 |
|
|
% $current_disk->{sector_size}) |
| 86 |
|
|
or die "Preserved partition $part_id does not end at a sector boundary\n"; |
| 87 |
mt |
5328 |
@@ -548,7 +549,8 @@ |
| 88 |
mt |
5287 |
} |
| 89 |
|
|
|
| 90 |
|
|
# on gpt, ensure that the partition ends at a sector boundary |
| 91 |
|
|
- if ($FAI::configs{$config}{disklabel} eq "gpt") { |
| 92 |
|
|
+ if ($FAI::configs{$config}{disklabel} eq "gpt" || |
| 93 |
|
|
+ $FAI::configs{$config}{disklabel} eq "gpt-bios") { |
| 94 |
|
|
$end_byte -= |
| 95 |
|
|
($end_byte + 1) % $current_disk->{sector_size}; |
| 96 |
|
|
} |
| 97 |
mt |
5328 |
@@ -621,18 +623,17 @@ |
| 98 |
mt |
5295 |
# the start byte for the next partition |
| 99 |
|
|
my $next_start = 0; |
| 100 |
mt |
5287 |
|
| 101 |
mt |
5295 |
- # on msdos disk labels, the first partitions starts at head #1 |
| 102 |
|
|
if ($FAI::configs{$config}{disklabel} eq "msdos") { |
| 103 |
|
|
+ # on msdos disk labels, the first partitions starts at head #1 |
| 104 |
|
|
$next_start = $current_disk->{bios_sectors_per_track} * |
| 105 |
|
|
$current_disk->{sector_size}; |
| 106 |
|
|
|
| 107 |
|
|
# the MBR requires space, too |
| 108 |
|
|
$min_req_total_space += $current_disk->{bios_sectors_per_track} * |
| 109 |
|
|
$current_disk->{sector_size}; |
| 110 |
|
|
- } |
| 111 |
|
|
|
| 112 |
|
|
- # on GPT disk labels the first 34 and last 34 sectors must be left alone |
| 113 |
mt |
5287 |
- if ($FAI::configs{$config}{disklabel} eq "gpt") { |
| 114 |
mt |
5295 |
+ } elsif ($FAI::configs{$config}{disklabel} eq "gpt") { |
| 115 |
|
|
+ # on GPT-EFI disk labels the first 34 and last 34 sectors must be left alone |
| 116 |
mt |
5287 |
$next_start = 34 * $current_disk->{sector_size}; |
| 117 |
|
|
|
| 118 |
|
|
# modify the disk to claim the space for the second partition table |
| 119 |
mt |
5379 |
@@ -640,6 +641,28 @@ |
| 120 |
mt |
5287 |
|
| 121 |
mt |
5295 |
# the space required by the GPTs |
| 122 |
|
|
$min_req_total_space += 2 * 34 * $current_disk->{sector_size}; |
| 123 |
|
|
+ |
| 124 |
|
|
+ } elsif ($FAI::configs{$config}{disklabel} eq "gpt-bios") { |
| 125 |
|
|
+ # on BIOS-style disk labels, the first partitions starts at head #1 |
| 126 |
|
|
+ $next_start = $current_disk->{bios_sectors_per_track} * |
| 127 |
|
|
+ $current_disk->{sector_size}; |
| 128 |
|
|
+ |
| 129 |
|
|
+ # the MBR requires space, too |
| 130 |
|
|
+ $min_req_total_space += $current_disk->{bios_sectors_per_track} * |
| 131 |
|
|
+ $current_disk->{sector_size}; |
| 132 |
|
|
+ |
| 133 |
|
|
+ # on gpt-bios we'll need an additional partition to store what doesn't fit |
| 134 |
|
|
+ # in the MBR |
| 135 |
|
|
+ $FAI::device = $config; |
| 136 |
mt |
5297 |
+ &FAI::init_part_config("primary"); |
| 137 |
mt |
5295 |
+ $FAI::configs{$config}{gpt_bios_part} = $FAI::partition_pointer->{number}; |
| 138 |
|
|
+ my $s = &FAI::convert_unit("120k"); |
| 139 |
|
|
+ # enter the range into the hash |
| 140 |
|
|
+ $FAI::partition_pointer->{size}->{range} = "$s-$s"; |
| 141 |
mt |
5379 |
+ # set proper defaults |
| 142 |
|
|
+ $FAI::partition_pointer->{encrypt} = 0; |
| 143 |
|
|
+ $FAI::partition_pointer->{filesystem} = "-"; |
| 144 |
|
|
+ $FAI::partition_pointer->{mountpoint} = "-"; |
| 145 |
mt |
5295 |
} |
| 146 |
|
|
|
| 147 |
|
|
# the list of partitions that we need to find start and end bytes for |
| 148 |
mt |
5379 |
@@ -690,7 +713,7 @@ |
| 149 |
mt |
5295 |
|
| 150 |
mt |
5287 |
# msdos does not support partitions larger than 2TB |
| 151 |
|
|
($part->{size}->{eff_size} > (&FAI::convert_unit("2TB") * 1024.0 * |
| 152 |
|
|
- 1024.0)) and die "msdos disklabel does not support partitions > 2TB, please use disklabel:gpt\n" |
| 153 |
|
|
+ 1024.0)) and die "msdos disklabel does not support partitions > 2TB, please use disklabel:gpt or gpt-bios\n" |
| 154 |
|
|
if ($FAI::configs{$config}{disklabel} eq "msdos"); |
| 155 |
|
|
# partition done |
| 156 |
|
|
shift @worklist; |
| 157 |
|
|
Index: trunk/man/setup-storage.8 |
| 158 |
|
|
=================================================================== |
| 159 |
|
|
--- trunk.orig/man/setup-storage.8 |
| 160 |
|
|
+++ trunk/man/setup-storage.8 |
| 161 |
|
|
@@ -216,7 +216,7 @@ |
| 162 |
|
|
.br |
| 163 |
|
|
/* attempt to resize partitions */ |
| 164 |
|
|
.br |
| 165 |
|
|
- | disklabel:(msdos|gpt) |
| 166 |
|
|
+ | disklabel:(msdos|gpt|gpt-bios) |
| 167 |
|
|
.br |
| 168 |
|
|
/* write a disklabel - default is msdos */ |
| 169 |
|
|
.br |
| 170 |
mt |
5289 |
Index: trunk/lib/setup-storage/Volumes.pm |
| 171 |
|
|
=================================================================== |
| 172 |
|
|
--- trunk.orig/lib/setup-storage/Volumes.pm |
| 173 |
|
|
+++ trunk/lib/setup-storage/Volumes.pm |
| 174 |
|
|
@@ -78,8 +78,9 @@ |
| 175 |
|
|
"Can't run on test-only mode on this system because there is no disklabel on $disk\n"; |
| 176 |
|
|
|
| 177 |
|
|
# write the disk label as configured |
| 178 |
|
|
- $error = &FAI::execute_command("parted -s $disk mklabel " |
| 179 |
|
|
- . $FAI::configs{"PHY_$disk"}{disklabel}); |
| 180 |
|
|
+ my $label = $FAI::configs{"PHY_$disk"}{disklabel}; |
| 181 |
|
|
+ $label = "gpt" if ($label eq "gpt-bios"); |
| 182 |
|
|
+ $error = &FAI::execute_command("parted -s $disk mklabel $label"); |
| 183 |
|
|
($error eq "") or die "Failed to write disk label\n"; |
| 184 |
|
|
# retry partition-table print |
| 185 |
|
|
$error = |