Return to the main iso2usb page


Instructions to make a boot drive, that boots both in UEFI and BIOS mode

Cloning - read-only drive

If you are happy with a read-only partition table and file system, you can clone the Ubuntu and Ubuntu community flavour iso files. This is very reliable but you cannot store data on the drive, and you cannot make it a persistent live drive (unless you start again for example with mkusb). Return if this is what you want.

Do it yourself - with the extraction method

The simple extraction method for UEFI mode is extended to BIOS mode and described with detailed instructions.

This method is designed to work with

  • Ubuntu: 64-bit Ubuntu desktop and Ubuntu community flavour desktop iso files

  • Windows: 64-bit Windows (8--10) iso files (Windows 7 boots only in BIOS mode)

Other linux distros: This method may or may not work in UEFI and/or BIOS mode depending on the boot structure. It helps if it is similar to Ubuntu's boot structure.

  • Linux Mint: From 'linuxmint-18.1-cinnamon-64bit.iso' you get a USB drive that boots in UEFI and BIOS mode, and you can make it persistent live.
  • Debian Stretch: From 'debian-live-9.0.1-amd64-cinnamon.iso', you get a USB drive that boots only in BIOS mode. The structure for booting and persistence is different from Ubuntu. (A cloned live-only USB drive can boot in UEFI and BIOS mode; If you wish, mkusb can create a USB drive that boots in UEFI and BIOS mode, and make it persistent live.)

Do it yourself - instructions

Download a compressed image file

Download this compressed image file: grub-do-it-yourself.img.xz

Check that the md5sum is correct with the following file: grub-do-it-yourself.img.xz.md5.asc

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,

tester@xenial32 ~ $ 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)

tester@xenial32 ~ $ gpg --verify grub-do-it-yourself.img.xz.md5.asc
gpg: Signature made mån 18 sep 2017 21:48:47 CEST using RSA key ID EB0FC2C8
gpg: Good signature from "Nio Sudden Wiklund (sudodus) <nio.wiklund@gmail.com>"
gpg: WARNING: not a detached signature; file 'grub-do-it-yourself.img.xz.md5' was NOT verified!
tester@xenial32 ~ $ 

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-do-it-yourself.img.xz.md5.asc

tester@xenial32 ~ $ md5sum -c grub-do-it-yourself.img.xz.md5.asc
grub-do-it-yourself.img.xz: OK
md5sum: WARNING: 14 lines are improperly formatted

The 'improperly formatted lines' are the lines belonging to the gpg signature.

Download the iso file

Download the iso file

64-bit Ubuntu desktop or Ubuntu community flavour desktop iso file

http://releases.ubuntu.com or for the community flavours http://cdimage.ubuntu.com

If the iso files of the version with the longest remaining support are not found via those links, you can find them via the following general link,

http://old-releases.ubuntu.com

and right now, when this is written, you want to find Ubuntu 16.04.1 LTS via the following link,

http://old-releases.ubuntu.com/releases/xenial

or

64-bit Windows 7--10 iso file

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

Check with md5sum that the iso file was downloaded correctly

Check the md5sum result with the uploaded values via this link: UbuntuHashes

Examples:

md5sum ubuntu-16.04.1-desktop-amd64.iso

or

md5sum Win10_US_x64.iso

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

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

Clone 'grub-do-it-yourself.img.xz' to the target drive

Normally you would clone grub-do-it-yourself.img.xz to a USB pendrive or memory card, minimum size 8GB. The image extracts to 7744 MB. There is a margin for undersized 8 GB pendrives and cards.

Use mkusb or Disks

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

dus grub-do-it-yourself.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

sudo dd if=grub-do-it-yourself.img.xz 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 the source and target

Create mountpoints /mnt/lp1 and /mnt/sd1

Create mountpoints only once.

sudo mkdir -p /mnt/lp1
sudo mkdir -p /mnt/sd1

Loop mount the iso file

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

for example

sudo mount -o loop ubuntu-16.04.1-desktop-amd64.iso /mnt/lp1
sudo mount -o loop Win10_US_x64.iso /mnt/lp1

Mount the partition 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 DIDITMYSELF|cut -d ' ' -f 1-2

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

sudo mount /dev/sdX1 /mnt/sd1

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

Copy the content from the iso file to the target partition

rsync

sudo rsync -a --info=progress2 /mnt/lp1/ /mnt/sd1

Normally there are 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.

But 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 mkusb for the whole process instead. It is made and tested to manage these cases, where rsync truncates some files.

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

sync

Now you have a live-only boot drive :-)

Unmount the partition on the target drive and unplug it

sudo umount /mnt/sd1

Check that no partition on the target drive is mounted with

df

(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

Create a new partition for storage

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

Make an Ubuntu persistent live drive

casper-rw file

Create a file with the name 'casper-rw'. There is free space in the FAT32 partition for the maximum 4 GB size.

sudo dd if=/dev/zero of=/mnt/sd1/casper-rw bs=1M count=4095

and create an 'ext2' file system inside the file

sudo mkfs.ext2 /mnt/sd1/casper-rw

Alternative - sharing free space between 'casper-rw' and 'home-rw'

You can use almost all (say 95%) of the remaining free space shared between a 'casper-rw' file and a 'home-rw' file. Decide how much to use for each of them depending on how you intend to use the drive: to install programs and/or to store data.

Edit grub.cfg

Edit the file /mnt/sd1/boot/grub/grub.cfg to add the boot option 'persistent' to the line starting with linux

linux ... quiet splash persistent ---

Save and exit the editor

Now you have a drive with a second partition and/or persistence :-)

Now you have a drive with a second partition for storage in Ubuntu and the Ubuntu community flavours. Windows can use the first partition (and if the second partition is a Microsoft file system, FAT32 or NTFS, an up to date Windows 10 system can use the second partition too).

Unmount the mounted partition on the target drive and unplug it

sudo umount /mnt/sd1

Check that no partition on the target drive is mounted with

df

(and you can unmount the iso file too

sudo umount /mnt/lp1

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

Check that your new boot drive works

Check that your new boot drive works as expected, and if not, try again, maybe you missed a step ...

Installation/iso2usb/diy (last edited 2017-09-24 13:43:44 by ister-kokos)