@@ -506,7 +506,13 @@ impl FromStr for MountSpec {
506
506
let mut parts = s. split_ascii_whitespace ( ) . fuse ( ) ;
507
507
let source = parts. next ( ) . unwrap_or_default ( ) ;
508
508
if source. is_empty ( ) {
509
- anyhow:: bail!( "Invalid empty mount specification" ) ;
509
+ tracing:: debug!( "Empty mount specification" ) ;
510
+ return Ok ( Self {
511
+ source : String :: new ( ) ,
512
+ target : String :: new ( ) ,
513
+ fstype : Self :: AUTO . into ( ) ,
514
+ options : None ,
515
+ } ) ;
510
516
}
511
517
let target = parts
512
518
. next ( )
@@ -890,10 +896,13 @@ async fn install_container(
890
896
891
897
// Write the entry for /boot to /etc/fstab. TODO: Encourage OSes to use the karg?
892
898
// Or better bind this with the grub data.
899
+ // We omit it if the boot mountspec argument was empty
893
900
if let Some ( boot) = root_setup. boot . as_ref ( ) {
894
- crate :: lsm:: atomic_replace_labeled ( & root, "etc/fstab" , 0o644 . into ( ) , sepolicy, |w| {
895
- writeln ! ( w, "{}" , boot. to_fstab( ) ) . map_err ( Into :: into)
896
- } ) ?;
901
+ if !boot. source . is_empty ( ) {
902
+ crate :: lsm:: atomic_replace_labeled ( & root, "etc/fstab" , 0o644 . into ( ) , sepolicy, |w| {
903
+ writeln ! ( w, "{}" , boot. to_fstab( ) ) . map_err ( Into :: into)
904
+ } ) ?;
905
+ }
897
906
}
898
907
899
908
if let Some ( contents) = state. root_ssh_authorized_keys . as_deref ( ) {
@@ -1807,6 +1816,7 @@ pub(crate) async fn install_to_filesystem(
1807
1816
1808
1817
// We support overriding the mount specification for root (i.e. LABEL vs UUID versus
1809
1818
// raw paths).
1819
+ // We also support an empty specification as a signal to omit any mountspec kargs.
1810
1820
let root_info = if let Some ( s) = fsopts. root_mount_spec {
1811
1821
RootMountInfo {
1812
1822
mount_spec : s. to_string ( ) ,
@@ -1889,7 +1899,13 @@ pub(crate) async fn install_to_filesystem(
1889
1899
1890
1900
let rootarg = format ! ( "root={}" , root_info. mount_spec) ;
1891
1901
let mut boot = if let Some ( spec) = fsopts. boot_mount_spec {
1892
- Some ( MountSpec :: new ( & spec, "/boot" ) )
1902
+ // An empty boot mount spec signals to ommit the mountspec kargs
1903
+ // See https://github.com/bootc-dev/bootc/issues/1441
1904
+ if spec. is_empty ( ) {
1905
+ None
1906
+ } else {
1907
+ Some ( MountSpec :: new ( & spec, "/boot" ) )
1908
+ }
1893
1909
} else {
1894
1910
boot_uuid
1895
1911
. as_deref ( )
@@ -1903,12 +1919,23 @@ pub(crate) async fn install_to_filesystem(
1903
1919
// By default, we inject a boot= karg because things like FIPS compliance currently
1904
1920
// require checking in the initramfs.
1905
1921
let bootarg = boot. as_ref ( ) . map ( |boot| format ! ( "boot={}" , & boot. source) ) ;
1906
- let kargs = [ rootarg]
1907
- . into_iter ( )
1908
- . chain ( root_info. kargs )
1909
- . chain ( [ RW_KARG . to_string ( ) ] )
1910
- . chain ( bootarg)
1911
- . collect :: < Vec < _ > > ( ) ;
1922
+
1923
+ // If the root mount spec is empty, we omit the mounts kargs entirely.
1924
+ // https://github.com/bootc-dev/bootc/issues/1441
1925
+ let mut kargs = if root_info. mount_spec . is_empty ( ) {
1926
+ Vec :: new ( )
1927
+ } else {
1928
+ [ rootarg]
1929
+ . into_iter ( )
1930
+ . chain ( root_info. kargs )
1931
+ . collect :: < Vec < _ > > ( )
1932
+ } ;
1933
+
1934
+ kargs. push ( RW_KARG . to_string ( ) ) ;
1935
+
1936
+ if let Some ( bootarg) = bootarg {
1937
+ kargs. push ( bootarg) ;
1938
+ }
1912
1939
1913
1940
let skip_finalize =
1914
1941
matches ! ( fsopts. replace, Some ( ReplaceMode :: Alongside ) ) || fsopts. skip_finalize ;
0 commit comments