Skip to content

Instantly share code, notes, and snippets.

@jcassette
Created November 23, 2022 20:55
Show Gist options
  • Select an option

  • Save jcassette/71724b7eb207b54e0c45313faffb919f to your computer and use it in GitHub Desktop.

Select an option

Save jcassette/71724b7eb207b54e0c45313faffb919f to your computer and use it in GitHub Desktop.
#!/bin/sh
iso_path="$1"
img_path="$2"
dd if=/dev/zero of="$img_path" bs=1MB count=8000 status=progress
parted --script "$img_path" -- \
mklabel gpt \
mkpart P1 fat32 1MB 1000MB \
mkpart P2 ntfs 1000MB 8000MB
iso_loop=`losetup --show --find "$iso_path"`
img_loop=`losetup --partscan --show --find "$img_path"`
p1_loop=${img_loop}p1
p2_loop=${img_loop}p2
mkfs.vfat $p1_loop
mkfs.ntfs $p2_loop
iso_mount=`mktemp --directory`
p1_mount=`mktemp --directory`
p2_mount=`mktemp --directory`
mount $iso_loop $iso_mount
mount $p1_loop $p1_mount
mount $p2_loop $p2_mount
rsync --recursive --progress --exclude=/sources --include=/sources/boot.wim $iso_mount/ $p1_mount/
rsync --recursive --progress $iso_mount/ $p2_mount/
umount $iso_mount
umount $p1_mount
umount $p2_mount
losetup -d $iso_loop
losetup -d $img_loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment