现在装系统都是用u盘安装了,一个u盘只能安装一个系统有些浪费了,因为空间足够大,可以装下好几个iso文件。
在linux环境中,使用dd命令只能制作一个引导盘,且其他空间不能再使用。从网上看用YUMI可以比较方便的制作多系统引导。然而实测发现是linux系统上实在太难用,装WINE也用不了。后来看到grub的方法成功实现了。
grub的方法分为两步:
- 对u盘分区,拷入iso文件
- 安装grub,编辑grub.cfg
u盘分区
首先可以找一找是否有现成的分区软件可以用,比如manjaro-kde自带的KDE partion manager。
下面还是给出fdisk的命令来复盘整个过程。
1
2
3
4
5
6
7
8
9
10
|
sudo su # 提升权限方便后续操作
fdisk -l # 查看当前分区,查找到u盘对应的位置,比如/dev/sdb
mkfs /dev/sdb # 格式化
fdisk /dev/sdb # 分区开始
d # 删除原分区
n # 新分区
a # 增加引导标志
t # 更改类型
w # 写入保存
m # 看help
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
I. Format your USB Flash Drive to use a Single Partition:
Open a terminal and type sudo su
Type fdisk -l (and note which device is your USB Drive)
Type fdisk /dev/sdx (replacing x with your actual usb device)
Type d (to delete the existing partition)
Type n (to create a new partition)
Type p (for primary partition)
Type 1 (to create the first partition)
Press Enter (to use the first cylinder)
Press Enter again (to use the default value as the last cylinder)
Type a (for active)
Type 1 (to mark the first partition active "bootable")
Type t (for partition type)
Type c (to use fat32 partition)
Type w (to write the changes and close fdisk)
II. Create a Fat32 Filesystem on the USB Flash Drive:
Type umount /dev/sdx1 (to unmount the mounted partition)
Type mkfs.vfat -F 32 -n MULTIBOOT /dev/sdx1 (to format the partition as fat32)
Remove and reinsert your USB flash drive, or remount it
|
grub
挂载,安装grub
1
2
|
mount /dev/sdb1 /mnt/udisk/linux/
grub-install --root-directory=/mnt/udisk/linux/ --boot-directory=/mnt/udisk/linux/boot/ --no-floppy /dev/sdb
|
grub配置,各linux发行版的grub menu都不太一样,需要从网上查找以及和iso中的文件进行比对,我现在用的manjaro和ubuntu的配置如下,亲测可以使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
set timeout=10
insmod fat
set default=0
loadfont /boot/grub/fonts/unicode.pf2
set gfxmode=1920x1080
set theme="/boot/grub/themes/starfield/theme.txt"
export theme
set gfxpayload=keep
insmod gfxterm
insmod vbe
insmod loopback
insmod iso9660
terminal_output gfxterm
insmod jpeg
background_image /boot/grub/grub.jpg
setmenu_color_normal=white/black
setmenu_color_highlight=black/light-gray
set USBUUID="306B-1C5B"
menuentry "manjaro-kde-2012" --class manjaro{
set isofile="/iso/manjaro-kde-20.1.2-201019-linux58.iso"
set dri="free"
search --no-floppy -f --set=root $isofile
probe -u $root --set=abc
set pqr="/dev/disk/by-uuid/$abc"
loopback loop $isofile
linux (loop)/boot/vmlinuz-x86_64 img_dev=$pqr img_loop=$isofile driver=$dri lang=zh_CN
initrd (loop)/boot/intel_ucode.img (loop)/boot/initramfs-x86_64.img
}
menuentry "Ubuntu2004" {
set isofile="/iso/ubuntu-20.04.1-desktop-amd64.iso"
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile locale=zh_CN.UTF-8
initrd (loop)/casper/initrd
}
menuentry "System shutdown" --class shutdown {
echo "System shutting down..."
halt
}
menuentry "System restart" --class restart {
echo "System rebooting..."
reboot
}
|