Skip to content

Instantly share code, notes, and snippets.

@Redecorating
Last active Sep 12, 2021
Embed
What would you like to do?
T2 VM install

For this guide, I'm installing PopOS, but

Setup VM

Install VirtualBox: https://www.virtualbox.org/wiki/Downloads

  1. Create a 64 bit Linux VM called "t2linux"
  2. Do not create storage for the VM now, we will do this manually.
  3. In macOS Terminal, create an iso disk image to install to:
    1. cd ~/VirtualBox\ VMs/t2linux
    2. dd if=/dev/zero of=./linux.iso bs=1G count=16, change count from 16 to your distro's minimum install space in GB (We will expand the partition later).
    3. VBoxManage internalcommands createrawvmdk -filename ./linux.vmdk -rawdisk ./linux.iso
    4. In VirtualBox, Settings -> Storage -> Controller: SATA -> "Hard Disk +" icon -> Add -> Select linux.vmdk, then you'll be able to choose linux.vmdk to add to the VM.
  4. Go to the VM's settings
    1. Under "System", enable efi and add more cores (i.e. maximum) and ram (i.e. 4GB) which will make it much faster than the default.
    2. Under "Storage", select "Empty" under the IDE Controler, and add your distro's install iso to it.
  5. Boot the VM
  6. Follow your distro's install process, but do partitioning manually.
  7. Partition
    1. Create a GPT partition table
    2. Create a 500 MB fat32 partition called "EFI", set its flags to "ESP"
    3. Create an ext4 or btrfs partition with the rest of the space, called "Root"
    4. EFI2 will be mounted at /boot/efi, Root will be mounted at /
  8. Continue installing
  9. Reboot the VM into your install

Install Drivers

Kernel

Debian Based: From https://github.com/marcosfad/mbp-ubuntu-kernel#manually

DKMS

https://wiki.t2linux.org/guides/dkms/

You will need to run sudo dkms install -m MODULE -v 0.1 -k x.x.x-mbp a second time for each of the modules you installed and change x.x.x-mbp with the mbp kernel you installed, i.e. -k 5.7.19-mbp

Make sure you have at least apple-bce in /etc/modules-load.d/t2.conf.

WiFi

https://wiki.t2linux.org/guides/wifi/

Audio

https://wiki.t2linux.org/guides/audio-config/

fstab

Make the following edits to /etc/fstab on your VM:

  1. Make NVRAM/EFIVARS read only to prevent panicing the t2 chip, by adding this line:

    efivarfs /sys/firmware/efi/efivars efivarfs ro,remount 0 0
    
  2. Change the first field in the line about /boot/efi to use the PARTLABEL, as it's UUID will change when we move the install. Also add the nofail option. For example:

    PARTLABEL=EFI2 /boot/efi vfat umask=0077,nofail 0 0
    
  3. Also ensure that all other disks are defined in fstab by their UUID=, not PARTUUID= or /dev/sdXY. You can find the UUID of your partitions with sudo blkid.

Move Install

  1. Shutdown your VM

  2. In terminal, hdiutil attach -nomount ~/VirtualBox\ VMs/t2linux/linux.iso

  3. Open macOS Disk Utility

    1. Click "Partition"
    2. Create a 500MB MS-DOS (FAT32) partition called "EFI2"
    3. Create a second partition with any format, but call it "Linux" and make sure it's larger that the "Root" partition you created in the VM. This will be the space for linux, so give it however much space you want linux to have.
    4. Apply these changes.
  4. In terminal, run diskutil list, you should have something similar to this for disk0:

    /dev/disk0 (internal, physical):
    #:                       TYPE NAME                    SIZE       IDENTIFIER
    0:      GUID_partition_scheme                        *500.3 GB   disk0
    1:                        EFI EFI                     314.6 MB   disk0s1
    2:                 Apple_APFS Container disk0         164.6 GB   disk0s2
    3:       Microsoft Basic Data EFI2                    499.1 MB   disk0s3
    4:                  Apple_HFS Linux                   84.3 GB    disk0s4
    

    The Disk Image should be there too:

    /dev/disk3 (disk image):
    #:                       TYPE NAME                    SIZE       IDENTIFIER
    0:      GUID_partition_scheme                        +16.7 GB    disk3
    1:                        EFI NO NAME                 524.3 MB   disk3s1
    2:           Linux Filesystem                         16.1 GB    disk3s2
    
  5. Copy the efi partition

    1. diskutil mount disk3s1 (Change disk3s1 to the identifier of the EFI partition of the Disk Image).
    2. In Finder, copy everything in the "NO NAME" disk (which was just mounted) to the "EFI2" disk.
  6. Copy the root partition over with dd. Be very careful that you use the right disks. Change the "if" (input file) to the disk image's "Linux Filesystem" partition, and the "of" to your ssd's "Root" partition. Do not set "of" or "if" to any partitions that you don't want to overwrite. This can overwrite macOS (or windows) if the wrong disks are used.

    1. Unmount "Root" with Finder
    2. Copy the Root partition: sudo dd if=/dev/disk3s2 of=/dev/disk0s4 bs=16M
    3. While dd runs, you can press control-T to see how many bytes it has written.

boot install

  1. reboot, and hold down command-R to enter macOS Recovery
  2. On the top menu bar select utilities and open startup secrity utility
  3. set secure boot to "no security"
  4. restart and hold option
  5. there should be a "EFI Boot", pick it.

post install

expand root partition with gparted or something similar

Make the efi partition get mounted again:

Edit fstab, and uncomment the boot partition's line, and change it to use the UUID, which can be found with sudo blkid

uname -r if it doesn't have mbp in it, then you need to set your bootloader to boot the mbp kernel. Look up instructions for your distro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment