cd /tmp grub-mkrescue --output=grub-img.iso #需要安装xorriso wget https://mirrors.ustc.edu.cn/gnu/xorriso/xorriso-1.3.0.tar.gz tar -zxvf xorriso-1.3.0.tar.gz cd xorriso-1.3.0 ./configure --prefix=/usr make make install xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso
#将配置文件写入(如果没有目录则自己创建) cat > /boot/grub/grub.cfg << "EOF" # Begin /boot/grub/grub.cfg
set default=0 set timeout=5 insmod ext2 set root=(hd0,2) menuentry "GNU/Linux, Linux 4.20.12-lfs-8.4" { linux /boot/vmlinuz-4.20.12-lfs-8.4 root=/dev/sda2 ro } EOF