0

How do I copy the whole partition map for a drive 'cloned' with DD? Same size hard drive for input and output of DD. Device block size was 4096 Bytes on input disk, 512 Bytes on output disk. Filevault 2 partitions on source.

1

You mustn't clone the partition map of a 4096 Byte disk to a 512 Byte disk (and vice versa) directly. 4096 Byte/512 Bytes are the device block sizes here.

The major differences are the 1st block (block=0) and the GPT header (block=1):

While the MBR (PMBR) on a 512 disk only occupies 512 bytes (Block(512)=0), the MBR on a 4096-disk occupies the whole first block and the GUID starts at block(4096)=1 (which would translate to block(512)=8).

The first GPT header on a 512 disk occupies the second block (Block(512)=1), the first GPT header on a 4096-disk occupies the whole second block and the GUID partition table starts at block(4096)=2 (which would translate to block(512)=16).

Examples:

Device block size: 512

                0           1         PMBR
                1           1         Pri GPT header
                2          32         Pri GPT table
               34           6         
               40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
           409640 size-main-v      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
totalsize-1269576     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
     totalsize-40           7         
     totalsize-33          32         Sec GPT table
      totalsize-1           1         Sec GPT header

Device block size: 4096 (in parenthesis the "respective" 512 start block/block size)

               0 (0)           1     (8)        PMBR
               1 (8)           1     (8)        Pri GPT header
               2(16)           4    (32)        Pri GPT table
               6(48)       51200(409600)      1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
           76806(..) size-main-v              2 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
totalsize-158697(..)      158692(..)          3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC       
     totalsize-5(..)           4    (32)        Sec GPT table
     totalsize-1(..)           1     (8)        Sec GPT header

As a consequence don't clone the partition table but create it yourself:

sudo gpt create diskX #(with diskX the disk identifier of the target disk(512)

Then add the EFI, the main partition and the Recovery HD. Just start at block 40(512) on your disk(512) while multiplying the sizes of the disk(4096) partitions by 8:

sudo gpt add -b 40 -s (size-old-efi*8) -i 1 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B diskX
sudo gpt add -b 40+(size-old-efi*8) -s (size-old-main-vol*8) -i 2 -t 53746F72-6167-11AA-AA11-00306543ECAC diskX
sudo gpt add -b 40+(size-old-efi*8)+(size-old-main-vol*8) -s 1269536 -i 3 -t 426F6F74-0000-11AA-AA11-00306543ECAC diskX

Your source EFI partition probably has either 51200 blocks(4096) or 76800 blocks(4096).

  • Thanks. Worked perfectly to create the partitions which seem to match the originals. However, when I do a "diskutil cs list" I don't see the corestorage volume and I can't see any volumes through finder. Any idea why? – Mike J Aug 31 '16 at 17:55
  • @MikeJ Is the source disk still installed? – klanomath Aug 31 '16 at 19:51
  • No, it is not. It's an unokugged external drive. – Mike J Aug 31 '16 at 19:53
  • @MikeJ EFI and Recovery HD usually aren't mounted. And a locked FV2 neither. The FV2 LV should be visible though in diskutil cs list! Do you remember the dd commands used? You may see them in your .bash_history – klanomath Aug 31 '16 at 19:58
  • I'd tried dd'ing the whole disk: sudo dd if=/dev/disk6 of=/dev/disk3 bs=1m after which I applied the partition mapping. I could post gpt and my math. Does dd w/ filevault2 only work when dd'ing a partition vs whole disk? – Mike J Sep 1 '16 at 22:50

You must log in to answer this question.

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