2

Similarly to this question I'd like to restore factory APFS partition container structure after reinstalling macOS Big Sur from bootable USB flash drive, exactly: make Macintosh HD volume disk1s1 (currently disk1s5) and Macintosh HD - Data volume disk1s2 (currently disk1s1).

This is what factory setup looks like:

diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         1.0 TB     disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.0 TB     disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            15.3 GB    disk1s1
   2:                APFS Volume Macintosh HD - Data     2.7 GB     disk1s2
   3:                APFS Volume Preboot                 284.2 MB   disk1s3
   4:                APFS Volume Recovery                626.3 MB   disk1s4
   5:                APFS Volume VM                      20.5 KB    disk1s5

This is what it looks like right now:

diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI ⁨EFI⁩                     314.6 MB   disk0s1
   2:                 Apple_APFS ⁨Container disk1⁩         1.0 TB     disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.0 TB     disk1
                                 Physical Store disk0s2
   1:                APFS Volume ⁨Macintosh HD - Data⁩     2.5 GB     disk1s1
   2:                APFS Volume ⁨Preboot⁩                 284.2 MB   disk1s2
   3:                APFS Volume ⁨Recovery⁩                626.3 MB   disk1s3
   4:                APFS Volume ⁨VM⁩                      20.5 KB    disk1s4
   5:                APFS Volume ⁨Macintosh HD⁩            15.3 GB    disk1s5
   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.3 GB    disk1s5s1

