跳至主要内容

How can I create a Windows bootable USB stick using Ubuntu?

even other Linux distros as long as GParted and GRUB are installed.
Install GParted and GRUB on Ubuntu with:
sudo apt-get install gparted grub-pc-bin p7zip-full ntfs-3g

For BIOS: MBR partition scheme

  1. Rewrite the partition table as msdos and format your USB drive as NTFS using GParted (and then "Manage flags" and add the boot flag).
  2. In GParted, right click the USB partition and select Information. Copy the UUID somewhere as you will need it.
  3. Copy all files from mounted Windows ISO or DVD to USB drive using your favorite file manager.
  4. Go to USB drive and if the folder named boot has uppercase characters, make them all lowercase by renaming it.
  5. Install GRUB on USB:
    sudo grub-install --target=i386-pc --boot-directory="/<USB_mount_folder>/boot" /dev/sdX
    
  6. Create a GRUB config file in the USB drive folder boot/grub with the name grub.cfg.
    Write this into the file:
    echo "If you see this, you have successfully booted from USB :) <or whatever you want>"
    insmod ntfs
    insmod search_fs_uuid  
    search --no-floppy --fs-uuid <UUID_from_step_2> --set root 
    ntldr /bootmgr
    boot
    
  7. Unmount the USB drive and restart your PC. Choose the USB as the first boot device in BIOS and start booting from it.

For UEFI: GPT partition scheme *

* Older Windows versions / editions may not be properly supported or not supported at all. I suggest reading the Microsoft UEFI Firmware page.
  1. Using GParted rewrite the partition table of the USB drive as GPT.
  2. Create a new primary partition and format it as FAT32.
  3. Copy all Windows files (from mounted ISO or DVD) to the USB drive.
  4. Look on USB in the efi/boot folder. If there's a file bootx64.efi (bootia32.efi) then you're done. The USB is bootable. Skip to step 7.
  5. Otherwise, open sources/install.wim with the Archive Manager (you must have 7zinstalled) and browse to ./1/Windows/Boot/EFI. From here extract bootmgfw.efisomewhere, rename it to bootx64.efi (or bootia32.efi for supported 32 bits OS [?]) and put it on USB in efi/boot folder.
  6. If you're making a Windows 7 USB, copy the boot folder from efi/microsoft to efifolder.
  7. Don't forget to unmount (safely remove) the USB drive. Select the proper EFI loader from your BIOS.

评论

此博客中的热门博文

onsen ui example splitter side menu swipe

<!DOCTYPE html> <html> <head> <title>TheyTube - Watch free video online</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">   <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>   <script type="text/javascript">   ons.platform.select('android')   </script> </head> <body> <ons-splitter>   <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>     <ons-page>       <ons-list>         <ons-list-item onclick="fn.load('home.html')" tappable>           Home         </ons-list-item>         <ons-list-item onclick="fn.load('settings.html')" tappable>           Setti

go golang get disk usage free space remain info

package main import ( "fmt" "syscall" ) func main() { fmt.Println(DiskUsage("./")) } func DiskUsage(path string) uint64 { fs := syscall.Statfs_t{} err := syscall.Statfs(path, &fs) if err != nil { return 0 } return fs.Bfree * uint64(fs.Bsize) } //All space   = fs.Blocks * uint64(fs.Bsize) //Free space = fs.Bfree * uint64(fs.Bsize) //Used space= fs.All - disk.Free