Web lists-archives.com

Re: New SSD on a MacBook Pro




On 16/11/2018 14:46, Stefan Monnier wrote:
I would expect the clone to work just fine.  I'd expect your initrd
contains drivers for both SATA and NVMe anyway.

OK. Now that I know that initrd does contain NVMe drivers, I would ask whether my strategy for cloning is sensible.

Firstly, here's my original partition table:

===================================
$ sudo parted -l
Model: ATA APPLE SSD SM0128 (scsi)
Disk /dev/sda: 121GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name                  Flags
1 20.5kB 210MB 210MB fat32 EFI System Partition boot, esp
 2      210MB   22.6GB  22.4GB  hfs+
 3      22.6GB  23.2GB  650MB   hfs+
 4      23.2GB  31.2GB  8000MB  linux-swap(v1)  swap
 5      31.4GB  121GB   89.8GB  ext4            linux
===================================

Partition 3 is macOS, partition 5 is linux. I don't know why partition 2 is there, macOS's Disk Utility created it when I originally partitioned the disk to make room for linux.

Partition 1 is the EFI partition, which is mounted on /boot/efi:

===================================
$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             4021656        0   4021656   0% /dev
tmpfs             807236     1352    805884   1% /run
/dev/sda5       85825416 68182636  13240004  84% /
tmpfs            4036168     4892   4031276   1% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
tmpfs            4036168        0   4036168   0% /sys/fs/cgroup
/dev/sda1         201633    23678    177955  12% /boot/efi
tmpfs             807232        0    807232   0% /run/user/113
tmpfs             807232       16    807216   1% /run/user/1000
===================================

The debian installer put the Grub2 loader in this partition:

===================================
$ sudo ls /boot/efi/EFI/debian
grubx64.efi

$ sudo efibootmgr -v
BootCurrent: 0000 Timeout: 5 seconds BootOrder: 0000,0080 Boot0000* debian HD(1,GPT,d43355a1-7dc2-4a96-ba68-4400a5db3981,0x28,0x64000)/File(\EFI\debian\grubx64.efi) Boot0080* PciRoot(0x0)/Pci(0x1c,0x5)/Pci(0x0,0x0)/Sata(0,0,0)/HD(3,GPT,911f18b9-6252-4cb8-8ad3-81c9ca73ded5,0x2a0f760,0x135f20)/File(\System\Library\CoreServices\boot.efi)

Boot0081* Mac OS X PciRoot(0x0)/Pci(0x1c,0x5)/Pci(0x0,0x0)/Sata(0,0,0)/HD(3,GPT,911f18b9-6252-4cb8-8ad3-81c9ca73ded5,0x2a0f760,0x135f20)

BootFFFF* PciRoot(0x0)/Pci(0x1c,0x5)/Pci(0x0,0x0)/Sata(0,0,0)/HD(3,GPT,911f18b9-6252-4cb8-8ad3-81c9ca73ded5,0x2a0f760,0x135f20)/File(\System\Library\CoreServices\boot.efi)
===================================

Now, here is what I would perform:

(1) Use macOS Time Machine to backup macOS on an external hard drive.
(2) dd the linux partition into an image file:
$ sudo dd bs=4M if=/dev/sda5 of=<ext_media>/debian_part.img
(3) Install new drive.
(4) Use macOS Recovery to restore macOS from the Time Machine backup.
(5) I believe that point (4) will also restore the EFI partition, but will debian/grubx64.efi be preserved as well? Need to gather some info and check. Anyhow, I should have ended up with just two partitions: the EFI partition and the macOS partition.
(6) Use macOS Disk Utility to partition the new disk.
(7) How to restore the backed up debian partition? Do I need to reinstall a basic debian system from scratch and then run something like:
sudo dd bs=4M if=<ext_media>/debian_part.img of=/dev/sdaN
(where N is the new partition number)?
Or is there some tool that can ease the recovery process?

Thanks!