asr restore (AFPS2 Systeme bootfähig klonen)

Macschrauber

Macschrauber

Aktives Mitglied
Thread Starter
Dabei seit
08.02.2014
Beiträge
13.577
Reaktionspunkte
9.519
Da ich das gerade mit meiner Test-Disk getan habe möchte ich das als Referenz schnell zusammenfassen:

Auf der Testdisk waren Big Sur, Monterey, Ventura und Sonoma

1.) createinstallmedia Stick / Partition booten (USB Installer)

2.) wenn nötig: Disk Utility aufrufen und das Zielvolume in GUID formatieren, einen Container anlegen.

3.) In's Terminal

4.) Quell und Zielcontainer rauslesen (diskutil list)

5.)
Code:
asr restore --source /dev/diskxs2 -- target /dev/disky --sourcevolumename "Monterey"

x=der QuellContainer
y=der ZielContainer
sourcevolumename=Der Namen vom System, das Datenvolume wird mit kopiert, im Beispiel Monterey und Monterey - Data

Das nächste System kann man anschließend auf die gleiche Art kopieren, wird hinzugefügt.


Während dem Booten hat ein Tool erst mal die UUID korrigiert und neu gestartet. Die OpenCoreLegacyPatcher Patches mussten auch erneuert werden.

Das ganze ging bei moderat gefüllten Datenvolumen in ein paar Minuten von Blade zu Blade. Deutlich schneller wie alle Systeme neu zu installieren.


Das dürfte auch im laufenden System funktionieren, wenn das zu kopierende System nicht läuft. Mir war das Booten des Installers sicherer. Hab den eh auf einer Partition, da geht das fix.


hier noch ein Bild, diesmal Kopie aus dem gebotenen System (nicht das zu kopierende, aber in den gleichen Container hinein):

Bildschirmfoto 2024-02-29 um 14.22.22.png
 
Zuletzt bearbeitet:
  • Gefällt mir
Reaktionen: iPhill, Petoschka und dg2rbf
da das Ganze auch etwas kompliziert werden kann hab ich ein AppleScript gebaut was das Kommando zusammensetzt.

Man könnte auch das Kommando gleich ausführen lassen, aber ich bin der Meinung das sollte man dan selber prüfen und im Terminal einsetzen.

Das heisst, das Script lässt das Sourcevolume auswählen, findet den Container und lässt den TargetContainer wählen. Und prüft dabei das Nahenliegenste.

Dann zeigt es das Kommando und kopiert es auf Nachfrage in die Zwischenablage.



AppleScript:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

do shell script "diskutil list | sed 's/[^[:print:]]//g' | sed -E 's/^[[:space:]]*[0-9]+:[[:space:]]+//' | grep -v -e '#:' -e 'EFI ' -e 'Preboot' -e 'VM' -e 'Recovery' -e 'Snapshot' >/tmp/list.txt"


set valid to false

repeat until valid
 
 
    set the_selection to every paragraph of (do shell script "cat /tmp/list.txt | grep -i -e 'Volume' -e 'Container' | grep -iv 'Preboot' | grep -iv 'Recovery' | grep -iv 'VM'")
    set possible_selection to (do shell script "cat /tmp/list.txt | grep -i 'Volume' | grep -iv 'Preboot' | grep -iv 'Recovery' | grep -iv 'VM'")
 
    set sourcevolumename_line to (choose from list the_selection with title "choose the OS" with prompt "possible selection:                                            " & return & possible_selection) as text
 
    if sourcevolumename_line is "false" then return
 
 
    set text item delimiters to space
    if sourcevolumename_line contains " - " then # for - data, - daten, etc
        set sourcevolumename to words 3 thru -5 of sourcevolumename_line as text
    else
        set sourcevolumename to words 3 thru -4 of sourcevolumename_line as text
    end if
    set text item delimiters to ""
 
 
    set sourcevolume_disk to last word of sourcevolumename_line
 
 
 
 
 
    -- source Apple_APFS Container
 
    try
        set diskx to last word of (do shell script "diskutil info " & sourcevolume_disk & " | grep 'APFS Physical Store:'")
        if sourcevolumename_line does not contain "Scheme" then set valid to true
    end try
 
    if not valid then display dialog sourcevolumename_line & return & "not valid, an APFS Volume is expected" buttons "OK" default button 1 with title "error"
 
 
end repeat







-- target

set possible_selection to (do shell script "cat /tmp/list.txt | grep 'APFS Container Scheme' || echo 'error'")





set valid to false

repeat until valid
 
    set apfs_container_scheme to (choose from list (every paragraph of (do shell script "cat /tmp/list.txt")) with title "choose the destination APFS Container Scheme" with prompt "possible selection:" & return & possible_selection) as text
    if apfs_container_scheme is "false" then return
 
    try
        set disky to (last word of apfs_container_scheme)
    on error
        set disky to "error"
    end try
 
 
    try
        if ((do shell script "diskutil list " & disky) contains "APFS Container Scheme") then
            set valid to true
        end if
    end try
 
 
    if not valid then display dialog "not an APFS Container Scheme, example:" & return & "0:   APFS Container Scheme -   +511.9 GB   disk1" with title "error" buttons "OK" default button 1
 
 
end repeat








set the_command to "sudo asr restore --source /dev/" & diskx & " --target /dev/" & disky & " --sourcevolumename " & (quoted form of sourcevolumename)

set button_returned to display dialog the_command buttons {"copy", "don't copy"} default button 1 with title "this is the terminal command"
if button returned of button_returned is "copy" then set the clipboard to the_command

-- example: "asr restore --source /dev/disk0s2 -- target /dev/disk5 --sourcevolumename  Mojave"
 
Zuletzt bearbeitet:
  • Gefällt mir
Reaktionen: iPhill und Petoschka
Zurück
Oben Unten