GRUB : Grand Unified Boot Loader


 /usr/sbin/update-initramfs -u


sudo grep 'menuentry ' $GRUB_CONFIG | cut -f 2 -d "'" | nl -v 0
sudo grub-reboot $index # wont work
sudo grub-reboot $name # will raise warning
sudo grub-set-default  0
sudo grub-reboot   'Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 4.9.0-9-amd64'
sudo update-grub
sudo reboot


grub screw syslinux or is it gag ?

"Welcome to GRUB!"

mv /etc/default/grub /etc/default/grub.orig

sudo os-prober 
/dev/sda2:Microsoft Windows XP Professional:Windows:chain
cat<<EOF > /root/
#! /bin/sh

#TODO: update that one ie 0=l 1=r 2=w

sudo grub-reboot $MENU_ENTRY 
echo "About to reboot : Press control+C to cancel"
sleep 10
sudo reboot 



GRUB loading.
error: no such disk
grub rescue> set
grub rescue> ls
(hd0) (hd0,6) (hd0,5)
grub rescue> ls (hd0,5)/
error: unknown filesystem
grub rescue> ls (hd0,6)/
./ ../ lost+found/ boot/
grub rescue> set prefix=(hd0,6)/boot/grub
grub rescue> insmod sh
rescue:grub> ls (hd0,6)/boot
./ ../ vmcoreinfo-2.6.31-20-generic initrd.img-2.6.31-20-generic
vmlinuz-2.6.31-20-generic config-2.6.31-20-generic grub/ memtest86+.bin abi-2.6.31-20-generic
rescue:grub> set root=hd0,6
rescue:grub> insmod linux
rescue:grub> linux /boot/vmlinuz-2.6.31-20-generic root=/dev/sda6 quiet
   [Linux-bzImage, setup=0x3400, size=0x3c400]
rescue:grub> initrd /boot/initrd.img-2.6.31-20-generic
   [Initrd, addr=0x177fb000, size=0x83874e]
rescue:grub> boot


error: no such partition.


cat /etc/grub.d/90_sda7 
exec tail -n +3 $0

