/[fai]/people/michael/experimental/patches/setup-storage_gpt-bios
ViewVC logotype

Contents of /people/michael/experimental/patches/setup-storage_gpt-bios

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5328 - (show annotations) (download)
Wed Apr 15 21:16:16 2009 UTC (4 years, 2 months ago) by mt
File size: 7615 byte(s)
Removed patches that were merged into trunk, updated patch line numbers
1 2009-03-25 Michael Tautschnig <mt@debian.org>
2
3 * 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 of EFI. Also installs an additional partition to store whatever doesn't fit
6 into MBR.
7 Index: trunk/lib/setup-storage/Commands.pm
8 ===================================================================
9 --- trunk.orig/lib/setup-storage/Commands.pm
10 +++ trunk/lib/setup-storage/Commands.pm
11 @@ -673,16 +673,17 @@
12 # 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 @@ -785,9 +786,8 @@
34
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 @@ -837,6 +837,14 @@
46 &FAI::make_device_name($disk, $FAI::configs{$config}{bootable}),
47 "boot_set_$disk" );
48 }
49 +
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 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 + | /^disklabel:(msdos|gpt-bios|gpt)/
70 {
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 @@ -353,7 +353,8 @@
78 }
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 @@ -548,7 +549,8 @@
88 }
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 @@ -621,18 +623,17 @@
98 # the start byte for the next partition
99 my $next_start = 0;
100
101 - # 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 - if ($FAI::configs{$config}{disklabel} eq "gpt") {
114 + } 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 $next_start = 34 * $current_disk->{sector_size};
117
118 # modify the disk to claim the space for the second partition table
119 @@ -640,6 +641,24 @@
120
121 # 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 + &FAI::init_part_config("primary");
137 + $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 }
142
143 # the list of partitions that we need to find start and end bytes for
144 @@ -690,7 +709,7 @@
145
146 # msdos does not support partitions larger than 2TB
147 ($part->{size}->{eff_size} > (&FAI::convert_unit("2TB") * 1024.0 *
148 - 1024.0)) and die "msdos disklabel does not support partitions > 2TB, please use disklabel:gpt\n"
149 + 1024.0)) and die "msdos disklabel does not support partitions > 2TB, please use disklabel:gpt or gpt-bios\n"
150 if ($FAI::configs{$config}{disklabel} eq "msdos");
151 # partition done
152 shift @worklist;
153 Index: trunk/man/setup-storage.8
154 ===================================================================
155 --- trunk.orig/man/setup-storage.8
156 +++ trunk/man/setup-storage.8
157 @@ -216,7 +216,7 @@
158 .br
159 /* attempt to resize partitions */
160 .br
161 - | disklabel:(msdos|gpt)
162 + | disklabel:(msdos|gpt|gpt-bios)
163 .br
164 /* write a disklabel - default is msdos */
165 .br
166 Index: trunk/lib/setup-storage/Volumes.pm
167 ===================================================================
168 --- trunk.orig/lib/setup-storage/Volumes.pm
169 +++ trunk/lib/setup-storage/Volumes.pm
170 @@ -78,8 +78,9 @@
171 "Can't run on test-only mode on this system because there is no disklabel on $disk\n";
172
173 # write the disk label as configured
174 - $error = &FAI::execute_command("parted -s $disk mklabel "
175 - . $FAI::configs{"PHY_$disk"}{disklabel});
176 + my $label = $FAI::configs{"PHY_$disk"}{disklabel};
177 + $label = "gpt" if ($label eq "gpt-bios");
178 + $error = &FAI::execute_command("parted -s $disk mklabel $label");
179 ($error eq "") or die "Failed to write disk label\n";
180 # retry partition-table print
181 $error =

  ViewVC Help
Powered by ViewVC 1.1.5