1
+ use std:: borrow:: Cow ;
1
2
use std:: fmt:: Display ;
2
3
use std:: io:: BufWriter ;
3
4
use std:: io:: Write ;
@@ -68,8 +69,6 @@ const BOOTPN: u32 = 3;
68
69
// This ensures we end up under 512 to be small-sized.
69
70
const BOOTPN_SIZE_MB : u32 = 510 ;
70
71
const ROOTPN : u32 = 4 ;
71
- // TODO calculate from ostree commit
72
- const ROOTFS_SIZE_MB : u32 = 5 * 1024 ;
73
72
#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
74
73
const EFIPN : u32 = 2 ;
75
74
#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
@@ -91,10 +90,14 @@ pub(crate) struct InstallOpts {
91
90
#[ clap( long) ]
92
91
pub ( crate ) wipe : bool ,
93
92
94
- /// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes)
93
+ /// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes).
94
+ ///
95
+ /// By default, all remaining space on the disk will be used.
95
96
#[ clap( long) ]
96
97
pub ( crate ) root_size : Option < String > ,
97
98
99
+ // TODO: A size specifier which allocates free space for the root in *addition* to the base container image size
100
+ // pub(crate) root_additional_size: Option<String>
98
101
/// The transport; e.g. oci, oci-archive. Defaults to `registry`.
99
102
#[ clap( long, default_value = "registry" ) ]
100
103
pub ( crate ) target_transport : String ,
@@ -493,8 +496,7 @@ fn install_create_rootfs(state: &State) -> Result<RootSetup> {
493
496
. as_deref ( )
494
497
. map ( crate :: blockdev:: parse_size_mib)
495
498
. transpose ( )
496
- . context ( "Parsing root size" ) ?
497
- . unwrap_or ( ROOTFS_SIZE_MB as u64 ) ;
499
+ . context ( "Parsing root size" ) ?;
498
500
499
501
// Create a temporary directory to use for mount points. Note that we're
500
502
// in a mount namespace, so these should not be visible on the host.
@@ -553,10 +555,13 @@ fn install_create_rootfs(state: &State) -> Result<RootSetup> {
553
555
"boot" ,
554
556
None ,
555
557
) ;
558
+ let root_size = root_size
559
+ . map ( |v| Cow :: Owned ( format ! ( "0:{v}M" ) ) )
560
+ . unwrap_or_else ( || Cow :: Borrowed ( "0:0" ) ) ;
556
561
sgdisk_partition (
557
562
& mut sgdisk. cmd ,
558
563
ROOTPN ,
559
- format ! ( "0:{ root_size}M" ) ,
564
+ root_size,
560
565
"root" ,
561
566
Some ( "0FC63DAF-8483-4772-8E79-3D69D8477DE4" ) ,
562
567
) ;
0 commit comments