最近研究了一下如何制作多启动移动硬盘,其中包含的操作系统有2个MacOS安装盘,Win10安装盘,Win11安装盘,Ubuntu,Fedora,OpenSUSE,Archlinux,Gentoo,Debian,RHEL,SLES。这里的启动器包括rEFInd (0.13.3.1)和Grub2 (2.06)。这里的Linux版本选择涵盖了最常用的服务器版本,分别是从Debian,RedHat,SUSE三大主流服务器过来的,具体的Linux族谱详情可以参考wiki上面的介绍。

移动硬盘的分区

这里我的移动硬盘大小是1TB(实际是931.5GB),具体GPT分区方案如图所示:
硬盘分区
稍微解释一下:

  1. 第一个分区EFI主要用来安装引导器,也就是grub2或者rEFInd,这里的目录结构为EFI-grub/BOOT/XXX和EFI-refind/BOOT/XXX。因为两个引导器可能导致目录混乱,所以安装的时候都是EFI/BOOT/XXX,需要启用哪个就保留EFI的名字,否则用EFI-xxx来重命名。
    a. 如果用grub2,命令大致是:grub-install.exe --removable --no-floppy --target=x86_64-efi --boot-directory=X:\EFI\BOOT --efi-directory=X:\
    其中,grub的配置文件存放在X:\EFI\BOOT\grub\文件夹下,grub产生的bootx64.efi存放在X:\EFI\BOOT\下。
    b. 如果用rEFInd,可以用sudo ./refind-install --usedefault /dev/sdx1,这样会把所有文件安装在/dev/sdx1/EFI/BOOT/下面。
  2. 紧接着的两个分区是macOS Mojave和macOS Monterey的安装盘,这个安装盘的制作方法非常简单,下载好镜像,然后用镜像里面的createinstallmedia命令就可以了,注意分区不要选到其他分区了。分区大小只要比安装盘的略大一点就好了。
  3. 再下来的Buffer分区是一个空分区,这个分区主要是用来调整前后分区大小的,比如上一个macOS的后一个版本的安装镜像比现在的要大,那么就用这个空间来扩展。
  4. 接着两个windows的安装盘分区,一个是Win10,一个是Win11。
  5. 接着是我存放数据的分区,也是最大的分区。
  6. 最后的是LINUX分区,这个分区的格式一定要注意,EXT2是我试过比较合适的,因为有些镜像比较大,FAT32不能够很好的支持,这个分区放到最后也有利于从前面一个分区进行分区扩展。

注意:首先安装两个macOS系统,这个没什么好说的,然后把Win10和Win11的安装盘文件解压到各自对应的分区的根目录。

附上我的目录结构:

基于rEFInd启动器的多启动移动硬盘的制作

在Linux分区创建不同的文件夹存放不同的Linux ISO文件,同时,要把各个Linux的引导(类似initrd的)和内核文件(类似vmlinuz的)从对应的ISO文件解压出来放到和ISO文件同层的地方。

注意:这里有一个例外,就是Debian系的,其他所有的引导和内核文件都是通过解压iso文件里面对应的内容到iso外面,但是,debian里面的那两个文件不管用!!!解决方法是去https://mirrors.tuna.tsinghua.edu.cn/debian/dists/Debian11.3/main/installer-amd64/current/images/hd-media/下载standard loader文件(无桌面),即vmlinuz和initrd,或者去https://mirrors.tuna.tsinghua.edu.cn/debian/dists/Debian11.3/main/installer-amd64/current/images/hd-media/gtk/下载graphical loader文件(有桌面),即vmlinuz和initrd。

rEFInd的安装

分享一下我的refind.conf,这里面的主题是用了https://github.com/Pr0cella/rEFInd-glassy,安装方法参考主题里面的位置做相应修改就好了。

timeout 60
use_nvram false
scanfor manual
include \EFI\BOOT\themes\glassy\theme.conf

menuentry "Windows 10 Setup" {
    icon \EFI\BOOT\themes\glassy\icons\os_win.png
    volume "Windows10"
    loader \EFI\boot\bootx64.efi
}

menuentry "Windows 11 Setup" {
    icon \EFI\BOOT\themes\glassy\icons\os_win8.png
    volume "Windows11"
    loader \EFI\boot\bootx64.efi
}

menuentry "Install macOS Mojave" {
    icon \EFI\BOOT\themes\glassy\icons\os_mac.png
    volume "Install macOS Mojave"
    loader \System\Library\CoreServices\boot.efi
}

menuentry "Install macOS Monterey" {
    icon \EFI\BOOT\themes\glassy\icons\os_mac_alt.png
    volume "Install macOS Monterey"
    loader \System\Library\CoreServices\boot.efi
}