diskutil apfs list
APFS Container (1 found)
|
+-- Container disk1 10FCC4F5-6143-41E5-9F74-AD9A76AC42EF
    ====================================================
    APFS Container Reference:     disk1
    Size (Capacity Ceiling):      1000240963584 B (1.0 TB)
    Capacity In Use By Volumes:   18980200448 B (19.0 GB) (1.9% used)
    Capacity Not Allocated:       981260763136 B (981.3 GB) (98.1% free)
    |
    +-< Physical Store disk0s2 54848ECD-A4D2-4BDF-A539-6CAB47645CCF
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk0s2
    |   Size:                       1000240963584 B (1.0 TB)
    |
    +-> Volume disk1s1 07781674-7D00-4803-8FB9-2109E944DDDD
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s1 (Data)
    |   Name:                      Macintosh HD - Data (Case-insensitive)
    |   Mount Point:               /System/Volumes/Data
    |   Capacity Consumed:         2529787904 B (2.5 GB)
    |   Sealed:                    No
    |   FileVault:                 No (Encrypted at rest)
    |
    +-> Volume disk1s2 AB82B314-D19E-4E84-837B-EB188E4B5B3F
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s2 (Preboot)
    |   Name:                      Preboot (Case-insensitive)
    |   Mount Point:               /System/Volumes/Preboot
    |   Capacity Consumed:         284155904 B (284.2 MB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk1s3 F7584C45-59AD-4B37-8897-C21D40B0C7A9
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s3 (Recovery)
    |   Name:                      Recovery (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         626294784 B (626.3 MB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk1s4 6DDAC30E-71D5-4C75-8F04-9F0B6F4296C5
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s4 (VM)
    |   Name:                      VM (Case-insensitive)
    |   Mount Point:               /System/Volumes/VM
    |   Capacity Consumed:         20480 B (20.5 KB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk1s5 C9027495-7A11-4921-A0D2-0668E7ABE28C
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk1s5 (System)
        Name:                      Macintosh HD (Case-insensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         15331536896 B (15.3 GB)
        Sealed:                    Broken
        FileVault:                 No (Encrypted at rest)
        |
        Snapshot:                  3E13A161-7421-48DE-8CA1-47FB0C581DC5
        Snapshot Disk:             disk1s5s1
        Snapshot Mount Point:      /
        Snapshot Sealed:           Yes

sudo gpt -r show /dev/disk0
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2          4         Pri GPT table
          6      76800      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      76806  244199454      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  244276260          4         Sec GPT table
  244276264          1         Sec GPT header

I have prepared a bootable macOS Big Sur running from external drive. However I'm not sure how do I achieve what I need. I've examined diskutil man on apfs and an article about creating APFS Fusion Drive by hand but could't come up with the idea how to do what I need. I'm not afraid to edit internal drive, there's no user data on it currently, just a fresh copy of macOS (if something goes wrong I can reinstall from USB flash drive again).

Please help!

6
  • 2
    Why do you care what the arrangement of the logical drive identifiers is? You can't make it match the factory-delivered layout, you've done at least one update since. Commented May 1, 2022 at 18:35
  • 1. I manage multiple Mac computers and it's easier to troubleshoot and fix issues when all of them have same logical structure. 2. I didn't do any updates on the current installation. I've just reinstalled the very same version of macOS that came from factory using bootable USB flash drive created using createinstallmedia Terminal command, I also first wiped entire internal SSD using Disk Utility in Recovery (booted from macOS installer USB flash drive, wiped drive, run installer). 3. I've seen people comment on this in a manner my goal can be achieved.
    – bananakid
    Commented May 1, 2022 at 18:45
  • Of course you did an update... " 6: APFS Snapshot ⁨com.apple.os.update-...⁩ 15.3 GB disk1s5s1". Commented May 1, 2022 at 19:23
  • Well that's what I got using bootable USB flash drive with "Install macOS Big Sur" created using "macOS Installer.app" from the Apple-provided InstallAssistant.pkg of macOS 11.6.1. This laptop wasn't connected to Internet even once after wiping internal SSD and installing macOS from USB flash drive. BTW there's an example APFS partition's Macintosh HD volume ID can be changed from disk1s5 to disk1s1 by redoing everything - forums.macrumors.com/threads/2230520 - however there're no exact details... P.S. I'm OK with reinstalling as an option.
    – bananakid
    Commented May 1, 2022 at 19:40
  • @MarcWilson: Identifiers are only assigned APFS snapshots that are mounted. The first diskutil list was not entered while booted to Big Sur. However, the second diskutil list was entered while booted to Big Sur. Commented May 2, 2022 at 3:30

1 Answer 1

0

You installed macOS Big Sur by executing an installer application. A factory install probably was done by cloning.

Apple probably did not install macOS Big Sur the same way you did. Most likely Apple did a restore from an archive file. You do not necessarily need an archive file. You could use an existing install instead.

I tested the steps below and was able to achieved the results you are looking for.

Steps for Installing macOS Big Sur

  1. Boot from a macOS Big Sur installer on bootable USB flash drive.

  2. Use the Disk Utility and/or Terminal to create two APFS container partitions on the internal drive.

  3. Install Big Sur in the second APFS container on the internal drive. The table below shows the APFS volumes and mounted APFS snapshots in this container when booted to Big Sur. Here, this container has the identifier diskX, where X is a positive integer.

    Identifier Type Name
    diskXs1 APFS Volume Macintosh HD - Data
    diskXs2 APFS Volume Preboot
    diskXs3 APFS Volume Recovery
    diskXs4 APFS Volume VM
    diskXs5 APFS Volume Macintosh HD
    diskXs5s1 APFS Snapshot com.apple.os.update-...
  4. Boot from a macOS Big Sur installer on bootable USB flash drive.

  5. Clone macOS. In other words, open the Disk Utility and restore to the first APFS container from the second APFS container.

  6. Remove the second APFS container and extend the first APFS container to include the free space.

  7. Boot from macOS Big Sur on the internal drive. The table below shows the APFS volumes and mounted APFS snapshots in this container when booted to Big Sur. Here, this container has the identifier diskX, where X is a positive integer.

    Identifier Type Name
    diskXs1 APFS Volume Macintosh HD
    diskXs1s1 APFS Snapshot com.apple.os.update-...
    diskXs2 APFS Volume Macintosh HD - Data
    diskXs3 APFS Volume Preboot
    diskXs4 APFS Volume Recovery
    diskXs5 APFS Volume VM
4
  • Thank you so much for taking time to experiment and finding a solution, David! Your observations correspond well with quite similar (yet not perfect) result from GitHub Gist article I've found earlier but did't manage to test yet. Essentially article involves cloning APFS Container disk-to-disk (as you described) using asr restore Terminal command. So yes, cloning-restoring is definitely the route used at the factory. I'm marking your answer as correct and will report later if it leads to success on my Intel Mac with T2.
    – bananakid
    Commented May 2, 2022 at 14:20
  • I was able to avoid entering commands in a Terminal window by using the Disk Utility application instead. However, unless you are familiar with all the bugs in the Disk Utility application and how to get around them, you are probably better off entering commands in a Terminal window. Commented May 2, 2022 at 14:33
  • Note 1. In step 5 you should not use DU > View > Show all devices and Container disk 1 device > Restore using Macintosh HD in Container disk 2, because this will provide result similar to asr restore command from GitHub Gist (i.e. Macintosh HD will be disk1s2 and Macintosh HD - Data will be disk1s1). Instead just click on <partition name you specified for APFS "Container disk 1"> (your disk1s1 device) > Restore on it's page ( "Macintosh HD - Data" inside "Container disk 1" will be created too).
    – bananakid
    Commented May 11, 2022 at 9:55
  • Note 2. After Restore the Macintosh HD will be reported as disk1s2 and MacintoshHD - Data will be reported as disk1s1 in diskutil list until you boot to macOS normally.
    – bananakid
    Commented May 11, 2022 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .