12

I want to create a Bootable EFI USB to install Ubuntu & Windows 7 (maybe with utilities like PartedMagic). I did that using MultiSystem previously. However, I am using GPT and Windows install needs to be launched in EFI mode to install on GPT system. I suppose I must use GRUB EFI instead? If theres no app like MultiSystem that creates a GRUB EFI Bootable USB, how can I create one myself?

I suppose I will format my USB as GPT, and install GRUB EFI on it (how?). Then I need to configure GRUB EFI to load Ubuntu & Windows 7 install in EFI? How can I do these?

UPDATE

Here's what I tried

  • Create 2 partitions on my USB (GPT, 100+MB FAT32 (/dev/sdc1, set boot flag), The rest FAT32, /dev/sdc2, for installs)
  • Extract Windows 7 & Ubuntu 11.10 iso's into Installer partition, 2 different folders
  • Tried using sudo elilo -b /dev/sdc1 --autoconf --efiboot -v`

jiewmeng@JM:~$ sudo elilo -b /dev/sdc1 --autoconf --efiboot -v
elilo: backing up existing /etc/elilo.conf as /etc/elilo.conf-
Loaded efivars kernel module to enable use of efibootmgr
elilo: Checking filesystem on /dev/sdc1...
elilo: Mounting /dev/sdc1...
e    lilo: 44298KB needed, 78781KB free, 42192KB to reuse
elilo: Installing primary bootstrap /usr/lib/elilo/elilo.efi onto /dev/sdc1...
elilo: Installing /tmp/elilo.k8NWXX on /dev/sdc1...
elilo: Installing /vmlinuz on /dev/sdc1...
elilo: Installing /vmlinuz.old on /dev/sdc1...
elilo: Installing /initrd.img on /dev/sdc1...
elilo: Installing /initrd.img.old on /dev/sdc1...
elilo: Updating EFI boot-device variable...
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
elilo: An error occured while updating boot menu, we'll ignore it
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
elilo: Installation complete.

Did sudo modprobe efivars got no output but got the same error, I think its because I am not bootted into EFI Ubuntu?

Next, I'll try using USB Startup Disk Creator to boot into a live system in EFI mode to try again

UPDATE

I am so lost, is Windows installed 1st the fault? I formatted & made a bootable USB for Ubuntu Alternate with UNetBootIn, and it failed too with same error of no available kernel. If I made a Ubuntu Desktop I will get cannot configure apt sources

The syslog for ubuntu desktop install http://pastebin.com/CdbUPXax

I feel I better not waste time and revert back to MBR soon ... that will mean I have to somehow backup all my data 1st ... which is why I am delaying it to the last resort ... any ideas?

UPDATE

I tried booting Ubuntu 11.10 Alternate in BIOS mode (Non-EFI), installed fine except I cannot install a boot loader. It says fatal error. I then installed GRUB by booting the USB in recovery mode. Works but it does not boot. Gives a blank screen on boot. If I try to enter recovery mode (on HDD, where ubuntu is installed), keyboard seems to fail, mouse have light though.

3
  • Have you looked into this? unetbootin.sourceforge.net
    – Dustin L.
    Jan 7, 2012 at 5:17
  • Easy2Boot may be what you want.
    – SteveSi
    Apr 21, 2014 at 16:55
  • Answers are best when they're more than just a a link or reference to some potential solution. Answers that show how to do something or at the very least describe the general approach are what we're after here.
    – slm
    Apr 21, 2014 at 17:16

5 Answers 5

8
+100

I'm working on an update to this question/answer.
This doesn't work without errors, but as I worked with @jiewmeng I uncovered that the goal was to use a USB to install both Windows and Ubuntu onto one hard drive, UEFI.
It has taken a while and I've found the solution but we need to clean the question and answer.
Maybe the original question can be answered as well but since the goal was more on the install side the single boot UEFI USB seemed less important.
I'm presently using two USB sticks one for Windows, one for Ubuntu.
This is a WIP to be updated ASAP

I've been working on this for a few days, spare hour here and there and finally have a single USB, that will boot and offer installation of windows 7 and ubuntu.
My config is 64 bit specific, you could try and change to accomodate a 32bit intall but there are many differences in filenames. Please follow up if you need 32bit. That said...

You cannot install Windows 7 from a GPT formatted USB.
You can use gdisk, or parted, and create a GPT USB, which will boot via UEFI.
You'll be able to configure the UEFI boot manager to load the Windows installer from the USB but the installer will search for files and data needed to perform the installation and it won't recognize the GPT USB, while it will find an MBR USB.

However, this is of little consequence as UEFI looks at the MBR/GPT and the EFI partition, see the Wikipedia entry on UEFI Booting

In spite of using a std MBR for the USB, one can install via UEFI to a GPT disk.

The following worked using 64bit installs, on 64bit UEFI Asus Sabertooth.
The firmware on each motherboard is very specific and each motherboard UEFI firmware searches for UEFI boot differently. You may have issues with your motherboard finding boot data, but the following works on my ASUS.

Here's how I made a bootable USB with an installable copy of the Windows 7 64bit DVD and an Ubuntu ISO (in this example, the 11.10 64bit desktop iso).

Using an 16G USB, which is all I had at hand...
my USB installed as /dev/sdc, change the relevant references to the appropriate device for your USB.
Make sure you have 7zip installed.

fdisk /dev/sdc
create new MBR, 'o' command
create new partition, part 1, size 8G, type ef, set bootable, write
mkfs.vfat -F32 /dev/sdc1
mkdir /mnt/USB
mount /dev/sdc1 /mnt/USB
insert Windows 7 x64 DVD, again, mine appeared as /media/UDF\ Volume, you need to change references below
# Extract/Copy the entire Windows DVD to the USB
cp -r /media/UDF\ Volume/* /mnt/USB
# I don't know what effect the following rename has, I copied blindly from another webpage.
mv /mnt/USB/sources/ei.cfg /mnt/USB/sources/ei.cfg_
cd /mnt/USB/efi/microsoft/boot/
7z e /mnt/USB/sources/install.wim 1/Windows/Boot/EFI/bootmgfw.efi
cp -r /mnt/USB/efi/microsoft/boot /mnt/USB/efi/
mv /mnt/USB/efi/boot/bootmgfw.efi /mnt/USB/efi/boot/bootx64.efi
# At this point I booted the USB, and installed Windows 7 to a GPT SSD
# Upon reboot I noticed the Windows Boot loader in my UEFI boot list (actually it made itself 1st).
# so, here we have a standalone Windows7 UEFI installer that will function correctly (64bit ASUS, at least).
# Now, on to adding Ubuntu
cd /mnt/USB
7z x /path2iso/ubuntu-11.10-desktop-amd64.iso
# If 7z finds prexisting files with the same name, just allow always overwrite
# (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? A

# At this point I booted the USB, and installed Ubuntu x64 to a GPT SSD
# we have a standalone Ubuntu 64bit installer that install Ubuntu 64

# Now, on to add a boot manager that will allow us to select between Windows 7 and Ubuntu

# Get the target UUID of the USB partition, using either blkid or the following command
grub-probe --target=fs_uuid /mnt/USB/efi/Microsoft/Boot/bootmgfw.efi  
will print YOUR_UUID # Substitute into the following references to YOUR_UUID

# Append the following menuentry to /mnt/USB/boot/grub/x86_64-efi/grub.cfg

menuentry "Microsoft Windows x86_64 UEFI-GPT Setup" {
    insmod usbms  
    insmod part_gpt  
    insmod part_msdos  
    insmod fat  
    insmod search_fs_uuid  
    insmod chain  
    search --fs-uuid --no-floppy --set=root YOUR_UUID # <- CHANGE THIS TO YOUR UUID
    chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi  
}

And voila! A working USB stick that uses grub as boot manager, allowing installation to GPT disks with UEFI install.

If you have an errors, don't hesitate to msg me, and I'll look into it.

18
  • I successfully boot into windows installer at the point "At this point I booted the USB, and installed Windows 7". However when trying grub-probe --target=fs_uuid /media/INSTALLS_/efi/microsoft/boot/bootmgfw.efi 4983-DA78 I get "Unknown extra argument `4983-DA78'."
    – Jiew Meng
    Jan 12, 2012 at 1:53
  • Running grub-probe provides the uuid to be used. It is then to be substituted in the following text.
    – bsd
    Jan 12, 2012 at 2:46
  • the command is only grub-probe --target=fs_uuid /media/INSTALLS_/efi/microsoft/boot/bootmgfw.efi No args. The value '4983-DA78' is your UUID being returned by grub-probe, for you to use in the following text as YOUR_UUID
    – bsd
    Jan 12, 2012 at 10:35
  • installed windows fine but when i tried ubuntu it says no kernel, any ideas?
    – Jiew Meng
    Jan 15, 2012 at 8:38
  • Did you install Ubuntu onto a machine that already had Windows 7 installed via the UEFI USB stick?
    – bsd
    Jan 15, 2012 at 12:02
3

I will do my best to answer the question, hopefully I'll get you in the right direction.

As you already know, Win7 x64 installation from GPT is only possible from EFI. Even worse your prevented from using any hybrid, as Win7 x64 treats any hybrid disk as legacy MBR. So you have to relabel/repartition your USB as GPT. This type of setup is not preferable for a USB, considering portability concerns. I'm not saying don't make one, I just wouldn't expect any automated tool to exist. I actually believe you might be able to use multisystem, after you format your drive. If the auto installed Grub2 lacks EFI/GPT support, overwrite it with the correct version of Grub2.

So I would assume you might have to do some of the install manually, which in its entirety, is beyond the scope of this answer. Although I should be able to get you started....

Using a current release of parted, relabel your drive with GPT. Assuming the disk is located at /dev/sdc,

 parted -s /dev/sdc mklabel gpt

Now you must partition the drive, preferably a USB should be a single primary. I always go with FAT32, for my bootable USB's.

parted -s /dev/sdc mkpart primary fat32 0 -1

parted mkpart does not create the FS, like mkpartfs would. The parted DOC recommends using the proper mkfs, as opposed to parted's built in support.

mkfs.vfat /dev/sdc1

Your drive is now ready, to handle the data. At this point I'm hoping you could use the multisystem, to set up your drive.

