switch over to GRUB 2

The GRUB 1 configuration hasn't been working in a while and-- let's face
it-- it's time. So now we have GRUB 2.

It should still work with a serial console though I haven't tested it yet.
This commit is contained in:
Albert Hopkins 2017-05-27 22:13:01 +00:00
parent 434d5d6759
commit 4a591cdf3a
4 changed files with 22 additions and 17 deletions

View File

@ -188,16 +188,17 @@ ifeq ($(DASH),YES)
endif
touch $(SYSTOOLS)
$(GRUB): $(PREPROOT) configs/grub.conf $(KERNEL) scripts/grub-headless.sed
$(GRUB): $(PREPROOT) configs/grub.cfg $(KERNEL) scripts/grub-headless.sed
ifneq ($(EXTERNAL_KERNEL),YES)
@scripts/echo Installing Grub
$(inroot) $(EMERGE) -nN $(USEPKG) sys-boot/grub-static
cp configs/grub.conf $(CHROOT)/boot/grub/grub.conf
$(inroot) $(EMERGE) -nN $(USEPKG) sys-boot/grub
mkdir -p $(CHROOT)/boot/grub
cp configs/grub.cfg $(CHROOT)/boot/grub/grub.cfg
ifeq ($(VIRTIO),YES)
sed -i 's/sda/vda/' $(CHROOT)/boot/grub/grub.conf
sed -i 's/sda/vda/' $(CHROOT)/boot/grub/grub.cfg
endif
ifeq ($(HEADLESS),YES)
sed -i -f scripts/grub-headless.sed $(CHROOT)/boot/grub/grub.conf
sed -i -f scripts/grub-headless.sed $(CHROOT)/boot/grub/grub.cfg
endif
endif
$(inroot) ln -nsf /run/systemd/resolve/resolv.conf /etc/resolv.conf
@ -244,7 +245,7 @@ endif
$(RAW_IMAGE): $(STAGE4_TARBALL) scripts/grub.shell scripts/motd.sh
@scripts/echo Installing files to `basename $(RAW_IMAGE)`
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
parted -s $(RAW_IMAGE).tmp mklabel gpt
parted -s $(RAW_IMAGE).tmp mklabel msdos
parted -s $(RAW_IMAGE).tmp mkpart primary 1 $(DISK_SIZE)
parted -s $(RAW_IMAGE).tmp set 1 boot on
sync
@ -255,8 +256,8 @@ $(RAW_IMAGE): $(STAGE4_TARBALL) scripts/grub.shell scripts/motd.sh
tar -xf $(STAGE4_TARBALL) --numeric-owner $(COPY_ARGS) -C $(CHROOT)
scripts/motd.sh $(EXTERNAL_KERNEL) $(VIRTIO) $(DISK_SIZE) $(SWAP_SIZE) $(DASH) $(ARCH) > $(CHROOT)/etc/motd
ifneq ($(EXTERNAL_KERNEL),YES)
echo '(hd0) ' $(RAW_IMAGE).tmp > device-map
$(CHROOT)/sbin/grub --device-map=device-map --no-floppy --batch < scripts/grub.shell
echo '(hd0) ' `cat partitions` > device-map
$(CHROOT)/usr/sbin/grub-install --no-floppy --grub-mkdevicemap=device-map --directory=$(CHROOT)/usr/lib/grub/i386-pc --boot-directory=$(CHROOT)/boot `cat partitions`
endif
umount $(CHROOT)
rmdir $(CHROOT)

10
configs/grub.cfg Normal file
View File

@ -0,0 +1,10 @@
insmod part_msdos
set timeout=2
set default=0
set fallback=1
set graphics=0
menuentry "Gentoo Linux" {
set root=(hd0,1)
linux /boot/vmlinuz root=/dev/sda1 rootfstype=ext4 net.ifnames=0 init=/usr/lib/systemd/systemd quiet
}

View File

@ -1,7 +0,0 @@
default 0
timeout 5
title Gentoo Linux
root (hd0,0)
kernel /boot/vmlinuz root=/dev/sda1 rootfstype=ext4 net.ifnames=0 init=/usr/lib/systemd/systemd quiet

View File

@ -1,3 +1,4 @@
1iserial --speed=9600 --unit=0 --word=8 --parity=no --stop=1\
1iterminal --timeout=2 serial console\
s/^\(kernel .*\)$/\1 console=ttyS0/
1iterminal_input serial\
1iterminal_output serial\
s/^\([ \t]*linux .*\)$/\1 console=tty0 console=ttyS0,38400n8/