10

I placed a entry like this in grub4dos,

rootnoverify (hd1)
chainloader +1
boot

But sometimes when I plug in my USB key too late, grub will not detect this usb key, is there anyway to let grub re-scan disk list?

I need to know for both grub0.9X and grub1.9X

daisy
  • 54,555

5 Answers5

17

Run the following command as root:

update-grub

EDIT: This is an Ubuntu specific command. To do this on another distribution, just run grub-mkconfig -o /boot/grub/grub.cfg

2nd EDIT: os-prober is required for that to work (automatically detect operating systems and add menu entries for them).

FSMaxB
  • 301
  • 1
  • 10
2

Grub does not provide an explicit command to rescan drives, but the drives will be rescanned if the computer is rebooted from within grub. To do this:

  • At the grub menu, press c to drop to the grub console
  • Type reboot and hit enter
  • Computer will reboot
  • Grub will be reloaded and the drives will be rescanned
bain
  • 214
1

From what I've seen, I don't believe this is possible. I was in a similar situation where I setup a GRUB entry to boot from a USB. If I didn't have a USB stick in before startup, the boot option fails. If I boot with the USB stick already connected, the option would boot from the USB.

Using GRUB 0.97, I've scanned the manual and tried many commands but I didn't see anything related to re-initializing the disks.

I see many hints in the manual that GRUB relies on the BIOS (if not entirely). When playing with boot options from the BIOS, it's in the same situation where if I don't have the USB stick plugged in before BIOS starts, it will never be listed as a bootable option (using AMI, Aptio). Maybe this is a BIOS limitation, a limitation of both or I could just strayed on a tangent.

I thought this was going to be an issue for me, but then I wondered what was easier: having someone toggle to the GRUB command mode and reinitialize disks or just CTRL-ALT-DEL'ing...

jdknight
  • 145
1

Hi guys I was having this a issue where i installed red hat enterprise linux and grub would not give me the option to dual boot. It only had linux as a option but not my windows os. i couldn't figure it out for a while until it hit me like a ton of bricks lol. I think God was helping me out. All you have to do is run the "os-prober" command on the terminal if you have red hat or centos. IF THIS DOES NOT WORK!? Its because your system is unable to read "ntfs" partitions, which are windows partitions. So to fix this install the package "ntfs-3g". The command will look like this: For Red Hat and Centos

$ sudo yum install ntfs-3g

   or

For Debian based or Ubuntu

$ sudo apt-get install ntfs-3g

Once its installed you can immediately run os-prober and it should work perfect. Reboot your system and you should have a choose on the grub2 menu of booting linux or windows or whatever other os you have. I hope this helps someone other there. And i hope i explained it right.

Sorry I forgot one more thing before you reboot run this as root user.

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

This command will generate a new grub.cfg file and rescan the disks and partitions. Then you can reboot the pc.

  • I used
          grub-mkconfig -o /boot/grub/grub.cfg 
    
    

    on Ubuntu 20.04.2 LTS after adding another SDD to my PC that didn't show up on initial boot after install.

    – VikingGlen Jun 21 '21 at 18:03
-1

yes; reboot.mod in grub ==ctrl-alt-del in common PC's.

The reason why a "late plugin usbstick" not recognised is due to hotplug concept! Since grub is at very early boot no driver for hotplug could be available.

A very simple experiment to illustrate:

  1. get 2 usbsticks with at least one with grub bootable
  2. start the pc with the bootable stick
  3. on grub's menu, type c to get into grub console
  4. grub>ls to display all drives seen by grub
  5. Plugin the 2nd stick
  6. grub>ls will see no change
  7. grub>reboot, then
  8. grub>ls will see the 2 sticks

Even in the future, hotplug will never exist in grub.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
wangji
  • 1