ARM Image Partition Expansion
Overview
The LnOS ARM image now supports automatic partition expansion to utilize the entire SD card space, regardless of the card's size. This feature ensures that users get maximum storage capacity from their SD cards.
Two ARM image options are available:
- Minimal Image (512MB): Small, fast download for LnOS installation
- Full Image (1.5GB): Complete system with automatic expansion
How It Works
Image Size Options
Minimal Image (512MB)
- Boot Partition: 128MB FAT32
- Root Partition: ~384MB ext4
- Purpose: Fast download, LnOS installation only
- Use Case: Network installation, minimal storage requirements
Full Image (1.5GB)
- Boot Partition: 256MB FAT32
- Root Partition: ~1.3GB ext4 (initially)
- Purpose: Complete system with automatic expansion
- Use Case: Standalone system, maximum storage utilization
Automatic Expansion
On first boot, the system automatically:
- Detects the actual SD card size
- Expands the root partition to use all available space
- Resizes the filesystem to match the new partition size
- Reboots to ensure all changes take effect
- Disables the expansion service to prevent re-running
Manual Expansion
If automatic expansion doesn't work or you want to expand manually:
sudo /root/LnOS/scripts/expand-rootfs.sh
Technical Details
Partition Layout
Minimal Image
- Boot Partition: 128MB FAT32 (fixed size)
- Root Partition: ~384MB (installation only)
Full Image
- Boot Partition: 256MB FAT32 (fixed size)
- Root Partition: Initially ~1.3GB, expands to use remaining space
Required Tools
The expansion process uses:
parted
- for partition resizingresize2fs
- for filesystem resizing (frome2fsprogs
package)partprobe
- for partition table refresh
Safety Features
- Expansion only runs once (tracked by flag file)
- Automatic rollback if expansion fails
- Verification of partition and filesystem sizes
- User confirmation for manual expansion
Usage
Building the Images
# Build minimal image (512MB)
sudo ./build-arm-minimal.sh [rpi4|generic]
# Build full image (1.5GB)
sudo ./build-arm-image.sh [rpi4|generic]
Writing to SD Card
sudo dd if=out/lnos-arm64-rpi4-YYYY.MM.DD.img of=/dev/sdX bs=4M status=progress
First Boot
- Insert SD card and boot the device
- The system will automatically expand partitions
- Wait for reboot to complete
- The root filesystem will now use the entire SD card space
Troubleshooting
Expansion Failed
If automatic expansion fails:
- Check if
parted
andresize2fs
are available - Run manual expansion script
- Check system logs for errors
Manual Expansion Issues
- Ensure you're running as root
- Verify the SD card is properly detected
- Check that the root filesystem is mounted
Verification
To verify expansion worked:
df -h /
parted /dev/mmcblk0 unit MiB print
Benefits
- Flexible Storage: Works with any SD card size (8GB, 16GB, 32GB, 64GB, etc.)
- Smaller Downloads: 512MB minimal vs 1.5GB full vs 4GB original
- Faster Downloads: Minimal image under 1GB, no compression needed
- GitHub Compatible: Both images under GitHub's 2GB file size limit
- Automatic: No user intervention required
- Safe: Includes error handling and verification
- Manual Option: Users can expand manually if needed
Compatibility
- Works with Raspberry Pi 4 and other ARM64 devices
- Compatible with ext4 filesystem
- Requires parted and e2fsprogs packages (included in base image)