menuentry "Ubuntu 20.04 LTS" {
    icon \EFI\BOOT\themes\glassy\icons\os_ubuntu.png
    volume "LINUX"
    loader /ubuntu/vmlinuz
    initrd /ubuntu/initrd
    options "iso-scan/filename=/ubuntu/jammy-desktop-amd64.iso file=/cdrom/preseed/ubuntu.seed quiet splash=silent"
}

menuentry "Fedora Workstation 35" {
    icon \EFI\BOOT\themes\glassy\icons\os_fedora.png
    volume "LINUX"
    loader /fedora/vmlinuz
    initrd /fedora/initrd.img
    options "iso-scan/filename=/fedora/Fedora-Workstation-Live-x86_64-35-1.2.iso root=live:CDLABEL=Fedora-WS-Live-35-1-2 rd.live.image nomodeset quiet rhgb"
}

menuentry "OpenSUSE Leap 15.3.3" {
    icon \EFI\BOOT\themes\glassy\icons\os_opensuse.png
    volume "LINUX"
    loader /opensuse/linux
    initrd /opensuse/initrd
    options "install=hd:/opensuse/openSUSE-Leap-15.3-3-DVD-x86_64-Media.iso splash=silent"
}

menuentry "Arch Linux" {
    icon \EFI\BOOT\themes\glassy\icons\os_arch.png
    volume "LINUX"
    loader /archlinux/vmlinuz-linux
    initrd /archlinux/initramfs-linux.img /archlinux/intel-ucode.img
    options "img_dev=/dev/disk/by-label/LINUX img_loop=archlinux/archlinux-2022.05.01-x86_64.iso"
}

menuentry "Gentoo Linux" {
    icon \EFI\BOOT\themes\glassy\icons\os_gentoo.png
    volume "LINUX"
    loader /gentoo/gentoo
    initrd /gentoo/gentoo.igz
    options "root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot isoboot=/gentoo/install-amd64-minimal-20220508T170538Z.iso"    
}

menuentry "Debian 11.3.0" {
    icon \EFI\BOOT\themes\glassy\icons\os_debian.png
    volume "LINUX"
    loader /debian/vmlinuz
    initrd /debian/initrd.gz
    options "findiso=/debian/debian-11.3.0-amd64-DVD-1.iso splash=silent"
}

menuentry "RHEL 9.0" {
    icon \EFI\BOOT\themes\glassy\icons\os_redhat.png
    volume "LINUX"
    loader /redhat/vmlinuz
    initrd /redhat/initrd.img
    options "inst.repo=hd:LABEL=LINUX:/redhat/rhel-baseos-9.0-x86_64-dvd.iso quiet"
}

menuentry "SLES 15 SP4" {
    icon \EFI\BOOT\themes\glassy\icons\os_suse.png
    volume "LINUX"
    loader /suse/linux
    initrd /suse/initrd
    options "splash=silent quiet nomodeset install=hd:/suse/SLE-15-SP4-Full-x86_64-PublicRC-202204-Media1.iso"
}

theme.conf如下:

hideui hints
icons_dir \EFI\BOOT\themes\glassy\icons

banner \EFI\BOOT\themes\glassy\background.png
banner_scale fillscreen

selection_big   \EFI\BOOT\themes\glassy\icons\selection_big.png
selection_small \EFI\BOOT\themes\glassy\icons\selection_small.png

font \EFI\BOOT\themes\glassy\fonts\nimbus-mono-28.png
showtools reboot, shutdown

基于Grub2启动器的多启动移动硬盘的制作

用Grub2的好处是不用从Linux ISO文件里面解压出来引导所需的文件,每个文件夹下只需要一个Linux ISO文件就好了(Debian除外)。在EFI\boot下面的grub文件夹下,如果没有grub.cfg,手动添加就好了,因为我用了tela主题,所以在grub/themes/文件夹下面有tela文件夹。简要介绍一下如何使用tela:

  1. 从GitHub克隆tela这个仓库。
  2. 将仓库目录下的tela整个文件夹放到/grub/themes/下面。
  3. 在仓库目录assets/backgrounds文件夹下面选出来一张喜欢的背景图片,命名为background.png放到/grub/themes/tela下面。
  4. 将仓库目录assets/icons/color文件夹下面的所有文件复制到/grub/themes/tela/icons文件夹下(这里先新建这个icons文件夹)。
  5. 从仓库目录assets/progressbar下面挑选出一张喜欢的进度条图片重命名为progress_highlight_c.png放到/grub/themes/tela下面。

注意:下面的--class选项的名称要和icons下面所选的图片名称一样,比如--class suse匹配icons/下面suse.png这张图片。

