20

I'm trying to update my grub config on ubuntu server 12.04.3 to include the GRUB_RECORDFAIL_TIMEOUT variable as described here: https://help.ubuntu.com/community/Grub2.

The procedure says run update-grub after making the change but it's doesn't appear to be on my system. How can I install this?

Braiam
  • 69,112

12 Answers12

39

The update-grub command was created to make things easier - it is simply a shell script in /usr/sbin/:

#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"

If it is not there, you can make your own. To do that, run this, and paste in the above script:

sudo nano /usr/sbin/update-grub

Save with Ctrl+O, and exit with Ctrl+X.

Then run these:

sudo chown root:root /usr/sbin/update-grub
sudo chmod 755 /usr/sbin/update-grub

And you should now be able to run update-grub. :-)

dskecse
  • 103
Wilf
  • 30,732
13

I would reinstall grub by running the following command:

sudo apt-get update; sudo apt-get install --reinstall grub
jhilmer
  • 1,213
3

you need to run it with root priviledges, run: sudo update-grub. Unless you removed it, its there in the system.

Bhavin Doshi
  • 2,496
2

If sudo update-grub doesn't work for you,

Try this

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

It will make grub entry for you.

1

This is supplemental to Sajith Sajan's answer:

Take a look in /usr/sbin and /boot. You may need to run:

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

instead.

1

If you get the following error:

$ sudo update-grub
sudo update-grub: command not found

That is caused by copying and pasting from the Ubuntu wiki not working. It turns the space into an invisible character. You have to manually type over the command to make it work.

0

For me, the issue was that I was the root user, at the time I attempted to run update-grub. When exit to my regular user account sudo update-grub works without error.

Lonnie Best
  • 2,244
0

In my case, I tried this answer to do sudo apt-get update, but I get lock held by packagekitd process error with pid, even reboot still same.

I use ps alxww --forest to confirm pid of packagekitd. Then sudo strace -f -s 100 -p <PID> to attach pid to strace to see what's going on.

The log shows 2 paths get downloading, one of them is '/var/lib/apt/lists/partial/tw.archive.ubuntu.com_ubuntu_dists_focal-updates_Contents-amd64.gz'.

Simply use sudo watch ls -lathi '/var/lib/apt/lists/partial/' to watch the progress until it's done. Now sudo apt update is working. sudo apt-get install --reinstall grub shows Package grub is not available. But try again with sudo update-grub, the command is come back.

林果皞
  • 596
0

It could be that the update-grub script exists in another directory (eg. /usr/sbin) but that directory (/usr/sbin) is not on your system path.

If this is the case, you could run the script by specifying the exact path, eg. /usr/sbin/update-grub. However, to avoid another "command not found" error for grub-mkconfig, a better option would be to add the missing directory to the system path like this:

export PATH=$PATH:/usr/sbin
update-grub

This will let your system look up the /usr/sbin directory for update-grub as well as other executables in that directory.

Hippo
  • 537
DrInk
  • 1
0

The update-grub command is now provided by the grub2-common package:

sudo apt-get install grub2-common
muru
  • 207,228
Prof
  • 101
0

You can also launch recovery os from advanced settings for ubuntu and from there an application will pop up and from there you can upgrade grubb

-1

I'm new to terminal and StackExchange, but I found a way around to **update-grub command not found **

:sudo apt-get update; sudo apt-get install --reinstall grub

I used the above command to reinstall GRUB, but it gave me

Package grub is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: grub2-common:i386 grub-efi-amd64:i386 grub2-common grub-pc grub-efi-ia32 grub-efi-amd64

So i tried to reinstall above packages with :sudo apt-get install --reinstall (ABOVE 6 PACKAGES) EX: :sudo apt-get install --reinstall grub2-common

Then I used :sudo update-grub to update it, and it worked displaying

Adding boot menu entry for UEFI Firmware Settings ... done

then i used the following

:sudo apt install grub-efi-amd64:

:sudo update-grub:

:sudo grub-install:

Reboot and use the following

:sudo update-grub:

ButterNut
  • 1
  • 1