Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

grub2-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify…

  1. User

    grub2-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.

  2. Assistant

    This error message indicates that the grub2-install command cannot find the modinfo.sh file in the specified location. You can resolve this error by specifying the target or directory location using the --target or --directory option.

    For example, you can run the command "grub2-install --target=x86_64-efi /dev/sda" to install grub2 to the specified target. Alternatively, you can specify a directory location by running the command "grub2-install --directory=/usr/lib/grub/x86_64-efi /dev/sda".

    Make sure to replace /dev/sda with the correct device name for your system.

  3. User

    /run/media/liveuser/lazarus/boot/efi/EFI/

  4. Assistant

    I'm sorry, I'm not sure what you're trying to do or what you want me to do with that path. Can you please provide more context or information about your issue or question?

  5. User

    /run/media/liveuser/lazarus/boot/efi/EFI/ is the directory where the bootx64.efi is

  6. Assistant

    Thank you for clarifying. If you have grub2 installed and want to add a new entry to the boot menu that points to the bootx64.efi file in that directory, you can do the following:

    1. Open a terminal and run the command sudo nano /etc/grub.d/40_custom to create a new custom entry for your boot menu.

    2. Add the following lines to the file:

      menuentry "New Boot Entry" {
          insmod part_gpt
          insmod fat
          set root='(hd0,gpt1)'    # Change "hd0" and "gpt1" according to your system's partition scheme
          chainloader /EFI/bootx64.efi
      }
      
    3. Save the file and exit the editor by pressing Ctrl+X, then Y, then Enter.

    4. Run the command sudo update-grub to update the boot menu.

    This will add a new entry named "New Boot Entry" to your boot menu that points to the bootx64.efi file in the specified directory. Make sure to change the set root line according to your system's partition scheme.

  7. User

    when i run $ grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub i get grub2-install: error: /boot/efi/modinfo.sh doesn't exist. Please specify --target or --directory. how can i reinstall grub2

  8. Assistant

    If you're running into that error message, it's possible that your system is missing some necessary files for the grub2-install command. Here are a few things you can try to reinstall grub2:

    1. Make sure your system is booting in UEFI mode: When you run grub2-install, it expects to be installing a UEFI boot loader. Make sure that your system is set up to boot in UEFI mode and that you're running the command as the root user.

    2. Check that the efi-directory exists: Make sure that the directory /boot/efi actually exists on your system. If not, create it with the command mkdir -p /boot/efi. Then, you can run grub2-install again.

    3. Try specifying the target manually: If the above steps don't work, you can try specifying the target manually using the --target flag, like this:

      grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck
      

      The --recheck option tells grub to regenerate its configuration files, and can be helpful if your system has changed recently.

    4. Reinstall grub from a live CD: Finally, if none of the above suggestions work, you can try reinstalling grub2 from a live CD. Boot from a live CD or USB drive and then chroot into your local installation. From the chroot environment, install grub2:

      # mount your partition at /mnt
      mount /dev/sda1 /mnt
      
      # chroot into /mnt
      chroot /mnt
      
      # reinstall grub
      grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck
      
      # regenerate grub.cfg
      grub2-mkconfig -o /boot/grub2/grub.cfg
      
      # exit chroot
      exit
      

    These are just a few suggestions to try if you're having trouble reinstalling grub2. If none of these solutions work, please let me know and we can try some additional troubleshooting steps.

  9. User

    can you give me a checklist to maKE a new disk bootable after cloning boot efi and the linux partition

  10. Assistant

    Sure, here are the steps to make a cloned disk bootable in UEFI mode:

    1. Boot your computer from the original drive: You'll want to boot your computer from the original drive that you cloned, and then connect the new drive to your computer.

    2. Clone the partitions: You'll want to clone the boot/efi partition and the Linux partition(s) to the new drive. You can use a tool like dd, ddrescue, or clonezilla. Make sure that you clone the entire partition, and not just the files or folders inside the partition.

    3. Edit the /etc/fstab: Since we cloned the Linux partitions, their UUIDs may be different than the ones in the original installation. You'll need to edit the /etc/fstab on the new drive and update the UUIDs for the Linux partitions. You can get the UUIDs by running the command blkid.

    4. Reinstall grub2: You'll need to reinstall grub onto the new disk to make it bootable. Assuming that the new disk has the same partition layout as the old disk, you can use the following commands:

      # Mount the boot/efi partition of new disk
      mkdir /mnt/new-drive
      mount /dev/sdb1 /mnt/new-drive
      
      # Mount the boot/efi partition of the original disk
      mkdir /mnt/old-drive
      mount /dev/sda1 /mnt/old-drive
      
      # Copy the original EFI partition to the new disk
      cp -r /mnt/old-drive/EFI /mnt/new-drive/
      
      # Reinstall grub onto the new disk
      grub2-install --target=x86_64-efi --efi-directory=/mnt/new-drive/EFI --bootloader-id=GRUB --boot-directory=/mnt/new-drive/EFI/BOOT
      
      # Rebuild the grub config file
      grub2-mkconfig -o /mnt/new-drive/EFI/GRUB/grub.cfg
      

      Note that you'll need to replace /dev/sda1 and /dev/sdb1 above with the appropriate drive/partition designations on your system.

    5. Check your BIOS settings: Make sure that your computer is set to boot from the new drive in UEFI mode.

    That's it! If you completed all of the above steps successfully, you should now be able to boot from the cloned disk.