If you've ever tried to create a bootable Windows 11 USB drive on a macOS system, you likely ran into a frustrating obstacle: the **4GB file size limit of FAT32**.
Windows installation ISOs now commonly include a file named `install.wim` that exceeds 5GB or 6GB. Since modern UEFI-based PCs require the bootable USB to be formatted as FAT32, you can't simply copy the files over. You need a way to split that large file while keeping the installer functional.
To solve this, I've developed a Python script called **Pendriver Bootloader for Windows**. It automates the entire process, from dependency installation to disk formatting and file splitting.
---
## Key Features
- **Native macOS Integration**: Uses built-in tools like `diskutil` and `hdiutil` for reliable disk management.
- **Auto-Elevation**: Automatically requests `sudo` permissions when needed, so you don't have to worry about running it with the right privileges.
- **Smart Dependency Management**: Checks for Homebrew and `wimlib`. If they are missing, the script offers to install them for you.
- **The WIM Splitter**: Uses `wimlib-imagex` to split the massive `install.wim` into smaller `.swm` chunks (under 4GB), allowing the Windows installer to run perfectly from a FAT32 partition.
- **Automated ISO Detection**: Scans your local directory for Windows ISOs, saves you from typing long paths, but also supports a manual `--iso` flag.
## How It Works: Under the Hood
### 1. Preparing the Environment
The script starts by ensuring you are on a macOS system and have the necessary permissions. It then verifies if `wimlib` is installed via Homebrew. This tool is the "secret sauce" that allows us to bypass the FAT32 file size limitation.
### 2. Disk Preparation (GPT & FAT32)
Using `diskutil`, the script identifies external USB drives and prepares them using the GUID Partition Table (GPT) and a MS-DOS (FAT32) file system. This is the gold standard for modern UEFI booting.
### 3. Mounting the ISO
Instead of making you manually open the ISO, the script uses `hdiutil mount` to attach the Windows image as a read-only volume. It specifically looks for `setup.exe` to confirm it has found a valid Windows installer.
### 4. The Copy Process & File Splitting
This is where the magic happens. The script copies all the files from the ISO to your USB drive. When it reaches the `sources/install.wim` file, it stops and invokes `wimlib-imagex split`.
It breaks the file into 4000MB parts. The Windows installer is smart enough to recognize these split files (`install.swm`, `install2.swm`, etc.) and treat them as a single image during the installation process.
## How to Use It
Using the script is straightforward. You just need a terminal and a USB drive (at least 8GB).
1. **Clone the repository** (or download the script).
2. **Open Terminal** in the script's directory.
3. **Run the script**:
```bash
python3 create-windowsbootloader.py
```
4. **Follow the prompts**: Select your USB drive, confirm the erase operation, and let the script do the rest.
If you have your ISO in a specific location, you can point to it directly:
```bash
python3 create-windowsbootloader.py --iso /path/to/windows.iso
```
## Conclusion
Creating a Windows installer shouldn't be a headache just because you prefer working on a Mac. This script bridges the gap between the two ecosystems, handling the technical complexities of partitioning and file splitting so you can get back to what matters most.
Feel free to check out the source code on [GitHub](https://github.com/jaccon/create-winowsbootloader.git) and contribute!
Happy booting! 🚀 🪟
Repository to download
André Jaccon