@@ -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 ) ]
@@ -240,6 +238,8 @@ pub(crate) fn install_create_rootfs(
240
238
let bootfs = mntdir. join ( "boot" ) ;
241
239
std:: fs:: create_dir_all ( bootfs) ?;
242
240
241
+ let mut partno = 0 ;
242
+
243
243
// Run sgdisk to create partitions.
244
244
let mut sgdisk = Task :: new ( "Initializing partitions" , "sgdisk" ) ;
245
245
// sgdisk is too verbose
@@ -250,18 +250,20 @@ pub(crate) fn install_create_rootfs(
250
250
#[ allow( unused_assignments) ]
251
251
if cfg ! ( target_arch = "x86_64" ) {
252
252
// BIOS-BOOT
253
+ partno += 1 ;
253
254
sgdisk_partition (
254
255
& mut sgdisk. cmd ,
255
- 1 ,
256
+ partno ,
256
257
"0:+1M" ,
257
258
"BIOS-BOOT" ,
258
259
Some ( "21686148-6449-6E6F-744E-656564454649" ) ,
259
260
) ;
260
261
} else if cfg ! ( target_arch = "aarch64" ) {
261
262
// reserved
263
+ partno += 1 ;
262
264
sgdisk_partition (
263
265
& mut sgdisk. cmd ,
264
- 1 ,
266
+ partno ,
265
267
"0:+1M" ,
266
268
"reserved" ,
267
269
Some ( "8DA63339-0007-60C0-C436-083AC8230908" ) ,
@@ -271,24 +273,23 @@ pub(crate) fn install_create_rootfs(
271
273
}
272
274
273
275
let esp_partno = if super :: ARCH_USES_EFI {
276
+ partno += 1 ;
274
277
sgdisk_partition (
275
278
& mut sgdisk. cmd ,
276
- EFIPN ,
279
+ partno ,
277
280
format ! ( "0:+{EFIPN_SIZE_MB}M" ) ,
278
281
"EFI-SYSTEM" ,
279
282
Some ( "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" ) ,
280
283
) ;
281
- Some ( EFIPN )
284
+ Some ( partno )
282
285
} else {
283
286
None
284
287
} ;
285
288
286
289
// Initialize the /boot filesystem. Note that in the future, we may match
287
290
// what systemd/uapi-group encourages and make /boot be FAT32 as well, as
288
291
// it would aid systemd-boot.
289
- let use_xbootldr = block_setup. requires_bootpart ( ) ;
290
- let mut partno = EFIPN ;
291
- if use_xbootldr {
292
+ let boot_partno = if block_setup. requires_bootpart ( ) {
292
293
partno += 1 ;
293
294
sgdisk_partition (
294
295
& mut sgdisk. cmd ,
@@ -297,8 +298,11 @@ pub(crate) fn install_create_rootfs(
297
298
"boot" ,
298
299
None ,
299
300
) ;
300
- }
301
- let rootpn = if use_xbootldr { BOOTPN + 1 } else { EFIPN + 1 } ;
301
+ Some ( partno)
302
+ } else {
303
+ None
304
+ } ;
305
+ let rootpn = partno + 1 ;
302
306
let root_size = root_size
303
307
. map ( |v| Cow :: Owned ( format ! ( "0:{v}M" ) ) )
304
308
. 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