Skip to content

Instantly share code, notes, and snippets.

@tenox7
Last active July 14, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenox7/96139e6c65e219e9ccb91d74275356ce to your computer and use it in GitHub Desktop.
Save tenox7/96139e6c65e219e9ccb91d74275356ce to your computer and use it in GitHub Desktop.
fast macOS dd with progress bar, umount and erase dst disk
#!/bin/bash -e
src="${1?:No src/file specified}"
dst="${2?:No dst/disk specified}"
bs=1m
diskutil unmountDisk "${dst}"
diskutil zeroDisk short "${dst}"
if [[ "${src}" == *.lz ]]
then
lzip -dcvv "${src}" | dd of="${dst}" bs=$bs
elif [[ "${src}" == *.xz ]]
then
xz -dcvv "${src}" | dd of="${dst}" bs=$bs
else
dd if="${src}" bs=1m | pv "${src}" | dd of="${dst}" bs=$bs
fi
@tenox7
Copy link
Author

tenox7 commented Jul 14, 2022

use /dev/rdskXXX for destination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment