Как сделать загрузочную флешку windows 7 из iso образа в убунту

Время на прочтение2 мин

Количество просмотров438K

Недавно друг попросил установить ему Windows 7. Так уж вышло, что мой DVD-привод давно не работает, зато есть флешка на 8 ГБ. Тема создания загрузочной флешки с Windows 7 из-под Windows уже давно сильно разжевана в Сети. Но я пользуюсь Ubuntu, так что пришлось искать другое решение. На самом деле, как мне кажется, оно еще и проще.

Для начала нам потребуется графическая утилита GParted и пакет для работы с файловой системой NTFS. Для этого достаточно установить пакеты gparted и ntfsprogs. Это можно сделать как через Synaptic, так и через консоль:
sudo apt-get install gparted ntfsprogs

Далее нам нужно отформатировать флешку.
Можно сделать это из консоли:
sudo mkfs.ntfs /dev/sdb4
вместо /dev/sdb4, разумеется, должен быть адрес Вашей флешки
Можно это сделать и более легким путем. Для этого запускаем GParted, выбираем флешку (выпадающее меню сверху) и выбираем раздел. Выбираем в меню «Раздел» подменю «Отмонтировать», потом снова в меню «Раздел» подменю «Форматировать в » и в выпадающем меню выбираем «ntfs». Жмем зеленую галочку на панели инструментов.

Если Вы форматировали флешку через консоль, то дальше все-равно придется запустить GParted для того, чтобы установить boot флаг на флешку. Выбираем нужный раздел, выбираем меню «Раздел», подменю «Установить флаги». В появившемся окошке ставим галочку на «boot» и закрываем окно. GParted нам больше не понадобится.

Дальше проблема, с которой я столкнулся было то, что стандартные средства Ubuntu не позволяют открыть UDF ISO образ. Поэтому нужно смонтировать образ вручную:
sudo mkdir /media/iso
sudo mount windows7.iso /media/iso -t udf -o loop

