Bootable-usb-stick-from-iso

From aldeid
Jump to navigation Jump to search

Description

This tutorial explains how to create a bootable USB stick from an ISO file. The ms-sys utility enables to write Windows Master Boot Record (MBR) on the USB key.

From Linux

Prerequisites

First install gettext (msgfmt is needed):

$ sudo apt-get install gettext

Download ms-sys utility from sourceforge:

$ cd /data/src/
$ wget http://downloads.sourceforge.net/project/ms-sys/ms-sys%20development/2.3.0/ms-sys-2.3.0.tar.gz
$ tar xzvf ms-sys-2.3.0.tar.gz
$ cd ms-sys-2.3.0/
$ make
$ sudo make install

Instructions

Start cfdisk utility

$ sudo cfdisk /dev/sdb
  • Delete all partitions on /dev/sdb
  • Create a new one:
    • that takes all available space
    • from type NTFS
    • that is bootable

Create NTFS filesystem

$ sudo umount /dev/sdb1
$ sudo mkfs.ntfs -f /dev/sdb1
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

Mount the USB stick as well as your ISO:

$ sudo mkdir /mnt/usb
$ sudo mkdir /mnt/iso
$ sudo mount -o loop /data/iso/win7.iso /mnt/iso/
$ sudo mount /dev/sdb1 /mnt/usb/

Copy all files from the ISO to your USB stick:

$ sudo cp -r /mnt/iso/* /mnt/usb/

Write Windows 7 MBR on usb stick:

$ sudo ms-sys -7 /dev/sdb

Unmount USB stick and you're done!

$ sudo umount /dev/sdb1

From Mac OS X

Convert your iso file into a dmg file:

$ hdiutil convert -format UDRW -o ~/iso/ubuntu-12.04.1-desktop-i386 ~/iso/ubuntu-12.04.1-desktop-i386.iso

The command above will create a file named ~/iso/ubuntu-12.04.1-desktop-i386.dmg

Insert your USB stick and check the disk number with diskutil:

$ diskutil list
dyld: DYLD_ environment variables being ignored because main executable (/usr/sbin/diskutil) has __RESTRICT/__restrict section
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            749.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.0 GB     disk2
   1:             Windows_FAT_32                         8.0 GB     disk2s1

Unmount the disk:

$ diskutil unmountDisk /dev/disk2

Copy Ubuntu on your USB stick:

$ sudo dd if=~/iso/ubuntu-12.04.1-desktop-i386.img.dmg of=/dev/disk2 bs=1m

Once completed, eject your disk:

$ diskutil eject /dev/disk2