笔记本efi安装kali
by Flavio De Stefano
由弗拉维奥·德·斯特凡诺(Flavio De Stefano)
如何在Mac上通过纯EFI引导将Kali安装在USB记忆棒上(以及通过Virtualbox在USB上进行虚拟化) (How to install Kali on a USB stick with pure EFI boot on a Mac (and let’s throw in virtualization via USB on Virtualbox, too))
This tutorial is for everyone who wants a USB stick with a full Kali installation to use with your Mac(s). This is not intended to perform a Live Kali installation with persistence.
本教程适用于所有想要完整安装Kali的USB记忆棒与Mac一起使用的人。 这并不是要持久执行Live Kali安装。
The problem when you perform a Kali installation on a USB stick is that Kali partitions the disk with the VFAT file system. Mac OS only recognizes HFS+ partitions along with some files needed for it.
在USB记忆棒上执行Kali安装时的问题是Kali使用VFAT文件系统对磁盘进行了分区。 Mac OS仅识别HFS +分区以及所需的一些文件。
So, you need:
因此,您需要:
- Your Mac 您的Mac
- A USB stick with Kali ISO installer 带有Kali ISO安装程序的USB记忆棒
- A target USB stick, SD card or an SSD external drive where you’re going to install Kali (16GB and USB 3.0 recommended) 要在其中安装Kali的目标USB记忆棒,SD卡或SSD外部驱动器(建议使用16GB和USB 3.0)
This tutorial was heavily inspired by this tutorial with proper fixes for Kali. https://medium.com/@mmiglier/ubuntu-installation-on-usb-stick-with-pure-efi-boot-mac-compatible-469ad33645c9
本教程的主要灵感是针对Kali的正确修复。 https://medium.com/@mmiglier/ubuntu-installation-on-usb-stick-with-pure-efi-boot-mac-compatible-469ad33645c9
USB Live安装 (USB Live installation)
First of all, install Kali on a USB stick by following this tutorial. I’m not gonna bother you on how to proceed on this step, but start here:
首先,按照本教程将Kali安装在USB记忆棒上。 我不会打扰您如何进行此步骤,而是从这里开始:
$ sudo dd if={KALI_ISO.iso} of=/dev/{USB} bs=1m
When you’re ready, reboot your Mac. Insert both your USB sticks, then press ALT and select the EFI boot to start the Live installer.
准备就绪后,重新启动Mac。 插入两个USB记忆棒,然后按ALT并选择EFI引导以启动Live安装程序。
Kali installer will ask you different questions about your timezone and keyboard layout.
Kali安装程序将询问您有关时区和键盘布局的不同问题。
Proceed until it asks you to partition disks, here select: Manual. Then select your USB target drive (where you want to install Kali). You can recognize by various factors, for example by its size. Click Continue: this will partition your drive.
继续操作,直到要求您对磁盘进行分区为止,在此选择: 手动。 然后选择您的USB 目标驱动器(要在其中安装Kali)。 您可以通过各种因素来识别,例如通过其大小。 单击继续:这将对驱动器进行分区。
Now, back again to the same screen and select the FREE SPACE under the USB target drive. Click Continue and select Automatically partition the free space. Follow the recommended option. Then click on Finish partitioning and write the change to disk.
现在,再次返回同一屏幕,然后在USB目标驱动器下选择FREE SPACE 。 单击继续,然后选择自动分区可用空间。 请遵循建议的选项。 然后单击“ 完成分区”并将更改写入磁盘 。
The installation process now will copy data to disk. Wait until it finishes (this is gonna take ~30 minutes).
现在,安装过程会将数据复制到磁盘。 等到它完成为止(这大约需要30分钟)。
从GRUB Live引导 (Boot from GRUB Live)
Once finished, your Mac will reboot and you have to press ALT again. Select EFI boot again.
完成后,Mac将重新启动,您必须再次按ALT 。 再次选择EFI引导 。
What we have to do now is to load our installed Kali system via Live GRUB, because our installed system doesn’t have a recognizable boot-loader by MacOS.
我们现在要做的是通过Live GRUB加载已安装的Kali系统,因为我们的已安装系统没有MacOS可识别的引导加载程序。
Once GRUB is loaded, press c to get the GRUB command-line-interface.
加载GRUB后,按c获取GRUB命令行界面。
Now you have to understand in which HD is your Kali installation. To do this, when GRUB cli is loaded, type ls; eject your USB stick and type ls again.
现在,您必须了解Kali安装在哪个HD中。 为此,在加载GRUB cli时,键入ls ; 弹出USB记忆棒,然后再次键入ls 。
grub> ls
(memdisk) (hd0) (hd1) (hd1,gpt3) (hd1, gpt2) (hd1,gpt1) ...
You’ll notice that an hd{X} disappeared: that is your drive. Now you have to find your gpt. Probably it’s the gpt2, but just to be sure, type:
您会注意到hd {X}消失了:这就是您的驱动器。 现在,您必须找到您的gpt。 可能是gpt2 ,但可以肯定的是,键入:
grub> ls (hdX,gpt2)/boot/grub
unicode.pf2 ...
If the command says unicode..
it’s the correct gpt; try other gpts otherwise. Now find your UUID of the partition, and annotate it.
如果命令说的是unicode..
那是正确的gpt; 否则,请尝试其他gpt 。 现在找到分区的UUID,并对其进行注释。
grub> ls -l (hdX},gpt{X})
Partition hd2,gpt2: Filesystem type ext* 〈...snip...〉 UUID e86c20b9-83e1-447d-a3be-d1ddaad6c4c6 - Partition start at [...]
Now we cant set the parameters to GRUB to boot (use the tab key to use autocomplete):
现在我们无法将参数设置为GRUB来引导(使用tab键使用自动完成功能):
grub> set root=(hd{X},gpt{X})
grub> linux /boot/vmlinuz〈...tab here!...〉.efi.signed root=UUID=〈the UUID〉
grub> initrd /boot/initrd〈...tab here!...〉
grub> boot
This should boot your Full Kali Installation using the Live GRUB. You could differentiate from Live environment by the password it recognizes during the login process.
这应该使用Live GRUB引导您的Full Kali安装 。 您可以通过在登录过程中识别出的密码来与Live环境区分开。
修复EFI分区 (Fixing the EFI partition)
Once you’re logged in in your Kali installation, open the Terminal and type:
登录Kali安装后,打开终端并输入:
$ fdisk -l
and find your drive.
并找到您的驱动器。
Now, open gdisk (installed by default on Kali) to partition the drive (be very careful here):
现在,打开gdisk (默认情况下安装在Kali上)以对驱动器进行分区(在此非常小心):
$ gdisk /dev/sd{X}
GPT fdisk (gdisk) version 1.0.1
Partition table scan:
MBR: hybrid
BSD: not present
APM: not present
GPT: present
Found valid GPT with hybrid MBR; using GPT.
Command (? for help):
Print the partition table and confirm that the first partition has type EF00:
打印分区表并确认第一个分区的类型为EF00:
Command (? for help): p
Disk /dev/sdd: ...
[...]
Number Start (sector) End (sector) Size Code Name
1 2048 1050623 512.0 MiB EF00 EFI System Partition
[...]
Now we have to:
现在我们必须:
- delete that EF00 partition 删除该EF00分区
- create a new HFS+ once in its place 一次创建一个新的HFS +
Command (? for help): d
Partition number (1-3): 1
Command (? for help): n
Partition number (1-128, default 1): 1
Just leave defaults values in the sector phase
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): AF00
Changed type of partition to 'Apple HFS/HFS+'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdd.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Now we have an unformatted HFS+ partition. To format, we need some tools; but to obtain these tools we need to add the Debian source-list to apt.
现在,我们有了一个未格式化的HFS +分区。 要进行格式化,我们需要一些工具。 但是要获得这些工具,我们需要将Debian源列表添加到apt中。
$ echo "deb http://ftp.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/debian.list
$ apt update
$ apt install hfsprogs
We can format that partition:
我们可以格式化该分区:
$ mkfs.hfsplus /dev/sd{X}1 -v Kali
Initialized /dev/sd{X}1 as a 512 MB HFS Plus volume
Now we have to edit the /etc/fstab file:
现在我们必须编辑/ etc / fstab文件:
$ gedit /etc/fstab
This will launch Gedit. In this file, localize these lines:
这将启动Gedit。 在此文件中,本地化以下行:
# /boot/efi was on /dev/sd{X}1 during installation
#/ boot / efi在安装过程中位于/ dev / sd {X} 1上
# /boot/efi was on /dev/sd{X}1 during installationUUID={XXXXXXX} /boot/efi vfat defaults 0 1
#/ boot / efi在安装过程中位于/ dev / sd {X} 1上 UUID = {XXXXXXX} / boot / efi vfat默认值为0 1
and delete them.
并删除它们。
Now, unmount the boot partition, localizing it using:
现在,卸载引导分区,使用以下方法将其本地化:
$ mount | grep /boot/efi
/dev/sd{Y}1 on /boot/efi ...
$ umount /dev/sd{Y}1
Then run this to add the necessary entries to your fstab file:
然后运行此命令以将必要的条目添加到您的fstab文件中:
$ echo "UUID=$(blkid -o value -s UUID /dev/sd{X}1) /boot/efi auto defaults 0 0" >> /etc/fstab
Now we have to reinstall GRUB so it can use the newly formatted HFS+ partition for its EFI data:
现在我们必须重新安装GRUB,以便它可以将新格式化的HFS +分区用于其EFI数据:
$ mkdir -p /boot/efi/EFI/Kali
$ echo "This file is required for booting" > /boot/efi/EFI/Kali/mach_kernel
$ echo "This file is required for booting" > /boot/efi/mach_kernel
$ grub-install --target x86_64-efi --boot-directory=/boot --efi-directory=/boot/efi --bootloader-id=Kali
We then need to “bless” the bootloader code, so that the Mac bootloader will boot it. To do that we need hfsbless binary that is not available via apt. No problem, just clone the repository and build:
然后,我们需要“祝福”引导程序代码,以便Mac引导程序将其引导。 为此,我们需要无法通过apt获得的hfsbless二进制文件。 没问题,只需克隆存储库并构建:
$ cd /root
$ git clone https://github.com/detly/mactel-boot
$ cd mactel-boot
$ make
Then bless:
然后祝福:
./hfs-bless /boot/efi/EFI/Kali/System/Library/CoreServices/boot.efi
The final step is to create the grub configuration:
最后一步是创建grub配置:
$ sed -i 's/GRUB_HIDDEN/#GRUB_HIDDEN/g' /etc/default/grub
$ sed -i 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=0.1/' /etc/default/grub
$ grub-mkconfig -o /boot/grub/grub.cfg
Perfecto! Now reboot and you should see your USB stick in the Mac bootloader by pressing ALT.
完美! 现在重新启动,然后按ALT键 ,您应该会在Mac bootloader中看到USB记忆棒。
通过Virtualbox虚拟化USB (Virtualizing the USB via Virtualbox)
If you ever need to boot this USB stick via Virtualbox (on Mac OSX), there is a simple trick to do that.
如果您需要通过Virtualbox(在Mac OSX上)引导此USB记忆棒,则有一个简单的技巧。
First of all, you’ve to create a VMDK disk that points to the sectors of your USB stick. So, let’s identify that disk:
首先,您必须创建一个指向USB记忆棒扇区的VMDK磁盘。 因此,让我们确定该磁盘:
$ diskutil list
/dev/disk0 (internal):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme 500.3 GB disk0
1: EFI EFI 314.6 MB disk0s1
2: Apple_APFS Container disk1 499.3 GB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +499.3 GB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD 222.0 GB disk1s1
2: APFS Volume Preboot 22.4 MB disk1s2
3: APFS Volume Recovery 519.9 MB disk1s3
4: APFS Volume VM 3.2 GB disk1s4
/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *32.0 GB disk3
In our case, it is /dev/disk3. Let’s unmount before proceeding:
在我们的例子中,它是/ dev / disk3。 在继续之前让我们卸载:
$ diskutil unmountDisk /dev/disk{X}
With VirtualBox installed, run:
安装VirtualBox后,运行:
$ sudo VBoxManage internalcommands createrawvmdk -filename ~/Kali.vmdk -rawdisk /dev/disk{X}
$ chmod 777 ~/Kali.vmdk
$ chmod 777 /dev/disk{X}
Perfecto. Now, run Virtualbox UI and create a new machine with the following settings:
完美 现在,运行Virtualbox UI并使用以下设置创建新计算机:
When VirtualBox asks you for a disk, let’s point to that VMDK created before:
当VirtualBox要求您提供磁盘时,让我们指向之前创建的VMDK:
Before starting up the machine, let’s go to Settings and adjust your process counts, video and memory.
在启动机器之前,让我们进入“设置”并调整过程计数,视频和内存。
The important things are to set Enable EFI under System > Motherboard.
重要的是在“ 系统”>“主板”下设置“ 启用EFI ”。
This will allow you to boot via EFI. Now start the virtual machine and immediately press F12.
这将允许您通过EFI引导。 现在启动虚拟机,然后立即按F12键。
Select Boot Maintenance Manager:
选择启动维护管理器:
Select Boot from file:
选择从文件启动:
Then select {SATA_DRIVE} > EFI > Kali > System > Library > CoreServices > boot.efi
然后选择{ SATA_DRIVE}> EFI> Kali> System> Library> CoreServ ices > boot.efi
And, voilà:
而且,
Stay tuned :)
敬请关注 :)
笔记本efi安装kali