Once your done with all that... We need to setup Grub2, obviously we intend to keep the config. Multisystem might have the ability to boot from EFI, but your going to have to mess with the module config regardless.

The Grub2 configuration is located at, boot/grub/grub.cfg. You should see some of the modules commented out. I've seen one relating to GPT, but not sure about EFI. I would look and do some testing, Consider reading some of the Grub2 docs.

If you still have any problems, comment back with follow-up questions.

2

Start with bdowning's answer above, then continue here to add Parted Magic.

There are a couple of ways to go about this, but the simplest is to copy the pmagic directory from the Parted Magic ISO to the root of your usb disk, and then add a menu entry for it:

menuentry "Parted Magic" --class gnu-linux --class gnu --class os {
  linux /pmagic/bzImage
  initrd /pmagic/initrd.img
}

(You may need to read the grub2 manual to get it completely working; I used grub1 when I did this the other day, and the configuration files are different.)

The downside here is that you're mixing files for Windows, Ubuntu and now Parted Magic into a single filesystem. Worse, we've put them directly into the EFI system partition. It works, but of course it might not work for every combination of operating systems so what we really ought to do is make a separate partition on the drive for each OS. Doing that requires telling grub to search for the right filesystem, which it can do by guid. Every filesystem gets a unique guid when it is created, so you'll have to use grub-probe (or similiar tools) to find that guid. You then stick it into a search command in your grub config:

menuentry "Parted Magic" --class gnu-linux --class gnu --class os {
    search --no-floppy --fs-uuid --set 8d2acb74-5216-4696-90a8-c76f92d5e4ee
    linux /pmagic/bzImage
    initrd /pmagic/initrd.img
}

Hope this helps.

1
  • The multiboot will work, but in bdowning's answer, when I try installing Ubuntu, I get Kernel not available (alternate) or cannot configure apt (desktop) errors (see bdowning's post & comments), any ideas how that can be fixed? We also chat @ chat.stackexchange.com/rooms/info/2240/…
    – Jiew Meng
    Jan 22, 2012 at 7:10
2

In Non-UEFI machines, we can use GRUB2 to make USB stick bootable. Then, we can use 'ntldr' command in the GRUB2 to boot Windows from USB.

menuentry 'Install Windows 8' {
 ntldr /bootmgr
}

See complete answer at my blog Creating a bootable windows USB from Linux

1
  • 1
    While this link may answer the question, it is better to include a more detailed description of the answer here and provide the link for reference.  Link-only answers can become nearly useless if your link goes down. Apr 10, 2015 at 19:07
1

Why bother with GRUB2? It just complicates things. Just use the EFI STUB method of booting Linux kernel from the ESP by adding a UEFI Shell into the ESP.

1
  • Nice to know. In my specific case (old macbook pro) it doesn't work, because the Apple renamed this proprietary crap to "EFI" and says that his bootloader is an EFI. But in fact, it is an undocumented, buggy, custom bootloader capable to boot only osx and windows. Thus, I installed LILO into one of the partitions and lie to this bootloader that it is a windows. So it works. So, "EFI" boots LILO in BIOS emulation mode, and LILO boots the kernel.
    – peterh
    Jan 30, 2018 at 6:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .