Wierd problem after doing a triple boot OS-X, UBUNTU 20.04, KALI-LINUX
質問
I've successfully did a triple boot on my Macbook-pro but somehow even after creating separate EFI partitions, all my grub files ended up in the first EFI partition. So I separated them manually.
Earlier to this process, my auto boot was into the Ubuntu boot screen where I was able to select Ubuntu or Kali. To access OS-X, I had to use option key. There I got 3 options and I was able to opt any. But after separating, and using option key, it also gives me 3 options, but I get some kind of error(excuse my limited knowledge).
The following are the pics for reference.
This is the OS-X boot page.
After a few seconds, I get this page, and then I can normally log-in to either OS.
My auto-boot remained the same, which is getting the above page.
This is my disk information. Disk0s1 is OS-X, Disk0s3 is Ubuntu, Disk0s6 is Kali.
$ diskutil list disk0
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *251.0 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 120.0 GB disk0s2
3: EFI NO NAME 400.6 MB disk0s3
4: Linux Filesystem 65.0 GB disk0s4
5: Linux Swap 15.0 GB disk0s5
6: EFI NO NAME 399.5 MB disk0s6
7: Microsoft Basic Data 50.0 GB disk0s7
$ sudo gpt -r show /dev/disk0
start size index contents
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 234375000 2 GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
234784640 128
234784768 782336 3 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
235567104 126953472 4 GPT part - 0FC63DAF-8483-4772-8E79-3D69D8477DE4
362520576 29296640 5 GPT part - 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
391817216 780288 6 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
392597504 97636352 7 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
490233856 863
490234719 32 Sec GPT table
490234751 1 Sec GPT header
The following are the current partition contents.
$ sudo diskutil mount /dev/disk0s1
Volume EFI on /dev/disk0s1 mounted
$ ls -a /Volumes/EFI
. .Spotlight-V100 .fseventsd EFI
.. .Trashes BOOTLOG
$ ls -a /Volumes/EFI/EFI
. .. APPLE BOOT
$ ls -a /Volumes/EFI/EFI/APPLE
. .. CACHES EXTENSIONS FIRMWARE
$ ls -a /Volumes/EFI/EFI/APPLE/EXTENSIONS
. .. Firmware.scap
$ ls -a /Volumes/EFI/EFI/APPLE/FIRMWARE
. .. MBP121.fd
$ ls -a /Volumes/EFI/EFI/BOOT
. .. BOOTX64.EFI
$ sudo diskutil mount /dev/disk0s3
Volume NO NAME on /dev/disk0s3 mounted
$ ls -a /Volumes/NO\ NAME
. .Trashes .fseventsd
.. .VolumeIcon.icns EFI
.Spotlight-V100 ._.VolumeIcon.icns
$ ls -a /Volumes/NO\ NAME/EFI/
. .. BOOT BOOTLOG Ubuntu
$ ls -a /Volumes/NO\ NAME/EFI/BOOT
. .. BOOTX64.EFI
$ ls -a /Volumes/NO\ NAME/EFI/Ubuntu
. BOOTX64.CSV grubx64.efi shimx64.efi
.. grub.cfg mmx64.efi
$ sudo diskutil mount /dev/disk0s6
Volume NO NAME on /dev/disk0s6 mounted
$ ls -a /Volumes/NO\ NAME/
. .Spotlight-V100 .fseventsd
.. .Trashes EFI
$ ls -a /Volumes/NO\ NAME/EFI
. .. kali
$ ls -a /Volumes/NO\ NAME/EFI/kali
. .. grubx64.efi
解決
This answer assumes the following:
- You are using macOS High Sierra or newer.
- The
/etc/fstab
file is setup up correctly for Ubuntu and Kali. More specifically, each/etc/fstab
file has the correct entry for the filesystem stored in the EFI partition. - Grub is installed correctly for Ubuntu and Kali.
Below are steps that can be taken to improve your configuration.
Remove from the Mac Startup Manager the existing internal drive icon with the
EFI Boot
label shown below.Use the macOS commands given below.
sudo diskutil mount disk0s1 rm /Volumes/EFI/EFI/BOOT/BOOTX64.EFI diskutil unmount disk0s1
Give names and labels to the EFI partitions used by Ubuntu and Kali. Also, make Grub from the Kali installation appear in the Mac Startup Manager. Below are the macOS commands I would use.
sudo diskutil mount disk0s3 diskutil rename disk0s3 EFI2 bless --folder /Volumes/EFI2/EFI/BOOT --label "Ubuntu" diskutil unmount disk0s3 sudo diskutil mount disk0s6 diskutil rename disk0s6 EFI3 mkdir -p /Volumes/EFI3/EFI/BOOT cp /Volumes/EFI3/EFI/kali/grubx64.efi /Volumes/EFI3/EFI/BOOT/bootx64.efi bless --folder /Volumes/EFI3/EFI/BOOT --label "Kali" diskutil unmount disk0s6
Add a Kali linux icon to Mac Startup Manager.
Note: This step assumes you have completed the previous step.
Download the file
mac-icns.dmg
from this SourceForge website to yourDownloads
folder. Next, enter the following command to copy the Kali linux icon set (icns) file to your third EFI partition.hdiutil attach ~/Downloads/mac-icns.dmg sudo diskutil mount disk0s6 cp /Volumes/mac-icns/OSX10.11.6/os_kali.icns /Volumes/EFI3/.VolumeIcon.icns diskutil unmount disk0s6 hdiutil detach /Volumes/mac-icns
The next time you boot to the Mac Startup Manager, the following icon should appear.
Change the type of the partition containing Kali to the linux filesystem data type.
Boot to either Ubuntu or Kali linux. Open a window to enter commands. Enter the following command to edit the GUID Partition Table (GPT).
sudo gdisk /dev/sda
Enter the following commands into
gdisk
.t 7 8300 w y
Restart the Mac.
Configure Grub to be hidden and/or omit other operating systems.
Boot to either Ubuntu or Kali linux. Open a window to enter commands. Enter the following command to edit the
grub
file.sudo nano /etc/default/grub
To remove other operating systems from the Grub menu, add the line
GRUB_DISABLE_OS_PROBER=true
after the line given below.
GRUB_CMDLINE_LINUX=""
To skip the Grub menu, add the line
GRUB_TIMEOUT_STYLE=hidden
after the line given below.
GRUB_DEFAULT=0
Exit the editor and enter the following command to update Grub.
sudo update-grub
Booting Ubuntu from the Mac Startup Manager
Note: This section refers to the files stored in
/dev/sda3
.
When Ubuntu is selected from the Mac Startup Manager, the bootx64.efi
(which is a copy of shimx64.efi
) is booted before grubx64.efi
is booted. This results in Ubuntu being automatically made the default operating system to boot.
Alternative to Booting Grub Using bootx64.efi
Note: This section refers to the files stored in
/dev/sda6
.
One of the above instructions is to copy the grubx64.efi
file to the bootx64.efi
file. If the grubx64.efi
is changed during some future Kali update/upgrade, then this new file will not be copied to bootx64.efi
. One way to avoid this problem would be to replace the bootx64.efi
file with a rEFInd version. This new version would silently boot Grub from the grubx64.efi
file. Below are the steps needed to make the change.
Boot to Kali linux.
Open a window to enter commands.
Enter the following commands to remove any previous versions of rEFInd that may have been downloaded.
cd ~/Downloads rm -rf refind_*_amd64.deb refind
Use a web browser to download and save rEFInd to your
Downloads
folder from the following SourceForge website.Enter the following command to install rEFInd.
cd ~/Downloads dpkg-deb -xv refind_*_amd64.deb refind sudo refind/usr/share/refind-*/refind-install --usedefault /dev/sda6 sudo umount -q /tmp/refind_install rm -rf refind_*_amd64.deb refind cd ~
Enter the following command to open
refind.conf
file in thegedit
editor.sudo nano /boot/efi/EFI/BOOT/refind.conf
Add the following lines to the end of the
refind.conf
file.menuentry Kali { loader /EFI/kali/grubx64.efi icon /EFI/refind/icons/os_linux.png enabled } scanner manual showtools timeout -1 screensaver -1
Exit
nano
and save the changes.
References
Separating EFI partitions of Ubuntu 20.04 and Mac OSX on Macbook Pro
Fully Move Grub to New Partition
Grub2/Setup
A gdisk Walkthrough
The rEFInd Boot Manager
The rEFInd Boot Manager: Installing rEFInd
refind-install
How to extract a .deb file without opening it on Debian or Ubuntu Linux
What is the difference between grubx64 and shimx64?
How To Add Apt Repository In Ubuntu