Posts Tagged ‘Ubuntu’

[Source]

Ubuntu has already an application called Startup Disk Creator, but this can only be used to make Linux bootable USB drives. To make a Windows bootable USB there is an application called WinUSB but it hasn’t been updated for a while.

The following guide works on any Linux distribution as long as it has GRUB and GParted installed and can make bootable USB for any Windows version newer than Vista (including Vista too).

Choose whatever method is suitable for your computer (either MBR for BIOS or GPT for UEFI – do NOT follow both tutorials as you’ll get a non-bootable USB). Note that the drive made for UEFI will not boot on BIOS computers.

MBR for BIOS

This is intended for older PCs that use BIOS. The USB can also be used on UEFI computers in CSM boot mode. A msdos partition scheme and a bootloader will be required.

1. Format USB

This is the first step. Although it can be done from Terminal, GParted has a nice GUI and it is easy to use for this. So, plug in your USB and start GParted (root permissions required). Select the USB drive and unmount it, otherwise you won’t be able to format it.

GParted main window. The first thing to do is select the USB drive.
Right-click the USB drive partition and select Unmount

You must re-create the partition table by going to the Device menu then select Create Partition Table. Choose msdos and click Apply. Note that it may work with a simple formatting without rewriting partition table.

The Partition Table dialog.

Right click the unallocated space and select New. Make a primary NTFS partition and give it a label too. Remember the label as you will need it later.

New Partition dialog.

Apply all pending operation from Edit menu – Apply all operations or click the button on the main window. Right click the partition and add the boot flag by selecting Manage Flags and tick the checkbox next to boot.

The Apply button from the main window of GParted

When installing bootloader, a partition UUID must be specified. So, right-click the partition again and select Information. Write down that UUID as you will need it later.

The Information dialog showing UUID

2. Copy Windows files

Quit GParted and use the file manager to copy all files from Windows ISO to USB stick. Mount the ISO using Open withDisk Image Mounter (if you use Nautilus as a file manager). Then select all files Ctrl+A and Copy to USB drive which will be automatically mounted when you click on it at /media/<username>/<drive_label>. After the copy process is finished, look in the USB root folder for the boot directory. If it is uppercase, rename it to lowercase.

3. Make it bootable

GRUB will be used for that. Open a Terminal and run:

sudo grub-install --target=i386-pc --boot-directory="/media/<username>/<drive_label>/boot" /dev/sdX

Replace:

  • /media/<username>/<drive_label> with the path where USB drive is mounted
  • /dev/sdX with the USB drive, not the partition (e.g. /dev/sdb)
Wait for it to finish. If everything is OK, you should see:
Installing for i386-pc platform.
Installation finished. No error reported.
If you got this error:

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

Install the grub-pc-bin package with sudo apt-get install grub-pc-bin and try again.

Now, create a text file and write the following in it:

default=1
timeout=15
color_normal=light-cyan/dark-gray
menu_color_normal=black/light-cyan
menu_color_highlight=white/black

menuentry "Start Windows Installation" {
 insmod ntfs
 search --no-floppy --fs-uuid <drive_UUID> --set root 
 chainloader +1 
 boot
}

menuentry "Boot from the first hard drive" {
 insmod ntfs
 insmod part_msdos
 set root=(hd1)
 chainloader +1
 boot
}

Replace <drive_UUID> with the UUID from step 1.  Save the file as grub.cfg and put it on the USB drive in the boot/grub folder.

That’s it. The USB drive is now bootable from BIOS (not UEFI) and can be used to install Windows on your PC. The first time you boot from it select Start Windows Installation. Tested with Windows Vista, but it should work with any newer version.

GPT for UEFI

UEFI boots from GPT schemed drives. No bootloader is required because EFI firmware can read FAT32 partition contents by itself. It looks for a specific firmware and if it founds it then loads it into RAM. Without a MBR bootloader the USB will not be bootable for BIOS computers. Only 64 bit versions of Windows 7 and newer are supported according to eightforums.com.

1. Format USB

Plug in the USB drive and launch GParted. Unmount the drive as shown above. Create a GPT partition table by selecting from Device menu Create Partition Table option. Choose gpt and apply.

