@@ -29,10 +29,8 @@ use super::RW_KARG;
29
29
use crate :: mount;
30
30
use crate :: task:: Task ;
31
31
32
- pub ( crate ) const BOOTPN : u32 = 3 ;
33
32
// This ensures we end up under 512 to be small-sized.
34
33
pub ( crate ) const BOOTPN_SIZE_MB : u32 = 510 ;
35
- pub ( crate ) const EFIPN : u32 = 2 ;
36
34
pub ( crate ) const EFIPN_SIZE_MB : u32 = 512 ;
37
35
38
36
#[ derive( clap:: ValueEnum , Debug , Copy , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
@@ -239,6 +237,8 @@ pub(crate) fn install_create_rootfs(
239
237
let bootfs = mntdir. join ( "boot" ) ;
240
238
std:: fs:: create_dir_all ( bootfs) ?;
241
239
240
+ let mut partno = 0 ;
241
+
242
242
// Run sgdisk to create partitions.
243
243
let mut sgdisk = Task :: new ( "Initializing partitions" , "sgdisk" ) ;
244
244
// sgdisk is too verbose
@@ -249,18 +249,20 @@ pub(crate) fn install_create_rootfs(
249
249
#[ allow( unused_assignments) ]
250
250
if cfg ! ( target_arch = "x86_64" ) {
251
251
// BIOS-BOOT
252
+ partno += 1 ;
252
253
sgdisk_partition (
253
254
& mut sgdisk. cmd ,
254
- 1 ,
255
+ partno ,
255
256
"0:+1M" ,
256
257
"BIOS-BOOT" ,
257
258
Some ( "21686148-6449-6E6F-744E-656564454649" ) ,
258
259
) ;
259
260
} else if cfg ! ( target_arch = "aarch64" ) {
260
261
// reserved
262
+ partno += 1 ;
261
263
sgdisk_partition (
262
264
& mut sgdisk. cmd ,
263
- 1 ,
265
+ partno ,
264
266
"0:+1M" ,
265
267
"reserved" ,
266
268
Some ( "8DA63339-0007-60C0-C436-083AC8230908" ) ,
@@ -270,24 +272,23 @@ pub(crate) fn install_create_rootfs(
270
272
}
271
273
272
274
let esp_partno = if super :: ARCH_USES_EFI {
275
+ partno += 1 ;
273
276
sgdisk_partition (
274
277
& mut sgdisk. cmd ,
275
- EFIPN ,
278
+ partno ,
276
279
format ! ( "0:+{EFIPN_SIZE_MB}M" ) ,
277
280
"EFI-SYSTEM" ,
278
281
Some ( "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" ) ,
279
282
) ;
280
- Some ( EFIPN )
283
+ Some ( partno )
281
284
} else {
282
285
None
283
286
} ;
284
287
285
288
// Initialize the /boot filesystem. Note that in the future, we may match
286
289
// what systemd/uapi-group encourages and make /boot be FAT32 as well, as
287
290
// it would aid systemd-boot.
288
- let use_xbootldr = block_setup. requires_bootpart ( ) ;
289
- let mut partno = EFIPN ;
290
- if use_xbootldr {
291
+ let boot_partno = if block_setup. requires_bootpart ( ) {
291
292
partno += 1 ;
292
293
sgdisk_partition (
293
294
& mut sgdisk. cmd ,
@@ -296,8 +297,11 @@ pub(crate) fn install_create_rootfs(
296
297
"boot" ,
297
298
None ,
298
299
) ;
299
- }
300
- let rootpn = if use_xbootldr { BOOTPN + 1 } else { EFIPN + 1 } ;
300
+ Some ( partno)
301
+ } else {
302
+ None
303
+ } ;
304
+ let rootpn = partno + 1 ;
301
305
let root_size = root_size
302
306
. map ( |v| Cow :: Owned ( format ! ( "0:{v}M" ) ) )
303
307
. unwrap_or_else ( || Cow :: Borrowed ( "0:0" ) ) ;
@@ -379,8 +383,8 @@ pub(crate) fn install_create_rootfs(
379
383
} ;
380
384
381
385
// Initialize the /boot filesystem
382
- let bootdev = if use_xbootldr {
383
- Some ( findpart ( BOOTPN ) ?)
386
+ let bootdev = if let Some ( bootpn ) = boot_partno {
387
+ Some ( findpart ( bootpn ) ?)
384
388
} else {
385
389
None
386
390
} ;
0 commit comments