ASR(8) | System Manager's Manual | ASR(8) |
asr
— Apple
Software Restore; copy volumes (e.g. from disk images)
asr |
verb [options] |
asr |
restore[exact]
--source source
--target target
[options] |
asr |
server --source
source --config
configuration [options] |
asr |
restore --source
asr://source --file
file [options] |
asr |
imagescan --source
image [options] |
asr |
help | file ... version |
asr
efficiently copies disk images onto
volumes, either directly or via a multicast network stream.
asr
can also accurately clone volumes without the
use of an intermediate disk image.
In its first form, asr
copies
source (usually a disk image, potentially on an HTTP
server) to target. source can be
specified using a path in the filesystem, or an http or https URL. It can
also be an asr:// URL to indicate a multicast source.
asr
can also be invoked with its second form to act
as a multicast server. In its third form, asr
will
restore a multicast disk image to a file instead of disk volume. In its
fourth form, asr
prepares a disk image to be
restored efficiently, adding whole-volume checksum information.
help and version provide usage and
version information, respectively.
source and target can be /dev entries or volume mountpoints. For more information on restoring to or from APFS filesystems, see the RESTORING WITH APFS FILESYSTEMS section below. If restoring a multicast disk image to a file, file can be a path to a local file or directory. If the specified path is a file, the disk image is given the specified name. If a directory, the name of the disk image being multicast is used. When specifying server, source has to be a UDIF disk image. Restoring from a multicast stream is accomplished by passing a asr:// url as source.
When restoring APFS volumes, asr
supports
restoring snapshots from the source volume, as well as restoring snapshot
deltas. See the RESTORING WITH APFS SNAPSHOTS section
below.
asr
supports restoring systems with a
Read-Only System Volume (ROSV). For more information, see the
RESTORING WITH READ-ONLY SYSTEM VOLUMES section below.
asr
needs to be run as root (see
sudo(8)) in order to accomplish its tasks.
Each verb is listed with its description and individual arguments.
--source
--target
--file
--file
can be specified instead of --target.
If the
specified path is a file, the disk image is given the specified name.
If a directory, the name of the disk image being multicast is
used.--erase
--erase
must always be used, as file copies
are no longer supported by asr
. If
source is a asr:// url for restoring from a
multicast stream, --erase
must be passed
(multicasting only supports erase block-copy restores). Passing
--erase
with --file
indicates any existing file should be overwritten when doing a
multicast file copy.--format
HFS+ | HFSX--erase
is also given. If not specified, the
destination will be formatted with the same filesystem format as the
source. If multicasting, the --format
specified must be block copy compatible with the
source. --format
is
ignored if --erase
is not used. Note: HFS
Journaling is an attribute of the source image, and is not affected by
--format
.--noprompt
--timeout
num--puppetstrings
asr
's progress
should use --puppetstrings
.--noverify
--noverify
allows
images which have not been scanned to be restored. Skipping
verification is dangerous for a number of reasons and should never be
used in production systems.--allowfragmentedcatalog
--allowfragmentedcatalog
is provided for
situations where such a change is impractical. This option only makes
sense if the source specifes an HFS+ filesystem variant. It is
otherwise ignored.--corestorageconvert
asr
will create a new Core Storage Logical
Volume Group (LVG), using the partition represented by
target as its only physical volume (PV). The
volume contents restored from source will be
present as a single logical volume (LV) exported from this LVG. If
target is already a Core Storage LV, then this
option has no effect.--SHA1
--SHA256
--sourcevolumename
asr
which volume in the
source container to invert when doing an APFS
restore. It is an error if more than one volume has the specified
name. You can see the volume names and UUIDs by running
asr
with the info verb. See
the section RESTORING WITH APFS FILESYSTEMS below
for when this option is necessary.--sourcevolumeUUID
asr
which volume in the
source container to invert when doing an APFS
restore. You can see the volume names and UUIDs by running
asr
with the info verb. See
the section RESTORING WITH APFS FILESYSTEMS below
for when this option is necessary.--useReplication
asr
to use replication for restoring
APFS volumes (see the section REPLICATION AND THE
INVERTER below). This is the default, but there may be a
preference setting to use the inverter instead. This would override
that preference setting.--useInverter
asr
to use the inverter for restoring
APFS volumes (see the section REPLICATION AND THE
INVERTER below). This overrides any preference setting.--toSnapshot
--fromSnapshot
--toSnapshot
to
specify a snapshot delta to restore to the
target APFS volume. The argument must be either
the name or UUID of a snapshot on both source
and target. See the RESTORING WITH
APFS SNAPSHOTS section below for more details.restoreexact is not allowed with APFS volumes (see the section RESTORING WITH APFS FILESYSTEMS below), so its use is deprecated.
--erase
be passed in by clients (multicasting only
supports erase block-copy restores).
--source
--interface
--config
asr
misses data on the first pass (x's during
progress) and slowing the Data Rate doesn't resolve it, setting the
Client Data Rate will dynamically regulate the speed of the multicast
stream to allow clients more time to write the data. It's a number in
the plist (-int when set with defaults(1)).--nostream
--allowfragmentedcatalog
--allowfragmentedcatalog,
but it is provided
in case fixing the image is impractical.--source.
The report is written to standard
output.
--plist
Individual APFS volumes can not be restored directly, because
their device nodes don't allow I/O from a standard process. However,
asr
can restore entire APFS containers, including
all volumes. Or it can restore valid system configurations, which can get
the effect of restoring a single system. This requires understanding what is
meant by a valid system.
In order for an APFS volume to be bootable, it must contain a properly installed macOS system. It must also be part of an APFS container which also has two special volumes in it: a Preboot volume and a Recovery volume. A container may have arbitrarily many system volumes in it, but it must have only one Preboot volume and one Recovery volume, each with the corresponding APFS volume role set (see diskutil(1) for information on roles). The Preboot and Recovery volumes contain information which is tied to each system volume in the container. So for a system volume to be bootable, that information needs to be set up in the Preboot and Recovery volumes. A system which is part of a container that has these two special volumes, and for which the requisite information is set up in those volumes, will be referred to here as a valid system.
If the source of a restore is an APFS image
(i.e. an image which contains an APFS container), then
asr
does different things depending on how
target was specified:
asr
will block
restore the APFS container to a file within that volume, after which it
will invert the volume within the restored container, erasing the previous
contents of the target volume and replacing them
with the source volume contents. If the source
container only has a single non-special volume (i.e. not Preboot or
Recovery), then that is the volume which will be inverted. If the
source container has more than one non-special
volume, then either the --sourcevolumename
or
--sourcevolumeUUID
option must be present and must
specify the volume to invert. Additionally, if the volume being inverted
is a valid system (as defined above), then the relevant
contents of both the Preboot and Recovery volumes will be copied from the
source to the target, creating
those volumes on the target if necessary.--erase
option is
not present, then asr
will create a new volume in
the given container, after which it will do a volume restore to that new
volume, as with the previous section. All other volumes in the container
are preserved.--erase
option is
present, then asr
will erase the existing
partition, create a new APFS container and a new volume in it, after which
it will do a volume restore to that new volume, as with the previous
section.See the EXAMPLES section below for some command lines that show these operations.
As of macOS Catalina, the standard mechanism for restoring APFS
volumes is to use the internal APFS replication capability. While this
should be sufficient for most needs, asr
does
provide the ability to use a legacy restore mechanism, which involves
running the apfs_invert program. Restoring with the inverter has some
limitations (e.g. all volumes in the target container must be unmounted, the
source volume can't have any snapshots in it, etc), so using the default
APFS replication is usually the better choice. However, in the event that
invert restores are desired, that option can be selected. The logic
asr
uses for this is as follows, from lowest to
highest priority:
- By default, use replication.
- Look for a preference in the domain com.apple.asr with key "ForceInvert" and a Boolean value.
- Look for a --useReplication
or
--useInverter
option on the command line.
APFS volumes may contain snapshots, which are point-in-time captures of all volume state (including directory hierarchy, file existence and file content). To distinguish between a snapshot and the current state of a volume, we will here refer to that current state as the "live volume." Snapshots can be identified by name or UUID. Names are unique within a single volume, but two volumes can have snapshots with the same name that are unrelated in content. By contrast, snapshot UUIDs are unique, in the sense that two snapshots on different volumes that have the same UUID must refer to identical content, a situation that will typically arise by restoring a snapshot, as described in this section.
In addition to restoring a live volume (either currently known to
the system or from an image), asr
also supports
restoring a snapshot from the source volume. The result of such a restore is
that the target volume ends up looking like the source volume at the time of
the given snapshot, rather than like the live source volume. Additionally,
the target volume will contain that state as a snapshot of its own, with the
same name and UUID as the restored snapshot in the source. See the
EXAMPLES section below for some command lines that show
snapshot restores.
asr
also supports restoring the difference
between two snapshots, referred to as a "snapshot delta." In this
case there must be both a "from" snapshot and a "to"
snapshot on the source volume, the target must be specified as a specific
volume rather than a whole container, and the target volume must already
contain a snapshot which is identical to the source's "from"
snapshot. The result of a snapshot delta restore is that the target ends up
looking like the source's "to" snapshot, similar to a regular
snapshot restore as described above. But the restore only needs to copy over
the difference between the two snapshots, so it may save considerable time
and/or network or bus resources. Note that a snapshot delta restore can
still discard data from the target volume, so asr
does require using the --erase
option when doing a
snapshot delta restore. Again, see the EXAMPLES section
below for some command line examples of snapshot delta restores.
Note that restoring with snapshots and snapshot deltas is only allowed when using replication (see the REPLICATION AND THE INVERTER section above).
macOS Catalina supports a Read-Only System Volume (ROSV) configuration, in which the standard macOS system install is split across two volumes. The two are referred to as the System and Data volumes, that is how their corresponding APFS roles are set (see diskutil(1) for more on APFS roles), they are combined into a volume group, and the System volume gets mounted read-only.
asr
has support for restoring ROSV volume
groups. If the source is a disk image containing an ROSV volume group, or an
existing volume that is part of a volume group, then both volumes will be
restored to the target, and the target volumes will be combined as
appropriate into a new group on the target. Since the source and the target
may each be part of a group or not, there are several cases to consider:
asr
can restore snapshots and snapshot
deltas from any volume in a volume group, but the behavior is different
between snapshot restores and snapshot delta restores.
When doing a snapshot restore (i.e. using the
--toSnapshot
option without the
--fromSnapshot
option), each volume in the source
volume group is examined to see if it contains the specified "to"
snapshot. Each volume in the group which contains the snapshot will be
copied as a snapshot replication, as described in the
RESTORING WITH APFS SNAPSHOTS section, above. Each volume
in the group which does not contain the snapshot will be copied as a live
volume replication. So all volumes in the group are restored, and only those
which contain the given "to" snapshot will have a snapshot restore
performed. Note that if the "to" snapshot is specified by name,
multiple volumes in the source group may have a snapshot with that name,
though those snapshots need not be related in any way.
By contrast, snapshot delta restores (i.e. using both the
--toSnapshot
and
--fromSnapshot
options) are only ever performed on a
single volume. The source volume can be any volume (i.e. it need not have
any particular role), but whether or not it's in a group, that will be the
only volume restored. So if there are multiple volumes which have snapshots
with the same names and you want to do a snapshot delta restore for all of
them, then you must invoke asr once for each such volume.
The following options control how asr
uses
memory. These options can have a significant impact on performance.
asr
is optimized for copying between devices
(different disk drives, from a network volume to a local disk, etc). As
such, asr
defaults to using eight one megabyte
buffers. These buffers are wired down (occupying physical memory). For
partition to partition copies on the same device, one large buffer (e.g. 32
MB) is much faster than the default eight medium sized ones. For multicast,
4 256k buffers are the default. Custom buffering for multicast operation is
not recommended.
--csumbuffers
and
--csumbuffersize
allow a different buffer
configuration for checksumming operations. One checksum buffer offers the
best performance. The default is 1 1MB buffer. Custom checksum buffering is
not recommended.
Like mkfile(8), size defaults to bytes but can be followed by a multiplier character (e.g. 'm').
--buffers
num--buffersize
size--csumbuffers
num--csumbuffersize
sizesudo asr restore -s
<compressedimage> -t <targetvol> --erase
Will erase the target and potentially do a block copy restore.
Multicast server:
Will start up a multicast server for the specified image, using the parameters in the configuration.plist. The image will not start multicasting on the network until a client attempts to start a restore. The server will continue to multicast the image until the process is terminated.
An example multicast configuration file:
Multicast client
Multicast client restoring to a file
Will receive the multicast stream from <hostname> and save it to a file. If <file> is a directory, the image of the streamed disk image will be used the save the file. --erase causes any existing file with the same name to be overwritten.
Restoring a single APFS volume
In this case the contents of MyAPFSVolume will be replaced by the contents of the source container's single APFS volume, possibly including any associated data for the Preboot and Recovery volumes, if the source is a valid system. If the source has more than one non-special volume, this is an error. No other volumes in the target will be affected.
Restoring one of many APFS volumes
This tells asr
to select the volume named
"SourceVolume" from the given APFS image. If there is no volume
with that name, or if there are more than one with that name, it is an
error. Use the info verb to see the volume names and UUIDs
for an image. No other volumes in the target will be affected.
Creating a new APFS volume on the fly
Here we get the same effect as the last example, except that
asr
will create a new volume on the target APFS
container disk, given by /dev/disk2, and use that newly created volume as
the target. Any volumes which already existed in the container will still be
there after the restore.
Overwriting the existing container
Like the last example, we restore to a new volume on the target APFS container disk. However in this case we are erasing the target, so any volumes which already existed are destroyed.
Looking at an image's volume names/UUIDs
Assuming this image has been previously scanned (using the
imagescan verb), this will display the volumes' names and
UUIDs so they can be used with the
--sourcevolumename
or
--sourcevolumeUUID
options.
Restoring a snapshot
This assumes that the image volume has a snapshot named Snap1.
During the restore, asr
will create a new volume in
the container at /dev/disk2 and use that volume as the target of the
restore. The resulting target volume will have the same contents as Snap1 on
the source volume, and it will also have a snapshot with the same name
(Snap1) and UUID as Snap1 on the source. This snapshot will match the live
target volume right after the restore; the live volume can subsequently
change, but the snapshot will remain the same.
Restoring a snapshot delta
This assumes that the image volume has a snapshot named Snap1 and another snapshot named Snap2. Furthermore the target volume (mounted here at "/Volumes/Target") must also contain Snap1, with the same UUID and content. The result of the restore will be that the target volume will have the same contents as Snap2 on the source volume, and it will also gain a snapshot with the same name (Snap2) and UUID as Snap2 on the source. The restore will only need to copy the difference between the two snapshots, rather than the entire contents of Snap2.
asr
requires a properly created disk image
for most efficient operation. This image is most easily made with the Disk
Utility application's "Image from Folder" function in OS X 10.3.
The Disk Copy from OS X 10.2.3 (v55.6) or later can also be used.
Basic steps for imaging and restoring a volume:
asr
can block copy restore HFS+/HFSX
filesystems and resize the source filesystem to fit in the target's
partition if the source filesystem data blocks will fit within the target
partition's space (resizing the filesystem geometry as appropriate).
HFS+ can be used as the source of a block copy to either an HFS+ or HFSX destination. However, an HFSX source can only be used to block copy to an HFSX destination. This is because case collision of file names could occur when converting from an HFSX filesystem to HFS+.
Certain non-HFS+/HFSX filesystems will block copy restore, but the target partition will be resized to match the size of the source image/partition size, with no filesystem resizing occurring.
asr
maintains compatibility with previous
syntax, e.g.
asr
-source
source -target
target [options]asr
-source
source -server
configuration [options]asr
-source
asr://source -file
file [options]asr
-imagescan
[options] imageasr
-h
|
file ... -v
where -source,
-target,
and -file
are
equivalent to --source,
--target,
and --file
respectively, and all [options] are equivalent to
their -- descriptions. asr
-server
configuration is
superseded by asr
server
--config
configuration. The
following deprecated options also remain:
-nocheck
-noverify
instead.-blockonly
-blockonly
cannot be block-copied to a particular
target an error will occur, since the file-copy
information was omitted.Note: Compatibility with previous syntax is not guaranteed in the next major OS release.
asr
will exit with status 1 if it cannot
complete the requested operation. A human readable error message will be
printed in most cases. If asr
has already started
writing to the target volume when the error occurs, then it will erase the
target, leaving it in a valid (but empty) state. It will, however, leave it
unmounted.
Some of the error messages which asr
prints are generated by the underlying subsystems that it uses, and their
meaning is not always obvious. Here are some useful guidelines:
asr
does some preflight testing before it starts
actually copying data. Errors that show up during this preflighting are
usually clear (e.g. "There is not enough space in volume
"Macintosh HD" to do the restore.")Apple Software Restore got its start as a field service restoration tool used to reconfigure computers' software to 'factory' state. It later became a more general software restore mechanism and software installation helper application for various Apple computer products. ASR has been used in manufacturing processes and in shipping computers' System Software Installers.
For Mac OS X, asr was rewritten as a command line tool for
manufacturing and professional customers. asr
is the
backend for the Mac OS X Software Restore application that shipped on
Macintosh computers as well as the Scan and Restore functionality in Disk
Utility.
Multicast support was added to allow multiple clients to erase restore an image from a multicast network stream.
Per its history, most functionality in asr
was originally focused on HFS+ volumes, but it has expanded to also include
APFS.
hdiutil(1), df(1), bless(8), ditto(1), and what(1)
December 10, 2020 | Mac OS X |