Score:0

Problem updating Grub. I´ve removed GRUB files

vg flag

Last day I installed Ubuntu 20.04 LTS with dual boot (Windows). The grub didn´t recognize my windows boot so I updated grub and it was successful. However, I accidentally removed grub files yesterday. I´ve try using boot repair, but it didn´t was ok. Now, when I put sudo update-grub it is what I´ve:

Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
El guión «/boot/grub/grub.cfg.new» no contiene órdenes y no hará nada
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.

What I´m supposed to do? Sorry, I´m not so good on English. I hope it can be understood. Thanks.

What it´s in init-select.cfg is:

# Work around a bug in the obsolete init-select package which broke
# grub-mkconfig when init-select was removed but not purged.  This file does
# nothing and will be removed in a later release.
#
# See:
#   https://bugs.debian.org/858528
#   https://bugs.debian.org/863801

My grub.cfg.new:

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

Error reinstalling grub-common:

[sudo] contraseña para alejandro: 
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Leyendo la información de estado... Hecho
Los paquetes indicados a continuación se instalaron de forma automática y ya no son necesarios.
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi i965-va-driver
  intel-media-va-driver libaacs0 libaom3 libass9 libavcodec58 libavformat58
  libavutil56 libbdplus0 libblas3 libbluray2 libbs2b0 libchromaprint1
  libcodec2-1.0 libdav1d5 libflashrom1 libflite1 libftdi1-2 libgme0 libgsm1
  libgstreamer-plugins-bad1.0-0 libigdgmm12 liblilv-0-0 libllvm13 libmfx1
  libmysofa1 libnorm1 libopenmpt0 libpgm-5.3-0 libpostproc55 librabbitmq4
  librubberband2 libserd-0-0 libshine3 libsnappy1v5 libsord-0-0 libsratom-0-0
  libsrt1.4-gnutls libssh-gcrypt-4 libswresample3 libswscale5 libudfread0
  libva-drm2 libva-wayland2 libva-x11-2 libva2 libvdpau1 libvidstab1.1
  libx265-199 libxvidcore4 libzimg2 libzmq5 libzvbi-common libzvbi0
  mesa-va-drivers mesa-vdpau-drivers pocketsphinx-en-us va-driver-all
  vdpau-driver-all
Utilice «sudo apt autoremove» para eliminarlos.
0 actualizados, 0 nuevos se instalarán, 2 reinstalados, 0 para eliminar y 4 no actualizados.
Se necesita descargar 80,1 kB/2.268 kB de archivos.
Se utilizarán 0 B de espacio de disco adicional después de esta operación.
Des:1 http://es.archive.ubuntu.com/ubuntu jammy/main amd64 memtest86+ amd64 5.31b+dfsg-4 [80,1 kB]
Descargados 80,1 kB en 1s (79,9 kB/s) 
Preconfigurando paquetes ...
(Leyendo la base de datos ... 202811 ficheros o directorios instalados actualmen
te.)
Preparando para desempaquetar .../grub-common_2.06-2ubuntu7.1_amd64.deb ...
Desempaquetando grub-common (2.06-2ubuntu7.1) sobre (2.06-2ubuntu7.1) ...
Preparando para desempaquetar .../memtest86+_5.31b+dfsg-4_amd64.deb ...
Desempaquetando memtest86+ (5.31b+dfsg-4) sobre (5.31b+dfsg-4) ...
Configurando memtest86+ (5.31b+dfsg-4) ...
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
El guión «/boot/grub/grub.cfg.new» no contiene órdenes y no hará nada
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.
dpkg: error al procesar el paquete memtest86+ (--configure):
 el subproceso instalado paquete memtest86+ script post-installation devolvió el
 código de salida de error 1
Configurando grub-common (2.06-2ubuntu7.1) ...
update-rc.d: warning: start and stop actions are no longer supported; falling ba
ck to defaults
Procesando disparadores para man-db (2.10.2-1) ...
Se encontraron errores al procesar:
 memtest86+
E: Sub-process /usr/bin/dpkg returned an error code (1)
Pilot6 avatar
cn flag
You can boot from a LiveUSB and install grub from there. Also if you want to get an output in English run commands with `LANG=C` prefix, e.g. `LANG=C sudo update-grub`.
ale98sanchez avatar
vg flag
I´ve already done it. I used a LiveUSB with boot repair and it didn´t was ok.
uz flag
Jos
The error is in `/etc/default/grub.d/init-select.cfg`. So copy the contents of this file, and paste them into your question, formatting the text with the `{}` button.
uz flag
Jos
Please paste it into your queston, as I said.
uz flag
Jos
It looks like the `#` at the start of the first line is missing. Please enter a `#` there and try again.
ale98sanchez avatar
vg flag
I added it. No changes on the result.
uz flag
Jos
Is there an obvious error in `/boot/grub/grub.cfg.new` that you can spot?
ale98sanchez avatar
vg flag
I don´t know. Added it's content to the question.
ale98sanchez avatar
vg flag
There´s only a file inside my `/etc/default/grub.d` (`init-select.cfg`). Can be the problem? There whould be more files?
uz flag
Jos
Yes, you should have many more. On both of my systems there are `00_header, 05_debian_theme, 10_linux, 10_linux_zfs, 20_linux_xen, 20_memtest86+, 30_os-prober, 30_uefi-firmware, 40_custom, 41_custom, README`. You can probably copy these over from your LiveUSB.
ale98sanchez avatar
vg flag
Where are these files? I've insert the USB but I can´t find them.
ale98sanchez avatar
vg flag
I've run my LiveUSB and pressed the option "try Ubuntu". Once there, In the `/etc/default/grub.d` there is also only one file, the same as the previus comment. What whould I do to get these files?
uz flag
Jos
They are provided by the package `grub-common`. Try to reinstall this on your live system. Also reinstall `memtest86+` which provides `/etc/grub.d/20_memtest86+`.
ale98sanchez avatar
vg flag
It would be with the comand `sudo update grub-common`?
uz flag
Jos
Try `sudo apt install --reinstall grub-common memtest86+`.
ale98sanchez avatar
vg flag
It was an error. I put on the question
oldfred avatar
cn flag
The /boot/grub/grub.cfg.new is created when you have a typo in /etc/default/grub or in one of the scripts. I had one once in 40_custom and it said it was in last line. Actually in middle and was a missing } . If you cannot find typo, do a total reinstall of grub, that will erase any changes you made. You can do a total reinstall from Boot-Repair and its advanced mode or chroot into system and reinstall from there.
ale98sanchez avatar
vg flag
Thanks for answer.So I have to use Boot Repair (in LiveUSB) and click the other option (not the recommended one), is correct? What is a typo?
Score:0
vg flag

I´ve actually solved the problem. I´ve reinstall Ubuntu from my LiveUSB.

  1. Insert LiveUSB with Ubuntu.
  2. Install Ubuntu (other options in order not to damage Windows files)
  3. Select the partition where the root is installed (it´s the ext4 partition). In my case, I had a EFI partition (shared with Windows), a ext4 partition (where the root was), another ext4 partition (where /home was) and a swap partition. The rest of the partition were ntfs (Windows). So I only clicked on the first ext4 partition and selected edit.
  4. Left the size as it is, select the format option and mount it on /.
  5. I touch anything more and continue with the installation progress.
  6. I put the same name I had (read about it in other site, I don´t know wether it´s necesary).
  7. When the installation finished I reboot the PC and the both boot options, the Windows and the Ubuntu appeared on the GRUB menu.

I hope I had been clear enough with the answer.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.