下面,贴出我用的grub.cfg,里面针对某些Linux的参数可以通过这些Linux ISO文件里面的grub.cfg可以找到,例如CDLABEL。

set default=0
set timeout=60 

# Disk format modules
insmod part_gpt
insmod fat
insmod ext2

# Video support modules
insmod all_video
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus

# Image support modules
insmod png
insmod jpeg

# Enable grub graphic terminals
set gfxterm=auto
set gfxpayload=keep
terminal_output gfxterm

# Set grub2 themes
loadfont /EFI/BOOT/grub/themes/tela/JetBrainsMonBold24.pf2
set theme=/EFI/BOOT/grub/themes/tela/theme.txt
export theme

# Loopback modules
insmod loopback

menuentry "Windows 10 Setup" --class win10 {
    search --no-floppy --label "Windows10" --set root
    chainloader /efi/boot/bootx64.efi
}

menuentry "Windows 11 Setup" --class win11 {
    search --no-floppy --label "Windows11" --set root
    chainloader /efi/boot/bootx64.efi
}

menuentry "Install macOS Mojave" --class mojave {
   search --no-floppy --label "Install macOS Mojave" --set root
   chainloader /System/Library/CoreServices/boot.efi
}

menuentry "Install macOS Monterey" --class monterey {
   search --no-floppy --label "Install macOS Monterey" --set root
   chainloader /System/Library/CoreServices/boot.efi
}

menuentry "Ubuntu 20.04 LTS" --class ubuntu {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/ubuntu/jammy-desktop-amd64.iso
    loopback loop ${iso_file}
    linux (loop)/casper/vmlinuz iso-scan/filename=${iso_file} file=/cdrom/preseed/ubuntu.seed quiet splash=silent
    initrd (loop)/casper/initrd
}

menuentry "Fedora Workstation 35" --class fedora {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/fedora/Fedora-Workstation-Live-x86_64-35-1.2.iso
    loopback loop ${iso_file}
    linux (loop)/isolinux/vmlinuz iso-scan/filename=${iso_file} root=live:CDLABEL=Fedora-WS-Live-35-1-2 rd.live.image splash=silent
    initrd (loop)/isolinux/initrd.img
}

menuentry "OpenSUSE Leap 15.3.3" --class opensuse {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/opensuse/openSUSE-Leap-15.3-3-DVD-x86_64-Media.iso
    loopback loop ${iso_file}
    linux (loop)/boot/x86_64/loader/linux install=hd:${iso_file} splash=silent
    initrd (loop)/boot/x86_64/loader/initrd
}

menuentry "Arch Linux" --class arch {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/archlinux/archlinux-2022.05.01-x86_64.iso
    loopback loop ${iso_file}
    linux (loop)/arch/boot/x86_64/vmlinuz-linux img_dev=/dev/disk/by-label/LINUX img_loop=${iso_file}
    initrd (loop)/arch/boot/x86_64/initramfs-linux.img (loop)/arch/boot/intel-ucode.img
}

menuentry "Gentoo Linux" --class gentoo {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/gentoo/install-amd64-minimal-20220508T170538Z.iso
    loopback loop ${iso_file}
    linux (loop)/boot/gentoo root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot isoboot=${iso_file} splash=silent
    initrd (loop)/boot/gentoo.igz
}

menuentry "Debian 11.3.0" --class debian {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/debian/debian-11.3.0-amd64-DVD-1.iso
    loopback loop ${iso_file}
    linux /debian/vmlinuz findiso=${iso_file} splash=silent
    initrd /debian/initrd.gz
}

menuentry "RHEL 9.0" --class redhat {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/redhat/rhel-baseos-9.0-x86_64-dvd.iso
    loopback loop ${iso_file}
    linux (loop)/isolinux/vmlinuz inst.repo=hd:LABEL=LINUX:${iso_file} quiet
    initrd (loop)/isolinux/initrd.img
}

menuentry "SLES 15 SP4" --class suse {
    search --no-floppy --label "LINUX" --set root
    set iso_file=/suse/SLE-15-SP4-Full-x86_64-PublicRC-202204-Media1.iso
    loopback loop ${iso_file}
    linux (loop)/boot/x86_64/loader/linux splash=silent quiet install=hd:${iso_file} nomodeset
    initrd (loop)/boot/x86_64/loader/initrd
}

menuentry 'NixOS Gnome 23.05' {
    search --no-floppy --label "LINUX" --set root
    set isofile="/latest-nixos-gnome-x86_64-linux.iso"
    loopback loop "$isofile"
    linux (loop)/boot/bzImage init=/nix/store/qfk353msxsvs123wsjyvmwil7qvs2pnn-nixos-system-nixos-23.05.1375.9790f3242da/init findiso="$isofile" rd.live.image root=LABEL=LINUX quiet splash
    initrd (loop)/boot/initrd
}

