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?

12 Answers 12

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. :-)

6
  • 1
    Thanks, since it was missing I reinstalled grub. Not sure if anything else might of went missing. Commented Feb 9, 2014 at 19:42
  • 3
    This is a lifesaver if reinstalling grub is not an option because of a broken system.
    – plok
    Commented May 5, 2015 at 11:00
  • Yes, really, lifesaver. The update-grub command was on my system, but gave me a /cow error, this one gave no error output.
    – Quidam
    Commented May 2, 2020 at 8:24
  • Do you know how to regenerate grub.cfg from a live session?
    – Quidam
    Commented May 2, 2020 at 8:25
  • @Quidam askubuntu.com/q/145241/178596. Also tools such as Boot Repair AFAIK can do it sort of. Recovery Mode if you can access that is also an option (Dropping to a root shell prompt which can run commands after mounting partitons)
    – Wilf
    Commented May 2, 2020 at 9:37
13

I would reinstall grub by running the following command:

sudo apt-get update; sudo apt-get install --reinstall grub
4
  • 2
    i lost update-grub after a do-release-upgrade. This worked for me. Commented May 14, 2017 at 20:07
  • 7
    I also did do_release_upgrade but don't know if I lost it after that. if I run the above command, this is what I get: 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
    – nurp
    Commented Sep 25, 2018 at 9:32
  • Saved my life thrice, only solution that worked in chroot for me
    – testing_22
    Commented Oct 25, 2021 at 19:15
  • For me, it was: sudo apt-get update && sudo apt-get install --reinstall grub2-common
    – GDP2
    Commented Jan 31 at 20:41
3

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

2
  • 2
    It was definitely gone, not sure how it went missing. Re-install grub brought it back. Commented Feb 9, 2014 at 19:43
  • It is NOT there on some Linux releases such as Fedora 31. Granted the question specifies Ubuntu but your answer could cover other releases using Grub. Commented Sep 4, 2022 at 9:14
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.

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.

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.

0

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

sudo apt-get install grub2-common
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:

1
  • POP OS is off-topic at this site.
    – Pilot6
    Commented Apr 30, 2022 at 11:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.