How to boot to efi USB stick from Grub command line

11,173

Boot ISO File on USB from grub

You can boot an ISO on USB by using your desktop grub to loop mount it. Add the following menuentry, (or similar), to /etc/grub.d/40_custom:

menuentry "Ubuntu-18.04.1-desktop-amd64.iso" {
    set root=(hdx,1)
        loopback loop /Ubuntu-18.04.1-desktop-amd64.iso
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/Ubuntu-18.04.1-desktop-amd64.iso splash --
        initrd (loop)/casper/initrd.lz
    }

Were x is the USB drive number.

Then in Terminal run:

sudo update-grub

You can add a ext4 persistent partition labeled casper-rw if you want persistence, then add a space and the word "persistent" to grub.cfg after "splash --"

Boot Full Install USB from Desktop grub

You can also boot a Full install USB using your desktop's grub.

Copy your preferred menuentry from your USB's grub.cfg to /etc/grub.d/40_custom on your internal drive.

Then in Terminal run:

sudo update-grub
Share:
11,173

Related videos on Youtube

Joeytje50
Author by

Joeytje50

I am a Master student in Computer Science and hobbyist web developer, experienced in html css3 js regex and a beginner in svg php python c++. I like to think outside the box to find alternative uses for existing features, such as with my CSS3 mineturtle, or with this supposedly impossible question. I came up with CSS3 :checked-based tab menus independently in 2011 (back when IE8 was still by far the most used browser). A personal dislike of mine is jQuery UI's default styling being used so often without being customised. The visited item on your own userprofile that shows the dates you logged in, for example, just doesn't blend in with the other styles at all. </rant>

Updated on September 18, 2022

Comments

  • Joeytje50
    Joeytje50 over 1 year

    I am trying to boot to an USB stick from Grub, and I have found a few sites that explain how to do it, but when I follow those instructions it does not seem to work. I think those guides may simply be outdated. I did find https://askubuntu.com/a/436735, but that one seems to cover only how to add an entry to grub when it already has a working system running on it.

    https://blog.viktorpetersson.com/2014/07/29/how-to-boot-from-usb-with-grub2.html tells me to run the following from the grub shell:

    grub> linux (hd1,msdos1)/install/vmlinuz root=/dev/sdb1
    grub> initrd (hd1,msdos1)/install/initrd.gz
    grub> boot
    

    But the stick only contains /efi/boot/bootx64.efi and /efi/boot/grubx64.efi. I found this by setting set root=(hd1,msdos2) (which is the usb stick) and then tabbing through on find /. So my question is: how can I make grub boot from this USB stick?

    PS: on this computer, booting to usb from the BIOS does not seem to work.

    • oldfred
      oldfred about 5 years
      UEFI or BIOS. And once you start booting in one mode, you cannot change, or grub only can boot other systems installed in same boot mode. And is USB flash drive a full install or a live installer. Full install has files as links to specific kernel in / so your instructions above will boot install. But live installer does not. Grub in live installer is for UEFI boot, and live installer uses syslinux for BIOS boot. Some more info: help.ubuntu.com/community/Installation/…
    • sudodus
      sudodus about 5 years
    • Meninx - メネンックス
      Meninx - メネンックス about 5 years
      I have been testing the answer below for about a week without problem. If you want to boot Full install USB from the internal grub, I can edit my answer.
  • Joeytje50
    Joeytje50 about 5 years
    Apologies for the late reply. Would this solution be possible at all if my existing installation is broken and does not boot from GRUB? Is there any way to do this from just the GRUB command line?
  • Meninx - メネンックス
    Meninx - メネンックス about 5 years
    @Joeytje50 : You can edit grub.cfg directly adding the menu entry above. I'm not sure it will work any better than the USB grub, but it is easy to try.