Осталось только скопировать все файлы из образа на флешку:
cp -R /media/iso/* /media/MyFlashDrive

Вот и все!

P.S. В принципе можно таким образом на флешку не только Windows 7 скопировать.

UPD. Можно обойтись и вовсе без использования GParted. Вместо него можно использовать fdisk (спасибо icCE)
bogus@bogus-laptop:~$ sudo fdisk /dev/sdb

Команда (m для справки): p

Диск /dev/sdb: 1998 МБ, 1998585344 байт
255 heads, 63 sectors/track, 242 cylinders
Units = цилиндры of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00068ccc

Устр-во Загр Начало Конец Блоки Id Система
/dev/sdb4 1 243 1951712 7 HPFS/NTFS
Раздел 4 имеет различные физические/логические окончания:
физ=(241, 254, 63) логич=(242, 250, 7)

Команда (m для справки): a
Номер раздела (1-4): 4

Команда (m для справки): p

Диск /dev/sdb: 1998 МБ, 1998585344 байт
255 heads, 63 sectors/track, 242 cylinders
Units = цилиндры of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00068ccc

Устр-во Загр Начало Конец Блоки Id Система
/dev/sdb4 * 1 243 1951712 7 HPFS/NTFS
Раздел 4 имеет различные физические/логические окончания:
физ=(241, 254, 63) логич=(242, 250, 7)

Команда (m для справки): w
Таблица разделов была изменена!

Вызывается ioctl() для перечитывания таблицы разделов.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Синхронизируются диски.
bogus@bogus-laptop:~$

UPD2. Более простой способ с помощью dd (спасибо stampoon):
dd if=/w7.iso of=/dev/sdx

UPD3. Если после dd или копирования файлов с флешки загрузиться не выходит, вероятно там не корректная MBR. (thx nalimka)
Можно заюзать утилиту ms-sys:
ms-sys -7 /dev/sdb

Contents

  1. Create a Windows install drive
  2. If you have not yet …

    1. … downloaded an iso file

      1. Download a 64-bit Windows 7—11 iso file
    2. … created a mountpoint and loop mounted the iso file

      1. Create a mountpoint
      2. Loop mount the iso file
      3. Check the size of the biggest file
    3. … downloaded the correct compressed image file

      1. Download the following compressed image file
  3. Create the partition table and file systems

    1. Install mkusb if you want to clone safely and easily (optional)
    2. Clone ‘grub-win-ntfs-install.img.xz’ to the target drive

      1. Use mkusb or Disks
      2. Use dd to clone in a risky way
      3. Use Win32 Disk Imager to clone in Windows
    3. Mount partitions on the target drive

      1. Create mountpoints
      2. Mount the partitions on the USB pendrive or memory card
  4. Copy the content from the iso file to the target partition

    1. rsync
    2. Alternative 1
    3. Alternative 2
  5. Flush the buffers
  6. Now you have a Windows install drive :-)

    1. Unmount the partitions on the target drive and unplug it
  7. Continue if you wish

    1. Modify the partition table

Return to the main diy page


Create a Windows install drive

These instructions can help you create a USB pendrive, that can install Windows from an iso file, which contains a file that exceeds the 4 GiB limit for the FAT32 file system.

  • The size of the USB pendrive should be at least 8 GB
    • If you have a custom iso file, that needs more space than provided by the NTFS partition of the compressed image file, you should delete the NTFS partition and create a new partition using all the drive space behind the FAT partition
  • The method is tested with 64-bit systems
  • The install drive works both in UEFI mode and BIOS mode (alias CSM alias legacy mode) including secure boot. Grub is used to boot in BIOS mode, and it comes with the compressed image file.

If you have not yet …

… downloaded an iso file

Download a 64-bit Windows 7—11 iso file

You find Windows iso files via Microsoft’s web pages (and you need a license key to use it later on).

… created a mountpoint and loop mounted the iso file

Create a mountpoint

Create the mountpoint only once.

sudo mkdir -p /mnt/lp1

Loop mount the iso file

sudo mount -o loop file.iso /mnt/lp1

for example

sudo mount -o loop Win10_1809Oct_EnglishInternational_x64.iso /mnt/lp1

Check the size of the biggest file

When you have loop mounted a Windows iso file, you should check the size of the biggest file, often ‘install.wim’. If it is > 4GiB, you need an ntfs partition. You can look for the biggest file with the following command line,

find /mnt/lp1 -ls|sort -nk7|tail -n1

Convert from bytes to MiB (you can divide by 2^30 in bc).

You can find all files that exceed the limit directly with the following command line,

find /mnt/lp1 -size +4G -printf "%11s %p\n" | sort -n

If a file exceeds the limit, you should download and use a compressed image file, that provides two partitions, one with the file system FAT16 and one with NTFS, that can manage the big file(s).

… downloaded the correct compressed image file

Download the following compressed image file

You may want a higher level of security. This file is signed with gpg and you can verify it according to the following commands.

gpg --keyserver keyserver.ubuntu.com --recv-keys EB0FC2C8
gpg --verify grub-do-it-yourself.img.xz.md5.asc 

The warning «was NOT verified» means that there is no chain of trusted keys between your computer’s keyring and the key, that was used to sign the checksums (the key of sudodus). Check that the result matches with the following output, when you verify it,

$ gpg --keyserver keyserver.ubuntu.com --recv-keys EB0FC2C8
gpg: directory `/home/tester/.gnupg' created
gpg: new configuration file `/home/tester/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/tester/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/tester/.gnupg/secring.gpg' created
gpg: keyring `/home/tester/.gnupg/pubring.gpg' created
gpg: requesting key EB0FC2C8 from hkp server keyserver.ubuntu.com
gpg: /home/tester/.gnupg/trustdb.gpg: trustdb created
gpg: key EB0FC2C8: public key "Nio Sudden Wiklund (sudodus) <address@mailserver.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

$ gpg --verify grub-win-ntfs-install.img.xz.md5.asc 
gpg: Signature made sön  3 mar 2019 13:20:07 CET
gpg:                using RSA key 0303EA77E34C52F2295847C6BD43C742EB0FC2C8
gpg:                issuer "nio.wiklund@gmail.com"
gpg: Good signature from "Nio Sudden Wiklund (sudodus) <nio.wiklund@gmail.com>" [ultimate]

Then there is reason to trust that nobody else has written the checksums. The date of the signature will change at updates, and the text might be translated to your local language, but it should be clear that it is a ‘Good signature from «Nio Sudden Wiklund (sudodus)»‘.

If you have the compressed image file and the md5sum file in the same directory, you can use the md5sum program to check like this,

md5sum -c grub-win-ntfs-install.img.xz.md5.asc

tester@xenial32 ~ $ md5sum -c grub-win-ntfs-install.img.xz.md5.asc
grub-win-ntfs-install.img.xz: OK
md5sum: WARNING: 14 lines are improperly formatted

The ‘improperly formatted lines’ are the lines belonging to the gpg signature.

Create the partition table and file systems

Install mkusb if you want to clone safely and easily (optional)

https://help.ubuntu.com/community/mkusb

Clone ‘grub-win-ntfs-install.img.xz’ to the target drive

Normally you would clone grub-win-ntfs-install.img.xz to a USB pendrive or memory card, minimum size 8GB. The image extracts to 7743 MB. There is a margin for undersized 8 GB pendrives and cards. Please unmount all partitions on the target drive before cloning.

Use mkusb or Disks

Use mkusb or Disks to clone in a safe way, via the GUI or using mkusb-dus

dus grub-win-ntfs-install.img.xz

or

Use dd to clone in a risky way

Avoid this method if you can, because it is risky.

Identify the target drive. You can use lsblk without options or better, copy and paste the following command line

lsblk -d -o name,vendor,model,type,size,hotplug

and then use the correct drive letter in the cloning command line

xz -d —stdout grub-win-ntfs-install.img.xz | sudo dd of=/dev/sdX bs=4096

where X is the drive letter of the target drive. Check that the drive letter is correct, and double-check the details of the whole command line. A minor typing error might overwrite your family pictures.

Use Win32 Disk Imager to clone in Windows

Mount partitions on the target drive

Create mountpoints

Create mountpoints only once.

sudo mkdir -p /mnt/sd1
sudo mkdir -p /mnt/sd2

Mount the partitions on the USB pendrive or memory card

Identify the target drive. You can use lsblk without options or better, copy and paste the following command line

lsblk -d -o name,vendor,model,type,size,hotplug

or blkid, grep and cut, copy and paste the following command line

sudo blkid |grep WININSTFAT|cut -d ' ' -f 1-2
sudo blkid |grep WinInstNtfs|cut -d ' ' -f 1-2

and then use the correct drive letter in the mounting command line

sudo mount /dev/sdX1 /mnt/sd1

sudo mount /dev/sdX2 /mnt/sd2

where X is the drive letter of the target drive. Double-check that the drive letters are correct.

Copy the content from the iso file to the target partition

rsync

You can use rsync to perform the copy operations. First copy the files related to booting to the FAT partition. Then copy ‘everything’ to the NTFS partition. Some computers need the FAT partition to boot in UEFI mode. Some computers can boot directly from the NTFS partition.

(Grub is used to boot in BIOS mode, and it comes with the compressed image file, you need not worry about that.)

sudo rsync -r --info=progress2 --exclude=sources /mnt/lp1/ /mnt/sd1
sudo mkdir /mnt/sd1/sources
sudo rsync -r --info=progress2 /mnt/lp1/sources/boot.wim /mnt/sd1/sources
sudo rsync -a --info=progress2 /mnt/lp1/ /mnt/sd2

There might be some warning and error messages from the rsync copying process. Some links cannot be understood and some permissions cannot be preserved by the FAT32 file system in the target partition. But the result will still be a useful system in the drive.

I have seen cases, when running in some versions of 32-bit Ubuntu systems, where rsync does not copy all the files correctly. They are truncated (too small). When this happens the system in the drive will not work. rsync did not notice it; there was no warning or error message about this problem.

Alternative 1

You can use the ‘old version’ (old method to make a Windows installer) in mkusb for the whole process instead. It is made and tested to manage these cases, where rsync truncates some files. Use the ‘new version’ in mkusb, if a file exceeds 4 GiB.

Alternative 2

You can try to extract the content from the iso file to the target partition with your favourite tool for compressed files, for example

1. 7z (via the package p7zip-full) in Ubuntu and

2. 7-zip in Windows.

Flush the buffers

Now you have a Windows install drive :-)

Unmount the partitions on the target drive and unplug it

Check that no partition on the target drive is mounted with

(and you can unmount the iso file too

sudo umount /mnt/lp1

but it is mounted read-only, and not dangerous to leave mounted)

In Windows you should eject the drive and wait until it is ‘safe to remove the device’.

or

Continue if you wish

Modify the partition table

  • If there is space enough (if the drive contains more than 8 GB), you can create a third partition. It is easy to use gparted to create the third partition.

  • If you have a custom iso file, that needs more space than provided by the NTFS partition of the compressed image file, you should delete the NTFS partition and create a new partition using all the drive space behind the FAT partition.

Return to the main diy page

Installation/iso2usb/diy/windows-installer-for-big-files (last edited 2023-04-29 00:39:16 by nio-wiklund)

There are a lot of guides on the web describing how to create a bootable Windows 7 or 10 USB drive in Linux. However, many of those guides have missing steps, involve using Windows, or use programs not readily available on modern Linux distributions.

The following post will walk you through the necessary steps to create a bootable Windows 7 or 10 USB drive from a modern Linux distribution.

Download the Windows 7 or 10 ISO File

If you do not already have the Windows 7 or 10 ISO file, start by downloading one of them:

  • Download Windows 7 Disc Images (ISO Files)
  • Download Windows 10 Disc Image (ISO Files)

Plugin the USB Drive

Next, you need to figure out the device ID of the USB drive.

Most modern Linux distributions should automount the USB drive. If not, you can see what device ID is assigned to the USB drive by running df -h or mount or lsblk.

Additionally, syslog can be monitored to find the device ID.

On Fedora, CentOS, or RHEL, run sudo tail -f /var/log/messages.

On Ubuntu or Debian, run sudo tail -f /var/log/syslog.

Once you figure out the USB drive’s device ID, be sure to unmount it before continuing:

sudo umount /dev/sdX

Partition the USB Drive

Disclaimer: The following steps will erase everything on your USB drive. I am not, nor is anyone else, responsible for any potential data loss.

Either parted or fdisk can be used to partition the USB drive. Use the command you are more familiar with.

Changes made using parted cannot be reverted because they are executed in real time to the device. Changes made using fdisk can be reverted as long as those changes have not yet been written to the device. In either case, make sure you are making changes to the correct device.

Partition the USB Drive with parted

Open the USB drive in parted:

sudo parted /dev/sdX

Once you are in the parted interactive menu, partition the USB drive with the following steps (Make sure you are using parted on the right device ID. Everything done using parted is executed in real time.):

(parted) mklabel msdos
(parted) mkpart primary ntfs 1 -1
(parted) set 1 boot on
(parted) quit

Next, go to the section titled Format the New Partition on the USB Drive as NTFS.

Partition the USB Drive with fdisk

Open the USB drive in fdisk:

sudo fdisk /dev/sdX

Once you are in the fdisk interactive menu, partition the USB drive with the following steps:

  1. Type p and Enter to print the current partition table. I do this out of habit.
  2. Delete all the current partitions by typing d then Enter for each partition.
  3. Type n and Enter. Type p and Enter. Type 1 and then type Enter three times to create one new primary partition that uses all available space.
  4. Type t and Enter (Partition 1 is automatically selected because it’s the only partition). Type 7 and Enter to change the type to HPFS/NTFS/exFAT.
  5. Type a and Enter. Type 1 and Enter to turn on the Boot flag.
  6. To verify everything worked, type p and Enter and make sure the Boot column has an asterisk (*) set and the Id column is set to 7.
  7. Finally, type w and Enter to write the changes.

Next, go to the section titled Format the New Partition on the USB Drive as NTFS.

Format the New Partition on the USB Drive as NTFS

You will need the Linux NTFS userspace driver installed.

To install it on Fedora, CentOS, or RHEL, run sudo yum install ntfs-3g.

To install it on Ubuntu or Debian, run sudo apt-get install ntfs-3g.

Then, format the partition as NTFS:

sudo mkfs.ntfs -f /dev/sdX1

Install ms-sys

You will need program ms-sys to write a Master Boot Record (MBR) to the USB drive.

To compile the source code, install the following packages: gcc, make, and gettext (the package names should be the same on Fedora, CentOS, RHEL, Ubuntu, and Debian).

To install those packages on Fedora, CentOS, or RHEL, run sudo yum install gcc make gettext.

To install those packages on Ubuntu or Debian, run sudo apt-get install gcc make gettext.

Download the latest ms-sys source code from http://ms-sys.sourceforge.net/#Download.

Un-tar the source code and change into the source code directory:

tar xvzf ms-sys-2.6.0.tar.gz

cd ms-sys-2.6.0

Compile and install the binary:

make

sudo make install

ms-sys will install to /usr/local/bin.

If you do not have /usr/local/bin in your shell’s environment path, run the following commands to temporarily add it:

su -

export PATH=$PATH:/usr/local/bin

Write a Master Boot Record (MBR) to the USB Drive

Now that ms-sys is installed, you will use it to write a Windows 7 Master Boot Record to the USB drive. This same command also works if you are creating a bootable Windows 10 USB drive.

sudo ms-sys -7 /dev/sdX

Successful output should be:

Windows 7 master boot record successfully written to /dev/sdX

Write an Extended Boot Record (EBR) to the USB Drive Partition

In addition to the Master Boot Record, you might also need to write an Extended Boot Record. For the lifetime of this post I have not had this step, but I recently added it because I encountered boot problems when trying to boot Windows 10 from a USB drive on a Lenovo X1 Carbon Gen 7. I found this step thanks to a similar post at Wayne Chang’s blog.

sudo  ms-sys -n /dev/sdX1

Successful output should be:

NTFS Windows 7 boot record successfully written to /dev/sdX1

Mount the USB Drive

Create or use an existing directory to mount the USB drive:

sudo mkdir -p /mnt/usb

sudo mount /dev/sdX1 /mnt/usb

Mount the Windows 7 or 10 ISO

Create or use an existing directory to mount the Windows 7 or 10 ISO:

sudo mkdir -p /mnt/iso

sudo mount -o loop /path/to/windows/iso.iso /mnt/iso

Copy the Contents of the Windows 7 or 10 ISO to the USB Drive

Finally, copy the contents of the mounted Windows 7 ISO to the mounted USB drive (this could take some time depending on the speed of the USB drive):

sudo cp -av /mnt/iso/* /mnt/usb/

Unmount the USB Drive

Unmount the USB drive once the cp command is finished.

sudo umount /mnt/usb

On several occasions the cp command completed before all I/O was written to the USB drive. Because of this, sudo umount /mnt/usb stalled until all I/O had been written. As previously mentioned, depending on the speed of your USB drive, it could take sometime for all I/O to finish being written to your USB drive.

Use the iotop command to watch the I/O throughput of the USB drive in real time. Once you no longer see the USB drive at the top of iotop’s output, sudo umount /mnt/usb should successfully exit.

Boot from the USB Drive

Plug the USB drive into the computer you want to install Windows 7 on and boot from it.

Modern laptops and desktop motherboards typically have several USB boot options such as:

  • USB-HDD
  • USB-ZIP
  • USB-FDD
  • USB-CDROM

Use trial and error to figure out the appropriate USB boot option to boot to.

For example, on a Gigabyte GA-MA74GM-S2 motherboard, booting to USB-HDD did not work. I had to boot to USB-ZIP. However, on a Lenovo ThinkPad X220 I had to boot to USB-HDD.

В данной статье мы расскажем как создать загрузочную флешку с Windows в системе Linux с помощью утилиты под названием «Ventoy».

Для начала вам потребуется:

— Сама утилита Ventoy под Linux, скачать вы ее можете с официального сайта.

— ISO Образ нужной вам Windows, скачать его можно в нашем каталоге.

— Так же вам потребуется активировать будущую Windows, оригинальные ключи активации вы можете приобрести у нас в магазине по выгодным ценам от 1140 ₽.

1) После того как вы скачали архив с программой, распаковываем его в удобное для вас место.

2) Переходим в папу с программой, и нажимаем «Свойство» на файле «VentoyGUIx86_x64».

3) В разделе «Права» ставим галочку напротив «Разрешить выполнение файла как программы», чтобы сделать файл исполняемым.

4) После этого запускаем файл.

5) После запуска открывается интерфейс утилиты, если вы будете устанавливать Windows на старый ПК c Legacy Boot, то в разделе Option => Partition Style выбираем «MBR». Если же установка будет производиться на новый ПК с UEFI, тогда выбираем разметку «GPT».

6) После выбора нужной вам разметки, жмем «Install» и ждем какое-то время.

7) После записи программы на флешку, появится два раздела.

— Первый раздел, куда установилась сама утилита с ее файлами.

— Второй раздел, куда нужно будет поместить ISO образ Windows.

8) Все что нам остается, это просто переместить во второй раздел заранее скачанный ISO образ нужной вам Windows.

9) После чего запуститься с этой флешки, выбрать второй раздел и начать процедуру установки системы.

Хотим напомнить что все популярные ISO образы Windows вы можете скачать в нашем каталоге.
— Windows 11

— Windows 10

— Windows 8.1

— Windows 7

As a lot of people asked me “How do I create a bootable usb drive with Windows 7 using Ubuntu?”, I decided to make this easy step-by-step tutorial to help you.  After many tests, I concluded that the most effective and simple solution is to use UNetbootin software. The main advantage is that this software is available for both Linux and Windows operating systems. So let’s start!

What you need:

  •  A USB Flash Drive (4GB or larger)
  •  .ISO file with Windows 7

Now we have to format our USB Flash Drive to NTFS. To do that we need to install Gparted (GParted is a friendly user free partition editor for graphically managing your disk partitions). To install it in Ubuntu we will use the next command:

sudo apt-get install gparted

Also, in order to format a drive to NTFS, we need to install NTFS-3g using the next command:

sudo apt-get install ntfs-3g

Now that we have installed all the applications we need, let’s format the USB Flash Drive as NTFS. Open Gparted and go to  System >> Administration >> GParted Partition Editor. From the following drop-down list, select your USB Flash Drive.

Due to my research, I’ve found that the newer versions of Unetbootin may cause some problems by selecting an USB Drive to format in NTFS way (!Don’t try to format it to FAT because Windows installation surely will fail). The version that I’ve already tested and it clearly works it’s Unetbootin-linux-494. (!Don’t try to install other version.)

Now let’s open the Unetbootin file. To do it right, first we have to allow it to be executed as a program. What we have to do is to right-click on it >> select “Properties” >> select “Permissions” tab >> CHECK “Allow executing file as a program”. Now double-click the Unetbootin to open it.

The main reason that we choose to use Unetbootin-linux-494 is that you still can choose the option “Show all Drivers“, otherwise, on the newer versions Unetbootin’s developers had removed this very useful option. Now let’s open Unetbootin double-click on its icon. It will open a window with a lot of options. First of all, be sure that you had selected “Diskimage”. The next step is to browse for your ISO file, by clicking on the next three dots, selecting the Windows 7 file, saved on your computer.

After that, you have to select the USB Drive, by ticking “Show all drivers” option. By clicking on the “Drive:”, it will appear a drop-down list. Now select your USB Drive. (! In my case, as you can see, the USB Drive it’s called “/dev/sbd1”, but it’s not a rule. Obviously, your USB Drive may have a different name.) You are now very close to use your new Bootable Windows 7 USB Drive. All you have to do is to click the “OK” button and wait some minutes (it depends by your computer’s performance the time you have to wait – better computer, less time to wait).

That was all you had to do. Now you can use your new Bootable Windows 7 USB drive to install on every computer that suport booting from an USB Drive.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как скрыть часто используемые папки windows 10
  • Лаги в играх на windows 10 как исправить
  • Заставка пузыри на рабочий стол windows 10
  • Установка nfs windows 2008 r2
  • Bitnami redmine windows installer