menuentry "sda7" {
        set root=(hd0,msdos6)
#       search --no-floppy --fs-uuid --set 147e39c87e39a400
        chainloader +1


Did not work from me :

root@nrv:/home/rzr# cat /etc/grub.d/WXHOEM_FR
#! /bin/sh
exec tail -n +3 $0
# 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.

menuentry "Windows XP installer" {
insmod part_msdos 
insmod ntfs 
insmod ntldr 
insmod fat
set root='(hd0,msdos1)'
search -f /i386/setupldr.bin -s root 
ntldr /i386/setupldr.bin


lts ubuntu 18

root@kubuntu:/mnt/tmp# echo 'GRUB_ENABLE_CRYPTODISK=y' >> /etc/default/grub
root@kubuntu:/mnt/tmp# grub-install --recheck --root-directory=/mnt/tmp/ /dev/sdb
Installing for i386-pc platform.

dev/ mising sd?


"Welcome to Grub"



df: Warning: cannot read table of mounted file systems: No such file or directory

"error: no such device"

sudo grub-install $disk

Error : "error: no such partition"

Context: Disk was installed on SatA and then relocated to UsB :

grub rescue> ls 
(hd0) (hd0,msdos5) ...


Possible fix, I installed DebiaN-9 to 1st part (800M < 1GB, DebiaN-10 did not fit in) disk is attached as USB.

Grub boots fine from UsB now:

fdisk -l 
Partition 4 does not start on physical sector boundary


Error 2 : Not found or not a block device.

root@nrv:/# grub-install  /dev/sda10
Could not find device for /boot: Not found or not a block device.
tar cvfz /root/grub.tar.gz /boot/grub
sudo aptitude reinstall grub
grub-install --recheck /dev/sda10
grub --batch
find /boot/grub/stage1
root (hd1,9)
#  Filesystem type is ext2fs, partition type 0x83
setup (hd1,9)
# Checking if "/boot/grub/stage1" exists... no
# Checking if "/grub/stage1" exists... no
# Error 2: Bad file or directory type

 /mnt/parent/usr/sbin/grub --version
grub (GNU GRUB 0.97)

grub> setup (hd1,9)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1,9)"... failed (this is not fatal)
 Running "embed /boot/grub/e2fs_stage1_5 (hd1,9)"... failed (this is not fatal)
 Running "install /boot/grub/stage1 (hd1,9) /boot/grub/stage2 p /boot/grub/menu.lst "... succeeded

grub : Error 15 : File not found

grub> find /boot/grub/menu.lst
find /boot/grub/menu.lst
grub> root (hd1,0)
root (hd1,0)
grub> setup (hd1,0)
setup (hd1,0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... no

Error 15: File not found
find /boot/grub/

also check for

grub-install --recheck /dev/sda1

error : "failed to get canonical path of" "devtmpfs"

Failed on deb install,



parted show no parts while /proc/partitions is there

chroot to install testdisk to recreate the partition table

grub : error ...

External Disk : USB

fdisk -l /dev/sdb
| Disk /dev/sdb: 250 GB, 250056737280 bytes
| 255 heads, 63 sectors/track, 30401 cylinders
| Units = cylinders of 16065 * 512 = 8225280 bytes
| Device Boot      Start         End      Blocks   Id  System 
| /dev/sdb1               1         130     1044193   82  Linux swap
mkfs.ext3  /dev/sdb1 
mount /mnt/sdb1 
cp -rfa /boot /mnt/sdb1/
grep root /mnt/sdb1/boot/grub/menu.lst
| root            (hd0,0)
cat  /mnt/sdb1/boot/grub/
| (hd0)   /dev/sdb
| (hd1)   /dev/hda
grub-install /dev/sdb --root-directory=/mnt/sdb1/

error: "invalid magic number" grub

sudo $(which grub-install) --version
/usr/sbin/grub-install (GRUB) 2.04-1ubuntu12.1

External Disk : SD (/dev/mmcblk0)

"GRUB" black screen

error: invalid arch-independent ELF magic"

error: fd1 cannot get C/H/S values on every boot

On PentiuM with grub-pc-bin (2.02+dfsg1-20+deb10u2) ?


sudo apt-get remove --purge grub 
mv /boot/grub /boot/grub.mine
sudo apt-get install grub 
grub-install /dev/sda

au boot presser 'c' :

title Windows XP
rootnoverify (hd0,0)
chainloader  +1

evidemment, faut adapter le hd0,0

chroot: cannot run command `/bin/bash': Permission denied

remount with exec param

sudo grub-install /dev/sda
/dev/sda: Not found or not a block device.

Copy /dev/* with mc

mknod  /dev/sda b 8 0
mknod  /dev/sda2 b 8 2
sudo grub-install /dev/sda
/dev/sda does not have any corresponding BIOS drive.
# cat /boot/grub/
(hd0)   /dev/hda
(hd1)   /dev/sda
# EOF file:///boot/grub/
LANG=C grub-install /dev/sda
/sbin/grub-install: line 485: /dev/null: Permission denied
# mount --bind /dev /mnt/sda8/dev && chroot /mnt/sda8
# yaird error: can't open directory /sys/block (fatal)
mount --bind /sys /mnt/sda8/sys

Errors :

Error 22: No such Partition

The file /boot/grub/stage1 is not read correctly.

error : grub : stage1

sudo grub-install /dev/sda
# Searching for GRUB installation directory ... found: /boot/grub
# The file /boot/grub/stage1 not read correctly.

fdisk /dev/sda << EOF t 1 83 w

error : grub : stage2

grub-install  /dev/sda
Searching for GRUB installation directory ... found: /boot/grub
The file /boot/grub/stage2 not read correctly.

Happened while :

cd  /mnt/sda8 
mount | grep $(pwd)
mount --bind /dev ./dev
mount --bind /proc ./proc
chroot .
grub-install  /dev/sda

Solution :

sudo update-grub 

Did not help

This happed when I used chroot :

grub --batch
root (hd1,7)
setup (hd1,7)

Error 15

Happended after i deleted /boot/grub and installed , plus update-grub

I missed install-grub

Solution: boot on other medium …

GRUB loading : Error 18

GRUB loading : Error 17 : Cannot mount selected partition


Probing devices to guess BIOS drives. This may take a long time.

Error 21 : remove grub

Grub Loading Stage 1.5 Grub Loading please wait…. Error 21

$ ms-sys -m /dev/sda
Windows 2000/XP/2003 master boot record successfully written to /dev/sda


$ install-grub /dev/sdaX  
$ mkfs.vfat -nv sdaX


  fdisk -l /dev/sda   Disk /dev/sda: 250.0 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x12345678   Device Boot Start End Blocks Id System /dev/sda1 1 130 1044193+ 82 Linux swap / Solaris /dev/sda2 1175 30401 234765877+ 5 Extended /dev/sda3 131 652 4192965 b W95 FAT32 /dev/sda4 653 1174 4192965 83 Linux /dev/sda5 1175 28707 221158791 83 Linux /dev/sda6 30272 30401 1044193+ 82 Linux swap / Solaris /dev/sda7 28708 29229 4192933+ b W95 FAT32 /dev/sda8 * 29230 30271 8369833+ 83 Linux   Partition table entries are not in disk order   cat /boot/grub/ # file:///boot/grub/ (hd0) /dev/hda (hd1) /dev/sda grub --batch root (hd1,7) setup (hd1,7)

ToDo : test


This appends w/ Kernel 2.6.14 :

Busybox Alert /dev/hda5 does not exist! Dropping into a shell....

grep ROOT /etc/mkinitrd/mkinitrd.conf
# grub-install  /dev/hda
The file /boot/grub/stage1 not read correctly.



@TaG: Boot loader chroot lilo MBR ntldr gag install

<iframe width="420" height="315" src="//" frameborder="0" allowfullscreen></iframe>


grub.txt · Last modified: 2020/09/08 20:43 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki