You are not logged in.

#1 2016-12-07 18:00:25

w201
Member
Registered: 2012-10-04
Posts: 289

[SOLVED] Get Syntax Error When I Run grub-mkconfig

Hi All,

I need a little help with my grub config files. A while back I had a dual boot setup with Arch/Windows 10, so I created a menu entry via /etc/grub.d/40_custom. Windows 10 is now long gone, but I had never bothered removing the menu entry until yesterday, so now when I run grub-mkconfg I get syntax errors on /boot/grub/grub.cfg.

A search turned up a few hits saying this could be a bug, so I applied the following fix to no avail:
https://bugs.archlinux.org/task/38041?p … tring=grub

The syntax error is line 160. Any ideas?

Here's my grub.cfg:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt 
insmod ext2
set root='hd1,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  6f4f7035-408f-4c81-baba-eec01ecff9c7
else
  search --no-floppy --fs-uuid --set=root 6f4f7035-408f-4c81-baba-eec01ecff9c7
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
insmod part_gpt 
insmod ext2
set root='hd1,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  6f4f7035-408f-4c81-baba-eec01ecff9c7
else
  search --no-floppy --fs-uuid --set=root 6f4f7035-408f-4c81-baba-eec01ecff9c7
fi
insmod gfxmenu
loadfont ($root)/boot/grub/themes/starfield/dejavu_10.pf2
loadfont ($root)/boot/grub/themes/starfield/dejavu_12.pf2
loadfont ($root)/boot/grub/themes/starfield/dejavu_14.pf2
loadfont ($root)/boot/grub/themes/starfield/dejavu_16.pf2
loadfont ($root)/boot/grub/themes/starfield/dejavu_bold_14.pf2
insmod png
set theme=($root)/boot/grub/themes/starfield/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-6f4f7035-408f-4c81-baba-eec01ecff9c7' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt 
	insmod ext2
	set root='hd1,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  6f4f7035-408f-4c81-baba-eec01ecff9c7
	else
	  search --no-floppy --fs-uuid --set=root 6f4f7035-408f-4c81-baba-eec01ecff9c7
	fi
	echo	'Loading Linux linux ...'
	linux	/boot/vmlinuz-linux root=UUID=6f4f7035-408f-4c81-baba-eec01ecff9c7 rw  quiet
	echo	'Loading initial ramdisk ...'
	initrd	 /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-6f4f7035-408f-4c81-baba-eec01ecff9c7' {
	menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-6f4f7035-408f-4c81-baba-eec01ecff9c7' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt 
		insmod ext2
		set root='hd1,gpt2'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  6f4f7035-408f-4c81-baba-eec01ecff9c7
		else
		  search --no-floppy --fs-uuid --set=root 6f4f7035-408f-4c81-baba-eec01ecff9c7
		fi
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=6f4f7035-408f-4c81-baba-eec01ecff9c7 rw  quiet
		echo	'Loading initial ramdisk ...'
		initrd	 /boot/initramfs-linux.img
	}
	menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-6f4f7035-408f-4c81-baba-eec01ecff9c7' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt 
		insmod ext2
		set root='hd1,gpt2'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  6f4f7035-408f-4c81-baba-eec01ecff9c7
		else
		  search --no-floppy --fs-uuid --set=root 6f4f7035-408f-4c81-baba-eec01ecff9c7
		fi
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=6f4f7035-408f-4c81-baba-eec01ecff9c7 rw  quiet
		echo	'Loading initial ramdisk ...'
		initrd	 /boot/initramfs-linux-fallback.img
	}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
 menuentry 'Windows 10 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-5E5CCCDB5CCCAED9' {
	insmod part_msdos 
	insmod ntfs
	set root='hd0,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  5E5CCCDB5CCCAED9
	else
	  search --no-floppy --fs-uuid --set=root 5E5CCCDB5CCCAED9
	fi
	drivemap -s (hd0) ${root}
	chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "Windows 10" {
	set root=(hd0,1)
	chainloader +1
}
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/60_memtest86+ ###
### END /etc/grub.d/60_memtest86+ ###

Last edited by w201 (2016-12-09 08:21:43)

Offline

#2 2016-12-08 16:57:25

w201
Member
Registered: 2012-10-04
Posts: 289

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

Wow, nothing huh? I guess as long as my system continues to boot I won't worry about the syntax error, but does anyone know what I need to do to remove Windows 10 from the menu entry, it's an eyesore. Commenting out 40_custom does nothing. All my searches lead to dead ends, so I could use a little help here.

Offline

#3 2016-12-08 17:24:08

alex.theoto
Member
From: Athens Greece
Registered: 2014-11-30
Posts: 307

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

Don't bump.
Remove os-prober and try grub-reboot command.

Offline

#4 2016-12-08 18:05:20

w201
Member
Registered: 2012-10-04
Posts: 289

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

What exactly am I accomplishing with the grub-reboot command?

Offline

#5 2016-12-08 21:21:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 79,185

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

Your grub.cfg is "old" and pointless, the buggy file is written into grub.cfg.new, thus not used.
The syntax error is somewhere in the config files, not the grub.cfg itself.

=> One needs to see /etc/default/grub and /etc/grub.d/*

Online

#6 2016-12-08 23:32:47

w201
Member
Registered: 2012-10-04
Posts: 289

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

I've checked the files in those directories, but I'll take another look. From my understanding, one makes configuration changes via /etc/default/grub and /etc/grub.d/, and those changes are pushed into grub.cfg, correct? If grub.cfg is not being used because it's "old and buggy", then what file is being used as a bootloader? My system still boots.

Last edited by w201 (2016-12-08 23:33:19)

Offline

#7 2016-12-09 05:06:49

WFV
Member
From: ☭USSA⛧⭒⭒⭒⭒
Registered: 2013-04-23
Posts: 290

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

just edit grub so that section is:

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

save and reboot, just remember, next time you run

grub-mkconfig -o /boot/grub/grub.cfg

it will put the W10 thing back in as it is coming from /etc/grub.d/30_os_prober

Last edited by WFV (2016-12-09 05:09:53)


∞ hard times make the strong, the strong make good times, good times make the weak, the weak make hard times ∞

Offline

#8 2016-12-09 07:39:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 79,185

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

w201 wrote:

If grub.cfg is not being used because it's "old and buggy", then what file is being used as a bootloader?

*Sigh*
Read over my comment again.

grub.cfg is "old" - it's a file you created somewhen in the past.
grub.cfg.new (see the ".new" suffix???) is the file created by your failing approach. Since it's expected to be buggy (because of the syntax errors) it's not used (because grub.cfg is. always.)

That's why showing us your grub.cfg is pointless - the file is perfectly ok, but not related to you failing updates.

Online

#9 2016-12-09 08:19:02

w201
Member
Registered: 2012-10-04
Posts: 289

Re: [SOLVED] Get Syntax Error When I Run grub-mkconfig

Seth, okay, I misunderstood you, but I get what you're saying now.

WFV wrote:

just edit grub so that section is:

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

save and reboot, just remember, next time you run

grub-mkconfig -o /boot/grub/grub.cfg

it will put the W10 thing back in as it is coming from /etc/grub.d/30_os_prober

Thank you! That solved the menu problem.

One more thing, as I was going over the config files again I had another look at 40_custom and spotted the culprit generating syntax errors:


#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

}

That curly braket at the end wasted two days of my life. Unreal. LOL

Offline

Board footer

Powered by FluxBB