The Partition Table dialog

Now right-click the unallocated space and create a new partition. It must be primary and formatted as FAT32. Give it a label too.

New Partition dialog

Don’t forget to apply all pending operations Ctrl+Enter.

2. Copy Windows files

Quit GParted and use the file manager to copy all files from Windows ISO to USB stick. Mount the ISO using Open with – Disk Image Mounter (if you use Nautilus as a file manager). Then select all files Ctrl+A and Copy to USB drive which will be automatically mounted when you click on it at /media/<username>/<drive_label>. After the copy process is finished, look in the USB root folder for the efi/boot directory. If there’s a bootx64.efi file there skip to step 3.

If the OS you are making a bootable USB for is Windows 7, browse the efi/microsoft folder and copy the entire boot folder from this path one level up in the efi folder. Merge folders if boot already exists.

Here is what to do if you don’t have the bootx64.efi file in efi/boot folder. Browse into the mounted Windows ISO image into the sources folder. Open install.wim with your archive manager (you will need 7z installed). Go to the path ./1/Windows/Boot/EFI and extract the file bootmgfw.efi anywhere you want. Rename it to bootx64.efi and put it on the USB drive, in the efi/boot folder. If you can’t find bootmgfw.efi in install.wim then you probably have a 32 bit Windows ISO or other types of images (recovery disks, upgrade versions).

Some UEFI firmwares are able to boot from NTFS and/or MBR partitions too as long as the bootx64.efi file exists at the right locations.

3. Make it bootable

It should be bootable. You can boot from USB now. The Windows-only utility Rufus does exactly the same thing when UEFI/GPT mode is selected.

Unless you can’t, do the following.

Launch GParted again and select your USB drive. Right-click the partition and assign it the boot flag (esp will get checked too). Note that msftdata will get unchecked. This boot flag makes the USB drive act as an ESP (EFI System Partition) so the first thing you’ll notice is that your OS (both Linux and Windows) is no longer auto mounting it. Do not boot your Linux OS with that USB plugged in (it may get automatically mounted at /boot/efi or something like that and it may interfere with the bootloader from HDD). To get back the USB drive, plug it in with the PC on, open GParted and check back msftdata.

If this didn’t work too, start over again but this time apply the msdos partition table instead of gpt. There will be no msftdata flag this time and boot flag has a totally different meaning.

I have been using the linux distros for quite a while now. My first distro was SuSE which lasted for couple of hours and then I switched to Ubuntu ultimate 2.0 because of its usability and the lack of time I had to learn the distro because of the urgency of couple of College Projects. Soon after the projects were over, I thought why not give a try to linux distro for all the usage and then I started looking for the best distro (I am not first person who does that 😉 ) and after suggestion from couple of friends , switched to fedora 10 with whom I lasted for couple of years. I don’t usually upgrade distros that often and fedora 10 was quite a stable version for me and I learnt a lot of internals of Unix on that distro. In between I also had an affair with RHEL for 1 or 2 months. With the release of Fedora 12-13, my fedora 10 was little outdated and now there was another college project lining up which required some unix work, time was to change the distro. Before changing the distro, I thought of upgrading to higher versions of fedora but there were so many problems with these versions of fedora, I decided to move to ubuntu. Since then I am using the Ubuntu.
I have tried ubuntu 9.04->9.10->10.04, but after upgrading from 10.04 to 10.10, distro had so many problems and then I fell back to 10.04 and again stuck with it till date. I had no plans to give up 10.04 until I heard from one of my colleague that 12.04 beta of Ubuntu is quite a stable and also the features it have are quite awesome. I was using kernel 3.1.1 on 10.04 and since long, I was planning to upgrade the kernel, 12.04 already had 3.2 kernel, I told myself,”what the hell,give it a try” and I installed 12.04. With quite a stable wine and unity, I have given up the dual boot windows and 12.04 is the only distro my system have.
Its not even a week since 12.04 is up on my system, I am already in love with it. I am sure if anybody gets a taste of this version of Ubuntu, he/she is surely gonna give up on windows. In terms of performance, end user usability, animated effects, configurability, it has surely left behind the windows by quite a mile. May 12.04 be the grand success for Ubuntu, Amen.