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.
There is an example to install debian from a Linux-mint live USB (or any debian based distro). If you have a debian based distribution already installed on your hdd , you can install other debian based distro using chroot
and debootstrap
from the existing OS.
Boot from the live USB .Use gparted to create your root
, swap
,/home
... partitions.
If you prefer the command line ( fdisk
, parted ..) , there is how to activate the swap partition :
mkswap /dev/sdaY
sync
swapon /dev/sdaY
Let's say you need to install debian stretch .
Install the debootstrap
package :
sudo apt-get install debootstrap
Create the /mnt/stable
then mount your root partition (sdaX
)
sudo mkdir /mnt/stable
sudo mount /dev/sdaX /mnt/stable
Install the base system:
sudo debootstrap --arch amd64 stretch /mnt/stable http://ftp.fr.debian.org/debian
sudo mount -t proc none /mnt/stable/proc
sudo mount -o bind /dev /mnt/stable/dev
sudo chroot /mnt/stable /bin/bash
Set up your root password:
passwd
Add a new user:
adduser your-username
Set up the hostname :
echo your_hostname > /etc/hostname
Configure the /etc/fstab
:
add the following lines:
/dev/sdaX / ext4 defaults 0 1
/dev/sdaY none swap sw 0 0
proc /proc proc defaults 0 0
use the debian documentation to edit your sources.list
(replace jessie
by stretch
)
Configure locale :
apt-get install locales
dpkg-reconfigure locales
Configure you keyboard:
apt-get install console-data
dpkg-reconfigure console-data
Install the kernel:
apt-cache search linux-image
Then:
apt-get install linux-image-4.9.0-3-amd64
Configure the network:
editor /etc/network/interfaces
and past the following:
auto lo
iface lo inet loopback
allow-hotplug eth0 # replace eth0 with your interface
iface eth0 inet dhcp
allow-hotplug wlan0 # replace wlan0 with your interface
iface wlan0 inet dhcp
To manage the wifi network install the following packages:
apt-get install net-tools network-manager wireless-tools
Install grub :
apt-get install grub2
grub-install /dev/sda
update-grub
You can install a desktop environment through the command tasksel
:
apt-get install aptitude tasksel
Run the following command and install your favorite GUI:
tasksel
Finally exit the chroot and reboot your system
Documentation: D.3. Installing Debian GNU/Linux from a Unix/Linux System
Debian wiki:
Best Answer
I did it like this:
Or to choose current Ubuntu Natty and amd64 architecture:
On an old Thinkpad R40 the bios USB boot support was not that great - the bios wanted a mbr, thus I created the USB stick like this:
Note that this method uses the text-based network installer.
Of course, you have to adjust the USB device name (
/dev/sdc
above), the Distribution name (Karmic is not 11.04) and architecture (x86 vs. amd64).