Skip to content

Instantly share code, notes, and snippets.

@takaxp
Last active March 17, 2021 01:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaxp/81fe2cb78d029a15dfc4bd22399dea40 to your computer and use it in GitHub Desktop.
Save takaxp/81fe2cb78d029a15dfc4bd22399dea40 to your computer and use it in GitHub Desktop.
Clone APFS bootable volume (from internal SSD to external HDD)
# see https://discussions.apple.com/thread/8384650
# disk2: main drive as source (SSD)
# disk2s1: Macintosh HD
# disk2s2: Preboot for disk2s1
# disk5: external drive as destination (HDD)
# disk5s1: Untitled
# disk5s2: Preboot for disk5s1
sudo vsdbutil -a /Volumes/Untitled
sudo rsync -xrlptgoEvHS --progress --delete / /Volumes/Untitled
diskutil list
diskutil apfs addVolume disk5 apfs Preboot -role B # as '/Volumes/Preboot'
diskutil info disk5s1 | grep "Volume UUID" # will return <UUID of disk5s1>
mkdir /Volumes/Preboot/<UUID of disk5s1>
diskutil mount disk2s2 # as '/Volumes/Preboot 1'
diskutil info disk2s1 | grep "Volume UUID" # will return <UUID of disk2s1>
sudo rsync -xrlptgoEvHS --progress --delete '/Volumes/Preboot 1/<UUID of disk2s1>/' '/Volumes/Preboot/<UUID of disk5s1>/'
diskutil unmount disk2s2
diskutil unmount disk5s2
sudo bless --folder /Volumes/Untitled/System/Library/CoreServices --bootefi
sudo update_dyld_shared_cache -root /Volumes/Untitled -force
@takaxp
Copy link
Author

takaxp commented Aug 20, 2019

The following attempts will be failed when cloning APFS volume:

  • Restoring from TimeMachine
  • Restoring from the current System

The operation will be finished with an error code like OSStatus error XX:
Screen Shot 2019-08-20 at 1 41 55

Then, just manually try the above procedure :)

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