systemimage module #13

Open
opened 2025-12-21 11:44:01 +00:00 by thabeta · 1 comment
Owner

Module Overview

The systemimage module provides comprehensive image format conversion and export capabilities, enabling the creation of bootable images in various formats suitable for different deployment targets. This module handles the complex process of converting kernel, initramfs, and root filesystem artifacts into standardized image formats that can be deployed across cloud providers, virtualization platforms, and bare metal systems.

The module supports industry-standard formats including ISO for optical media and installation, QCOW2 for QEMU/KVM virtualization, raw for direct block device deployment, and VHD for Microsoft Hyper-V compatibility. It includes optimization features like compression, validation, and integrity verification to ensure reliable deployment.

Functionality

  • Multi-format export: Convert artifacts to ISO, QCOW2, raw, and VHD formats with appropriate boot configurations
  • Bootable image creation: Generate properly configured bootable images with correct partition tables, boot loaders, and boot parameters
  • Format conversion utilities: Convert between different image formats with preservation of data and boot capability
  • Image validation and verification: Validate image integrity, verify bootability, and generate checksums for distribution
  • Compression and optimization: Apply compression algorithms to reduce image size while maintaining performance
  • Cloud-init integration: Attach cloud-init ISO images to enable first-boot configuration in cloud environments

Module API

Image Export

  • ImageExporter::new(kernel: &Path, initramfs: &Path, rootfs: &Path) -> Self - Create a new image exporter with artifacts
  • export_to_iso(&self, output: &Path) -> Result<(), ExportError> - Export as bootable ISO image
  • export_to_qcow2(&self, output: &Path, size: u64) -> Result<(), ExportError> - Export as QCOW2 virtual disk image
  • export_to_raw(&self, output: &Path, size: u64) -> Result<(), ExportError> - Export as raw disk image
  • export_to_vhd(&self, output: &Path, size: u64) -> Result<(), ExportError> - Export as VHD format for Hyper-V
  • create_bootable_image(&self, format: ImageFormat, output: &Path) -> Result<(), ExportError> - Create bootable image in specified format
  • add_cloud_init_iso(&mut self, cloud_init: &Path) -> &mut Self - Attach cloud-init ISO to the image

Format Conversion

  • convert_image(input: &Path, output: &Path, format: ImageFormat) -> Result<(), ConversionError> - Convert between image formats
  • qcow2_to_raw(input: &Path, output: &Path) -> Result<(), ConversionError> - Convert QCOW2 to raw format
  • raw_to_qcow2(input: &Path, output: &Path, compression: bool) -> Result<(), ConversionError> - Convert raw to QCOW2 with optional compression
  • vhd_to_qcow2(input: &Path, output: &Path) -> Result<(), ConversionError> - Convert VHD to QCOW2 format
  • resize_image(image: &Path, new_size: u64) -> Result<(), ConversionError> - Resize image to specified size
  • compress_image(image: &Path, method: CompressionMethod) -> Result<PathBuf, ConversionError> - Compress image using specified method

Image Validation

  • validate_image(image: &Path) -> Result<ValidationReport, ValidationError> - Validate image structure and integrity
  • check_bootability(image: &Path) -> Result<bool, ValidationError> - Check if image is bootable
  • verify_checksum(image: &Path, expected: &str) -> Result<bool, ValidationError> - Verify image checksum
  • generate_checksum(image: &Path, algorithm: HashAlgorithm) -> Result<String, ValidationError> - Generate image checksum
## Module Overview The systemimage module provides comprehensive image format conversion and export capabilities, enabling the creation of bootable images in various formats suitable for different deployment targets. This module handles the complex process of converting kernel, initramfs, and root filesystem artifacts into standardized image formats that can be deployed across cloud providers, virtualization platforms, and bare metal systems. The module supports industry-standard formats including ISO for optical media and installation, QCOW2 for QEMU/KVM virtualization, raw for direct block device deployment, and VHD for Microsoft Hyper-V compatibility. It includes optimization features like compression, validation, and integrity verification to ensure reliable deployment. ## Functionality - **Multi-format export**: Convert artifacts to ISO, QCOW2, raw, and VHD formats with appropriate boot configurations - **Bootable image creation**: Generate properly configured bootable images with correct partition tables, boot loaders, and boot parameters - **Format conversion utilities**: Convert between different image formats with preservation of data and boot capability - **Image validation and verification**: Validate image integrity, verify bootability, and generate checksums for distribution - **Compression and optimization**: Apply compression algorithms to reduce image size while maintaining performance - **Cloud-init integration**: Attach cloud-init ISO images to enable first-boot configuration in cloud environments ## Module API ### Image Export - `ImageExporter::new(kernel: &Path, initramfs: &Path, rootfs: &Path) -> Self` - Create a new image exporter with artifacts - `export_to_iso(&self, output: &Path) -> Result<(), ExportError>` - Export as bootable ISO image - `export_to_qcow2(&self, output: &Path, size: u64) -> Result<(), ExportError>` - Export as QCOW2 virtual disk image - `export_to_raw(&self, output: &Path, size: u64) -> Result<(), ExportError>` - Export as raw disk image - `export_to_vhd(&self, output: &Path, size: u64) -> Result<(), ExportError>` - Export as VHD format for Hyper-V - `create_bootable_image(&self, format: ImageFormat, output: &Path) -> Result<(), ExportError>` - Create bootable image in specified format - `add_cloud_init_iso(&mut self, cloud_init: &Path) -> &mut Self` - Attach cloud-init ISO to the image ### Format Conversion - `convert_image(input: &Path, output: &Path, format: ImageFormat) -> Result<(), ConversionError>` - Convert between image formats - `qcow2_to_raw(input: &Path, output: &Path) -> Result<(), ConversionError>` - Convert QCOW2 to raw format - `raw_to_qcow2(input: &Path, output: &Path, compression: bool) -> Result<(), ConversionError>` - Convert raw to QCOW2 with optional compression - `vhd_to_qcow2(input: &Path, output: &Path) -> Result<(), ConversionError>` - Convert VHD to QCOW2 format - `resize_image(image: &Path, new_size: u64) -> Result<(), ConversionError>` - Resize image to specified size - `compress_image(image: &Path, method: CompressionMethod) -> Result<PathBuf, ConversionError>` - Compress image using specified method ### Image Validation - `validate_image(image: &Path) -> Result<ValidationReport, ValidationError>` - Validate image structure and integrity - `check_bootability(image: &Path) -> Result<bool, ValidationError>` - Check if image is bootable - `verify_checksum(image: &Path, expected: &str) -> Result<bool, ValidationError>` - Verify image checksum - `generate_checksum(image: &Path, algorithm: HashAlgorithm) -> Result<String, ValidationError>` - Generate image checksum
Owner

too many things at once, we need to think better what do we need first

too many things at once, we need to think better what do we need first
despiegk added this to the later milestone 2025-12-21 20:41:36 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_research/herolib_rust#13
No description provided.