eprigorodov / mkosxinstallusb

Linux shell script that creates USB flash drive booting OS X installer
Apache License 2.0
45 stars 10 forks source link

Suggestion: Ensure USB disk is properly configured #8

Open donhector opened 4 years ago

donhector commented 4 years ago

This is just a suggestion.

In my case, I had used the USB stick for other stuff and was previously imaged with dd, so despite the stick being physically 8Gb, my Linux was only seeing it as a much smaller disk (2Gb). This caused issues later on when rsyncing the Packages folder onto the stick as it was running out of space!.

The solution for me was to do this to my stick before running the mkosxinstallusb script:

sudo dd if=/dev/zero of=/dev/sdb bs=1M status=progress
sudo sync

That made it be an 8Gb disk again.

Maybe mkosxinstallusb could incorporate this step before running sgdisk -o $stick_dev to make the process more robust for some corner cases. Something like this:

[...]
echo "\n# partitioning USB drive"
if [ -b "$stick_dev" ]
then
    for device in $(lsblk -lnp -o NAME "$stick_dev" | tac)
    do
        umount -l "$device" 2>/dev/null || true
    done
fi
dd if=/dev/zero of=$stick_dev bs=1M status=progress
sync
sgdisk -o $stick_dev
sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 $stick_dev
sync
[...]