Skip to content

fcos translate.go: add warn on small or constrained root partition#378

Merged
prestist merged 2 commits intocoreos:mainfrom
prestist:warn-on-fs-too-small
Apr 23, 2026
Merged

fcos translate.go: add warn on small or constrained root partition#378
prestist merged 2 commits intocoreos:mainfrom
prestist:warn-on-fs-too-small

Conversation

@prestist
Copy link
Copy Markdown
Collaborator

@prestist prestist commented Aug 4, 2022

#211

Note I somehow dropped the '1' in the version for FCOS in the commit messages.. but before I update the commit structure lets make sure we are happy with the functional changes. Look at the first 2 commits, i.e the exp changes this is basically propagated to all versions back to 1_3 as you can see later with the fixup commits. Once approved I will merge the fixup commits with a rename to the commits to be inclusive of the changes!

@prestist prestist force-pushed the warn-on-fs-too-small branch from df3fd2e to 166e0d5 Compare August 5, 2022 18:29
Comment thread config/fcos/v1_5_exp/translate.go Outdated
Comment thread config/fcos/v1_5_exp/translate.go Outdated
Comment thread config/common/errors.go Outdated
Comment thread config/common/errors.go Outdated
Comment thread config/fcos/v1_5_exp/translate.go
Comment thread config/fcos/v1_5_exp/translate.go Outdated
Comment thread config/fcos/v1_5_exp/translate_test.go Outdated
Comment thread config/fcos/v1_5_exp/translate_test.go Outdated
Comment thread config/fcos/v1_5_exp/translate_test.go Outdated
Comment thread config/fcos/v1_5_exp/translate_test.go Outdated
@prestist prestist force-pushed the warn-on-fs-too-small branch 6 times, most recently from b95add4 to 98397ca Compare August 22, 2022 20:44
@prestist prestist force-pushed the warn-on-fs-too-small branch 2 times, most recently from 8a4a4c3 to 50f80a6 Compare August 29, 2022 15:49
@prestist prestist force-pushed the warn-on-fs-too-small branch from 50f80a6 to 8882e58 Compare January 15, 2026 14:19
@prestist prestist force-pushed the warn-on-fs-too-small branch 2 times, most recently from 74876cc to 78f8481 Compare January 28, 2026 21:24
@prestist prestist marked this pull request as ready for review January 28, 2026 21:37
@prestist prestist force-pushed the warn-on-fs-too-small branch from 78f8481 to 530a65e Compare January 28, 2026 21:48
@prestist prestist changed the title WIP: fcos translate.go: add warn on small or constrained root partition fcos translate.go: add warn on small or constrained root partition Jan 29, 2026
@aaradhak
Copy link
Copy Markdown
Member

The first commit message says fcos v0_7_exp but there is no v0_7_exp directory. May be this should be fcos v1_7_exp?

@aaradhak
Copy link
Copy Markdown
Member

Minor: Typo in commit message body: "contstraints" should be "constraints"

Comment thread config/common/errors.go Outdated

// In the boot_device.mirror case, nothing specifies partition numbers
// so match existing partitions only when `wipeTable` is false
if !util.IsTrue(disk.WipeTable) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand this wipetable change. The previous code only checked reserved partlabels when wipeTable is false. The current change now runs the root validation even when wipeTable is true. I guess it is intentional.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it was intentional the root partition size validation needs to happen regardless of wipeTable, because:

  1. Even when wipeTable is true (creating a fresh partition table), users can still specify
    partitions that trap the root partition - this is exactly the scenario we want to warn about

  2. The wipeTable check only applies to the "reserved partlabel validation" (checking that
    BIOS-BOOT is partition 1, root is partition 4, etc.). That validation should only run
    when wipeTable is false because we're matching existing partitions.

  3. The root size/constraint validation is orthogonal to whether we're wiping the table -
    it's about warning users before they create a configuration that won't have enough space
    for OS updates.

@prestist prestist force-pushed the warn-on-fs-too-small branch from 7aa0707 to 2641b14 Compare April 10, 2026 15:00
@prestist
Copy link
Copy Markdown
Collaborator Author

@aaradhak

Fixed both issues! I've rebased and updated the commit messages:

  1. Changed from "fcos v0_7_exp" to "fcos translate.go" / "fcos translate_test.go" since
    these changes actually apply to FCOS versions v1_3 through v1_7

  2. Fixed the typo: "contstraints" → "constraints"

@prestist prestist force-pushed the warn-on-fs-too-small branch from b910184 to f042937 Compare April 10, 2026 15:08
@aaradhak
Copy link
Copy Markdown
Member

@prestist I happened to go over the release details of butane v0.27.0 . I bumped into this Add Fcos spec 1.8.0-experimental , Should this validation also be added to config/fcos/v1_8_exp/translate.go? Was it excluded intentionally?

@prestist
Copy link
Copy Markdown
Collaborator Author

@prestist I happened to go over the release details of butane v0.27.0 . I bumped into this Add Fcos spec 1.8.0-experimental , Should this validation also be added to config/fcos/v1_8_exp/translate.go? Was it excluded intentionally?

Nope that was an oversite, due to the latest stabilization and the age of this pr.

@prestist
Copy link
Copy Markdown
Collaborator Author

@aaradhak

If you want to test it locally you can do this:

1. Checkout and Build                                                                                                                                                  
                                                                                                                                                                         
  # Checkout the PR                                                                                                                                                      
  gh pr checkout 378                                                                                                                                                     
                                                                                                                                                                         
  # Build butane                                                                                                                                                         
  ./build                                                                                                                                                                                                               
                                                                                                                                                                         
  2. Manual Testing Scenarios
                                                                                                                                                                         
  The PR adds two warnings for root partition issues:                                                                                                                    
  
  ⚠️  Warning 1: Root Too Small (< 8 GiB)                                                                                                                                 
                                                                            
  cat > test-small.bu << 'EOF'                                                                                                                                           
  variant: fcos                                                                                                                                                          
  version: 1.7.0
  storage:                                                                                                                                                               
    disks:                                                                  
      - device: /dev/vda
        wipe_table: false                                                                                                                                                
        partitions:
          - number: 4                                                                                                                                                    
            label: root                                                     
            size_mib: 5000                                                                                                                                               
  EOF                                                                                                                                                                    
  
  ./bin/amd64/butane < test-small.bu                                                                                                                                     
  Result: warning: root should have 8GiB of space assigned ✅               
                                                                                                                                                                         
  ⚠️  Warning 2: Root Constrained by Auto-Positioned Partition
                                                                                                                                                                         
  cat > test-constrained.bu << 'EOF'                                        
  variant: fcos                                                                                                                                                          
  version: 1.7.0                                                            
  storage:
    disks:
      - device: /dev/vda
        partitions:                                                                                                                                                      
          - number: 4                                                                                                                                                    
            label: root                                                                                                                                                  
            size_mib: 0                                                                                                                                                  
          - number: 5                                                       
            label: data
            start_mib: 0
  EOF                                                                                                                                                                    
                                                                                                                                                                         
  ./bin/amd64/butane < test-constrained.bu                                                                                                                               
  Result: warning: root partition cannot expand; it is set to fill available space but is followed by an auto-positioned partition ✅                                    
                                                                                                                                                                         
  ✅ No Warning: 8 GiB or larger
                                                                                                                                                                         
  cat > test-ok.bu << 'EOF'                                                 
  variant: fcos                                                                                                                                                          
  version: 1.7.0                                                            
  storage:
    disks:                                                                                                                                                               
      - device: /dev/vda
        wipe_table: false                                                                                                                                                
        partitions:                                                         
          - number: 4                                                                                                                                                    
            label: root                                                     
            size_mib: 8192
  EOF

  ./bin/amd64/butane --strict < test-ok.bu  # No warnings  

@prestist prestist force-pushed the warn-on-fs-too-small branch from f042937 to 1521b20 Compare April 21, 2026 19:52
Comment thread config/fcos/v1_7/translate.go Outdated
nextStart = *nextPartition.StartMiB
}
// If this partition starts before the current "next", it's closer to root
if (apStart > 0 && apStart < nextStart) || (nextStart == 0 && apStart > 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition here causes an explicitly positioned partition to replace an auto-positioned one as the "nearest" candidate but the auto-positioned partition is the one that actually constrains root right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooof, okay; yees you are right; Let me update the code to account for this.

@prestist prestist force-pushed the warn-on-fs-too-small branch from 1521b20 to 7e3ec1a Compare April 23, 2026 15:59
@prestist
Copy link
Copy Markdown
Collaborator Author

@aaradhak Good catch! You're right - the previous logic missed when both an auto-positioned and an explicitly positioned partition were present, the "find nearest" would prefer the explicit partitions, effectively hiding the auto-positioned partition that actually constrains root.

The startMiB of any following partition. If this is unspecified (0) and the root sizeMiB is also unspecified, then the following partition will prevent the root partition from growing at all, and we should warn.

Instead of trying to determine which partition is physically "nearest" to root (which we can't reliably do without knowing disk size and sgdisk's placement heuristics), we now simply check: if root is auto-sized AND any other partition on the disk has startMiB unspecified, warn. I also added a test case for this scenario (auto-positioned partition with an explicit one also present).

Fixes: coreos#211, the root partition needs a certain amount of space, with
recent changes butane has the opportunity to warn when those expectations
are not met.

Warn if root partition sizeMiB is explicitly less than 8GiB, or if root
is set to fill available space and any other partition on the disk is
auto-positioned (startMiB == 0 or nil), which would prevent root from
expanding.

Applied to FCOS versions v1_3 through v1_8_exp.
Add test cases for:
 - Root partition constrained by disk position (not partition number)
 - Root partition with auto-positioned following partition (StartMiB=0)
 - Root partition NOT constrained when next partition has explicit StartMiB
 - Root partition constrained by auto-positioned partition even when an
   explicit partition is also present
 - Root partition size validation (too small, exactly 8GiB)

Applied to FCOS versions v1_3 through v1_8_exp.
@prestist prestist force-pushed the warn-on-fs-too-small branch from 7e3ec1a to a063fa1 Compare April 23, 2026 17:07
Copy link
Copy Markdown
Member

@aaradhak aaradhak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@prestist prestist merged commit 06af893 into coreos:main Apr 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants