/bin/sh: 1: grub2-mkrescue: not found make: *** [Makefile:31: build/hello.iso] Error 127

NobinPegasus

New Member
Joined
Feb 4, 2022
Messages
13
Reaction score
0
Credits
101
I want to build a basic os on qemu.
But when I type make qemu
it gives the following error
Don't know how to solve

Code:
$make qemu
mkdir -p build/isofiles/boot/grub
cp build/kernel.bin build/isofiles/boot/kernel.bin
cp grub.cfg build/isofiles/boot/grub
grub2-mkrescue -o build/hello.iso build/isofiles #2> /dev/null
/bin/sh: 1: grub2-mkrescue: not found
make: *** [Makefile:31: build/hello.iso] Error 127
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,488
Reaction score
2,113
Credits
10,603
You simply need to install grub2-mkrescue.
I’m nowhere near my laptop atm, so I can’t look up the name of the package.

Off the top of my head, I think on Debian based distro’s - it’s provided by something like grub2-common. On other distros, the package name should be something similar.

You haven’t posted which distro you’re using, but perhaps look up grub-common in your package manager and see if it’s installed. If it’s not installed, you’ll need to install it.

If it is installed, but still does not work - then you’ll probably need to run make qemu as root.

So on my Debian laptop, to run the make commands as root, I’d use:
Bash:
sudo make qemu

If you’re running another distro, you might also use sudo, or depending on how your distro is set up, you might have to su to root before running the command.
 
OP
N

NobinPegasus

New Member
Joined
Feb 4, 2022
Messages
13
Reaction score
0
Credits
101
I'm using parrot OS.
I've already installed grub2-common, grub-common but it doesn't work.
I've grub-mkrescue installed but not grub2-mkrescue.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,488
Reaction score
2,113
Credits
10,603
Looking at the repos, the packages available and the man-pages - I think the older legacy version of grub is still available - as the grub-legacy package.
The default version of grub has been grub2 for a long time now.
Previously there were separate packages for all of the tools for grub and grub2.

All of the tools for grub V1 (grub legacy) used the grub prefix and the grub2 tools used the grub2 prefix.
Now all of the grub related tools that used to use the grub2 prefix e..g grub2-mkrescue appear to just use the grub prefix.

So the version of grub-mkrescue that you have installed IS the version for grub2. And I think it's been modified to work with grub-legacy, if grub-legacy is installed.

Which would mean that the tutorial you're following is perhaps a little out of date.

So I think that the actual solution to your problem is to either edit the makefile to use grub-mkrescue instead of grub2-mkrescue.
Or you could just create a symbolic link to grub-mkrescue called grub2-mkrescue.
e.g.
Bash:
sudo ln -sT /usr/bin/grub-mkrescue /usr/bin/grub2-mkrescue
That way any older makefiles that you have that use grub2-mkrescue will end up using grub-mkrescue via the sym-link.

Those are your options as I see it.

Additionally - it's worth noting that grub-mkrescue will silently fail if any of its optional dependencies are missing.
So for example, if you are trying to create a .iso rescue image - it will silently fail if you don't have GNU xorriso installed.
Also UEFI related operations will silently fail if the optional mtools package is not installed.

So I'd consider installing mtools and xorriso, if you don't already have them installed.
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top