Grubで構文エラーを修正する方法は?

Grubで構文エラーを修正する方法は?

Grub設定を更新したいです。

次のメッセージを受け取りました。

# 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 10 on /dev/sda1
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 178
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.

ここは過去のごみ箱です。/boot/grub/grub.cfg.new

その中のファイルを見ようとしましたが、/etc/grub.d/*デバッグに失敗しました。

ベストアンサー1

今後のデバッグを支援するために、私が犯したエラーの検索を記録しました。

問題は178行目です。

### 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.
 
 
 
if [ "${grub_platform}" == "pc" ]; then
fi                                            #<------that is line 178
### END /etc/grub.d/40_custom ###

だから明らかに問題があるのです40_custom

これらの文書については、次のように述べています。

GRUBの専門家ではなく、変更の効果を理解していない限り、これらのファイルを変更しないでください。それでも、必ず元のジョブgrub.cfgファイルのバックアップコピーを保持してください。特定のファイル 40_custom および 41_custom は、GRUB 構成のユーザー変更を生成するために使用されます。これらのファイルに対する変更の結果を理解し、元のgrub.cfgファイルのバックアップを維持する必要があります。

したがって、これはおそらくこのファイルに追加したものです。

経験豊富なシェルスクリプターであれば、これに気づいたでしょう。

if [ "${grub_platform}" == "pc" ]; then 
    :
fi

構文エラーを修正します。私はあなたの意図が何であるかわからないので、「構文」エラーを明示的に指摘しました。

/etc/grub.d/40_customではなく(編集中のファイル)でこの設定を変更しますが、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
#

おすすめ記事