menuentry "Reboot" --class reboot {
    reboot
}

menuentry "Shutdown" --class shutdown {
    halt
} 

最后附上我个人的grub2和rEFInd的最终文件压缩包

EFI-grub
EFI-refind

posted @ 2020-03-01 12:26 alexanderzjs 阅读(6540) 评论(0) 推荐(0) 编辑
摘要: Hyper V导入win11虚拟机的时候,会出现key protector program unwrapped error类似的错误信息导致导入失败。这主要是证书问题导致的。 所以在到处虚拟机的时候先运行win11export.ps1,生成两个证书。然后在导入之前,运行win11import.ps1 阅读全文
posted @ 2023-08-17 11:25 alexanderzjs 阅读(358) 评论(0) 推荐(0) 编辑
摘要: Ngnix上配置HTTPS不算特别复杂,下面记录一下整体过程。 ## 生成自签名的SSL证书 通过下面命令生成一系列文件,最终只需要server.key和server.crt两个就可以了 ``openssl genrsa -des3 -out server_temp.key 2048`` ``ope 阅读全文
posted @ 2023-06-23 09:06 alexanderzjs 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 公司连接外网需要代理,所以下载Docker镜像(docker pull)需要配置代理。下面是方法: mkdir -p /etc/systemd/system/docker.service.d vim /etc/systemd/system/docker.service.d/http-proxy.co 阅读全文
posted @ 2023-06-20 15:48 alexanderzjs 阅读(1002) 评论(0) 推荐(0) 编辑
摘要: 简要记录下自己折腾两天的成果,以便后来人使用。顺便吐槽下,网上的教程五花八门,感觉就是说不到点上,我来试着解释清楚每一步需要做什么方便大家理解。 ## 基础环境介绍 公司给配置了一台个人用的台式机,接入公司网络,由于公司网络限制,只分配了一个公司内网地址(假设这个地址是101.101.101.101 阅读全文
posted @ 2023-06-15 15:10 alexanderzjs 阅读(13988) 评论(6) 推荐(1) 编辑
摘要: 源码编译Python 3.11 MacOS上安装Python 3.11的时候为了不用官方给的那个安装包把Python安装到自己不知道的目录,所以折腾了一下如何从源码编译。 前提条件 安装xcode-select; 安装Homebrew; 下载并解压Python 3.11的源码。 安装依赖 brew 阅读全文
posted @ 2023-04-07 16:32 alexanderzjs 阅读(258) 评论(0) 推荐(0) 编辑
摘要: OpenCore最终效果如下图:。Clover其实效果差不多,不过由于后续可能不再支持了,所以主推OpenCore。另外,由于OpenCore自身开发不是用来做多系统引导的,所以,附上我个人魔改的OpenCore启动器教程: https://github.com/alexanderzjs/OpenC 阅读全文
posted @ 2022-05-30 21:40 alexanderzjs 阅读(3573) 评论(0) 推荐(0) 编辑
摘要: # Win11 PE的制作方法 Windows 11 PE的ISO镜像制作方法可以参考[微软官方的制作方法](https://docs.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/download-winpe--windows-p 阅读全文
posted @ 2022-05-25 16:24 alexanderzjs 阅读(2545) 评论(0) 推荐(0) 编辑
摘要: Ubuntu 20.04 LTS升级到Ubuntu滚动版 Ubuntu的滚动版是通过更新内核和根据新的release的软件仓库更新现有软件实现的,并不是真正的滚动版。 从https://wiki.ubuntu.com/Releases获取future release's的代码的首个单词 替换下面链接 阅读全文
posted @ 2022-05-24 19:57 alexanderzjs 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 本文着重于解决gradle本身,以及gradle在eclipse和idea里面出现中文乱码的问题。 问题表现 问题的表现非常的简单,就是gradle在build的时候,compileJava这个任务的输出中有中文无法正常显示。出现下面几种表现: 中文输出“锟斤拷” 中文输出“???” 中文输出“�� 阅读全文
posted @ 2022-02-07 13:30 alexanderzjs 阅读(3876) 评论(2) 推荐(3) 编辑
摘要: 最近工作需求,需要在Windows 10开发Spring Boot应用,不过由于Intellij收费的缘故,转而使用VSCode,经过一系列的配置,终于让Spring Boot程序成功跑起来了(基于Gradle和Maven)。下面简要描述一些需要注意的点。 VSCode Extension的安装 在 阅读全文
posted @ 2021-12-01 15:09 alexanderzjs 阅读(1012) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示