⚠️ This post was last updated on February 23, 2022 and the content may be OUTDATED!
If you encounter any issues, please feel free to reachout to me!
OS:Arch Linux + Windows 10
bootloader:GRUB
因为偶尔仍然要使用 Windows 做些事情,之前每次都是通过 GURB 的界面退出操作进行重新选择,很是麻烦,所以就尝试进行配置 Arch Linux+Windows 的双启动。用的工具是 os-prober,操作很简单。
1、首先安装os-prober
:
[root@archlinux /]# pacman -S os-prober
2、检查磁盘分区,确认 Windows 的安装位置(根据自己的安装情况选择磁盘设备,我这里是/dev/sda
):
[root@archlinux /]# fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SA400S3
Units: sectors of 1 \* 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 78241A73-6994-4D0B-9FCB-433076B5EC41
Device Start End Sectors Size Type
/dev/sda1 2048 1023999 1021952 499M Windows recovery environment
/dev/sda2 1024000 1228799 204800 100M EFI System
/dev/sda3 1228800 1261567 32768 16M Microsoft reserved
/dev/sda4 1261568 468860927 467599360 223G Microsoft basic data
3、找到 Windows 的 EFI 分区之后,挂载它以确保os-prober
可以发现:
[root@archlinux /]# mount /dev/sda2 /mnt/
[root@archlinux /]# ls -l /mnt/
total 1
drwxr-xr-x 4 root root 1024 Feb 23 10:24 EFI
4、然后执行os-prober
:
[root@archlinux /]# os-prober
/dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi
5、当然,为了安全起见,首先执行下面命令,备份原有的 boot 配置:
[root@archlinux /]# cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
6、然后,重新生辰 GRUB 配置文件:
[root@archlinux /]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
done
7、最后重启电脑就可以在 GRUB 界面直接选择想要进入的操作系统了。
❦
Sooner or later, everything ends.