Install and Boot Linux & Windows from external SSD on a Mac mini 2018

# Main concept
Create a rEFInd boot drive in a USB drive, use this drive to boot Linux and Windows on a Mac mini.

# Things you need
1. Mac mini 2018 (or other T2 chip inside Mac, but I only test on my Mac mini)
1. external SSD
1. USB drive
1. USB keyboard & USB mouse
1. wired LAN connect OR a Linux ready USB WiFi dongle
1. VirtualBox (or other VM software which has the ability to direct access to a physical disk)
1. Linux & Windows 10 ISO file
1. rEFInd ISO file
1. any bootable USB creator tool

# Procedure
1. Create a virtual disk file to directly access to physical disk
1. Install Windows in VM
1. Install Linux in VM
1. Create rEFInd USB drive
1. Check the boot entry on Mac Boot Manager
1. Some work to do after the install in Windows & Linux

# Create a virtual disk file to directly access to physical disk
Please read this article: [Using a Physical Hard Drive with a VirtualBox VM](https://www.serverwatch.com/guides/using-a-physical-hard-drive-with-a-virtualbox-vm/)

I have tried this on 3 OSes and here are the results:
1. On Windows 10, although I have installed VBox, when I run VBoxManager command I got a error like "command not found". I don't know the reason or the solution.
1. On macOS you need to unmount the target disk before create the VMDK file and root privilege is required. Then, the VMDK file is owned by root so you have to run VBox in root to add this VMDK into your VM. `chown` can't resolve.
1. On Linux you need to unmount the target disk before create the VMDK file and root privilege is required.
1. When you create a new VM, it may be better if you choose OS type as Mac OS X, OS version as macOS 10.13 High Sierra(64-bit). In this configuration, VBox will set the VM as Macmini8,1(Mac mini 2018), it's just the device you are using! 

# Install Windows in VM
Nothing strange to mention, typically. The installation of Windows is basic. But I suggest you to reserve the space for Linux and (if you want) the data partition.
After the installation completed and you see the Windows desktop, shutdown the VM immediately. Don't let it do any Windows update or driver installation. It's useless to set Windows for a VM environment.

# Install Linux in VM
Same as Windows installation, if you want a partition for data storage, create it before Linux installation. For example, I use a 1TB SSD and I set 333GB for Windows, 333GB for Linux and 334GB for an exFAT partition.
I installed Linux Mint 20.3 to my SSD. The installer detected there is a Windows install in the disk and ask me if I want to install Linux Mint aloneside Windows. I chose yes. Of course you can set your installation plan manually.

# Create rEFInd USB drive
Download "A USB flash drive image file" from this site. [The rEFInd Boot Manager: Getting rEFInd](https://www.rodsbooks.com/refind/getting.html)
Extract the zip file and create a USB bootable drive with the ISO file.

# Check the boot entry on Mac Boot Manager
Insert the USB drive and the external SSD to Mac mini, plug a display to Mac mini's HDMI port. Boot Mac mini and press Option key continuely until you see the Mac Boot Manager. In my case there is a "Macintoch HD" and two "EFI Boot", one is for rEFInd in USB drive, the other is for Grub2 in external SSD.
![Mac Boot Manager](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/502913/9e2f2c27-4ac3-6720-d35e-277824906302.png)
We don't know the destination of each "EFI Boot" entry. But you can enter them and check it. If you entered rEFInd you will see the rEFInd boot menu. If you entered Grub2, since Mac Boot Manager can't boot Grub2, you will see a black screen and the fan may boost to full speed for about 1 second, finally your Mac mini will reboot or shutdown.

My rEFInd menu look like this:
![rEFInd](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/502913/320e06eb-055d-3b3d-b262-441d904fb466.png)
The first line of icon, from left to right:
1. Boot into macOS
1. Boot into Windows 10
1. Boot into Grub2 (but Grub2 shows nothing on screen so you have to play with grub menu without see anything, or you just wait about 20s until grub2 get a timeout and boot into its first boot option)
1. I forgot what it is :)
1. Boot into Linux Mint directly without Grub2
1. **This entry can't boot into Windows**
1. **This entry can't boot into Windows**

So, press the 2ed entry you can boot into Windows 10 and the 3rd or 5th entry can boot into Linux.

# Some work to do after the install in Windows & Linux
## Windows
Boot into Windows with HDMI output instead of Thunderbolt 3. Then run the Windows Update, not only the major update items, but also the option drivers (not the option windows update items e.g. Cumulative Update Preview for Windows 10). After that, Intel GPU driver, Thunderbolt 3 display output, WiFi, audio speaker, Bluetooth, Ethernet become functional.

## Linux
First, update your system to the latest. Then upgrade the kernel to the latest major version. Newer kernel may brings better hardware support. In my case, Linux Mint 20.3, which is same as Ubuntu 20.04.3, shipped a kernel of 5.4, the latest kernel of this version is 5.13. Finally, Thunderbolt display output & Intel GPU & Bluetooth & Ethernet work fine, audio speaker & WiFi don't work.
For these hardware which don't work, this site [Home - t2linux wiki](https://wiki.t2linux.org/) provides many support contents for you. I tried the tutorial about DKMS and audio speaker works.