From 07cc8512efe281707e017555fd0849e3bb0ed23c Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Mon, 29 Sep 2025 16:18:16 +0300 Subject: [PATCH 1/2] Increase partition sizes The /usr partition was too small some time ago and we gained space again by switching to btrfs with compression and also removing/splitting out content. The /boot partition is too small all the time and we added many hacks to fit the kernel+initrd under 60 MB. To handle the case where the /oem partition is too small for the A/B-updated OEM extensions we added the workaround to write the inactive one (or both) to the rootfs. All this would not be needed if we had increased the partition sizes a few years ago so that we could now assume that most nodes have the increased sizes and we can make use of them. Still, we can do it now to prepare for the next time when in five or ten years we have serious size problems and run out of workarounds. We have to do the change now and wait a few years so that most nodes have been provisioned with the new layout. Then we can drop the workarounds and have a full featured kernel and initrd, and we can also increase the /usr filesystem to make use of the larger partition. Ideally we use large enough sizes that we never have to worry again but since we also want to support small ARM boards which might only have 8 GB internal storage, let's target this when increasing the partition sizes. With 1 GB /boot, two 2 GB /usr, and 1 GB /oem partitions we are already at 6 GB, leaving 2 GB for the rootfs. For now, reduce the extracted /usr update payload size to the current combined filesystem and verity data usage (same size as before). The rootfs size was also reduced for the initial .bin image so that we don't overshoot 8 GB - it will be resized to fit the disk anyway on first boot. Signed-off-by: Adrian Vladu Signed-off-by: Kai Lueke --- build_library/disk_layout.json | 12 +++++++----- build_library/disk_util | 14 +++++++++++--- changelog/changes/2025-10-09-partition-sizes.md | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 changelog/changes/2025-10-09-partition-sizes.md diff --git a/build_library/disk_layout.json b/build_library/disk_layout.json index 33ae6cb473..de346ea424 100644 --- a/build_library/disk_layout.json +++ b/build_library/disk_layout.json @@ -13,7 +13,7 @@ "label":"EFI-SYSTEM", "fs_label":"EFI-SYSTEM", "type":"efi", - "blocks":"262144", + "blocks":"2097152", "fs_type":"vfat", "mount":"/boot", "features": [] @@ -27,7 +27,8 @@ "label":"USR-A", "uuid":"7130c94a-213a-4e5a-8e26-6cce9662f132", "type":"flatcar-rootfs", - "blocks":"2097152", + "blocks":"4194304", + "extract_blocks":"2097152", "fs_blocks":"260094", "fs_type":"btrfs", "fs_compression":"zstd", @@ -38,7 +39,8 @@ "label":"USR-B", "uuid":"e03dd35c-7c2d-4a47-b3fe-27f15780a57c", "type":"flatcar-rootfs", - "blocks":"2097152", + "blocks":"4194304", + "extract_blocks":"2097152", "fs_blocks":"262144" }, "5":{ @@ -51,7 +53,7 @@ "label":"OEM", "fs_label":"OEM", "type":"data", - "blocks":"262144", + "blocks":"2097152", "fs_type":"btrfs", "fs_compression":"zlib", "mount":"/oem" @@ -70,7 +72,7 @@ "label":"ROOT", "fs_label":"ROOT", "type":"flatcar-resize", - "blocks":"4427776", + "blocks":"3653632", "fs_type":"ext4", "mount":"/" } diff --git a/build_library/disk_util b/build_library/disk_util index 8550605a99..497ab5f67d 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -40,10 +40,10 @@ def LoadPartitionConfig(options): '_comment', 'type', 'num', 'label', 'blocks', 'block_size', 'fs_blocks', 'fs_block_size', 'fs_type', 'features', 'uuid', 'part_alignment', 'mount', 'binds', 'fs_subvolume', 'fs_bytes_per_inode', 'fs_inode_size', 'fs_label', - 'fs_compression')) + 'fs_compression', 'extract_blocks')) integer_layout_keys = set(( 'blocks', 'block_size', 'fs_blocks', 'fs_block_size', 'part_alignment', - 'fs_bytes_per_inode', 'fs_inode_size')) + 'fs_bytes_per_inode', 'fs_inode_size', 'extract_blocks')) required_layout_keys = set(('type', 'num', 'label', 'blocks')) filename = options.disk_layout_file @@ -136,6 +136,13 @@ def LoadPartitionConfig(options): part.setdefault('fs_block_size', metadata['fs_block_size']) part.setdefault('fs_blocks', part['bytes'] // part['fs_block_size']) part['fs_bytes'] = part['fs_blocks'] * part['fs_block_size'] + # The partition may specify extract_blocks to limit what content gets + # extracted. The use case is the /usr partition where we can grow the + # partition but can't directly grow the filesystem and the update + # payload until all (or most) nodes are running the partition layout + # with the grown /usr partition (which can take a few years). + if part.get('extract_blocks', None): + part['extract_bytes'] = part['extract_blocks'] * metadata['block_size'] if part['fs_bytes'] > part['bytes']: raise InvalidLayout( @@ -823,6 +830,7 @@ def Extract(options): if not part['image_compat']: raise InvalidLayout("Disk layout is incompatible with existing image") + extract_size = part.get('extract_bytes', part['image_bytes']) subprocess.check_call(['dd', 'bs=10MB', 'iflag=count_bytes,skip_bytes', @@ -831,7 +839,7 @@ def Extract(options): 'if=%s' % options.disk_image, 'of=%s' % options.output, 'skip=%s' % part['image_first_byte'], - 'count=%s' % part['image_bytes']]) + 'count=%s' % extract_size]) def GetPartitionByNumber(partitions, num): diff --git a/changelog/changes/2025-10-09-partition-sizes.md b/changelog/changes/2025-10-09-partition-sizes.md new file mode 100644 index 0000000000..407bf1a036 --- /dev/null +++ b/changelog/changes/2025-10-09-partition-sizes.md @@ -0,0 +1 @@ +- Increased all partition sizes: `/boot` to 1 GB, the two `/usr` partitions to 2 GB, `/oem` to 1 GB so that we can use more space in a few years when we can assume that most nodes run the new partition layout - existing nodes can still update for the next years ([scripts#3027](https://github.com/flatcar/scripts/pull/3027)) From f0c94a9107739fbb572f7b7568ac7c3f14ce6c21 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Fri, 10 Oct 2025 17:00:59 +0900 Subject: [PATCH 2/2] vm_image_util: Use larger rootfs for AWS and Akamai images The default rootfs size for the .bin raw iamge is a bit smaller now because we still want to be able to flash to 8 GB storage. However, the VM images still have the 6 GB rootfs as before. Some cloud images weren't using the larger VM rootfs size though but the raw image rootfs size. Specify that AWS and Akamai images should use the larger VM rootfs size. Signed-off-by: Kai Lueke --- build_library/vm_image_util.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 17a0c024a2..349736df01 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -224,9 +224,11 @@ IMG_ami_vmdk_DISK_FORMAT=vmdk_stream IMG_ami_vmdk_OEM_USE=ami IMG_ami_vmdk_OEM_PACKAGE=common-oem-files IMG_ami_vmdk_SYSEXT=oem-ami +IMG_ami_vmdk_DISK_LAYOUT=vm IMG_ami_OEM_USE=ami IMG_ami_OEM_PACKAGE=common-oem-files IMG_ami_OEM_SYSEXT=oem-ami +IMG_ami_DISK_LAYOUT=vm ## openstack IMG_openstack_DISK_FORMAT=qcow2 @@ -342,6 +344,7 @@ IMG_kubevirt_OEM_SYSEXT=oem-kubevirt IMG_kubevirt_DISK_EXTENSION=qcow2 ## akamai (Linode) +IMG_akamai_DISK_LAYOUT=vm IMG_akamai_OEM_PACKAGE=common-oem-files IMG_akamai_OEM_USE=akamai IMG_akamai_OEM_SYSEXT=oem-akamai