How to edit or remove a grub menu entry while booted off a live usb

bootdual-bootgrub2shutdownuefi

I messed up and tried adding a grub menu entry to shutdown the computer using the "halt" command. I accidentally put the "halt" command outside the menu entry 'tags' and now the computer starts to boot and after post immediately shuts down again. From my understanding what is happening is grub is booting and running the script with my shutdown menu entry and just running the halt command as it is outside the menu entry tags. I have managed to boot the computer to a Ubuntu live USB and found what I thought was the script but after removing the command outside the tags and restarting the computer it shuts down like before. How can I edit or remove the menu entry while booted off the USB?

Best Answer

these are the steps:

  1. Boot from live usb (try ubuntu)
  2. Open a terminal and as root (sudo -s) mount the boot partition in /mnt
    example: "mount /dev/sdax /mnt".
  3. execute chroot /mnt
    When you do chroot now your / starts from what it was /mnt.
  4. edit your grub settings
    the suggested way to do this is by modifying /etc/default/grub
  5. execute update-grub
  6. reboot

Hope it is more clear now.

Again, good luck.