Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

How to make a disk image of APFS container, then restore it.

License

NotificationsYou must be signed in to change notification settings

toolbits/imagingAPFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

diskutil unmountDisk /dev/disk1
hdiutil create -srcdevice /dev/disk0s2 -format UDZO /Volumes/Test\ HD/container.dmg

is same as:
hdiutil create -srcdevice /dev/disk1 -format UDZO /Volumes/Test\ HD/container.dmg
hdiutil create -layout GPTSPUD -partitionType Apple_APFS -srcdevice /dev/disk0s2 -format UDZO /Volumes/Test\ HD/container.dmg
hdiutil create -layout GPTSPUD -partitionType Apple_APFS -srcdevice /dev/disk1 -format UDZO /Volumes/Test\ HD/container.dmg

// asr imagescan --source /Volumes/Test\ HD/container.dmg
// => NG (internal error)

// asr restore --source /Volumes/Test\ HD/container.dmg --target /dev/disk2 --erase
// => NG (has no container disk)

hdiutil attach /Volumes/Test\ HD/container.dmg
=> attached as diskXX
asr restore --source /dev/diskXX --target /dev/disk2 --erase
=> OK (however, apfs_invert command required, see below.)

the target disk is recommened to re-format by DiskUtility.
first, format as non APFS (for example, HFS+), then re-format as APFS.
target container size must be larger than image container size.

explanation...

"container image as device" contains meeningfull whole APFS container (including Preboot, Recovery, VM).
However, this type of image has no partition map information and volume title information.
So, "asr imagescan" and "asr restore" goes to fail.
We have to mount image first by "hdiutil attach", then use "asr restore" command.

When we do this process in booted by macos USB installer, last process of "asr restore" will be fail.
Because last process is inverting APFS container process, but, macos USB installer has no apfs_invert command.
We need do this process in standard installed macos system or inject apfs_invert to macos USB installer's BaseSystem.dmg.

/Volumes/Install\ macOS\ High\ Sierra/Install\ macOS\ High\ Sierra.app/Contents/SharedSupport/BaseSystem.dmg
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs_invert

Restored APFS container has no VM volume, however don't be afraid.
It will be automatically created in next boot process.

hint for next research...

It seems that OVERALLOCATION PROBLEM (original container has) is repaired by inverting process.
However, rebooted by restored container and use it, that problem will strangely revive in the future.

(This research was written by HORIGUCHI Junshi, 2018/06/24.)

About

How to make a disk image of APFS container, then restore it.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp