howto:bootable-usb

This is an old revision of the document!


Create bootable USB drive

UNetBootin

sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt-get update
sudo apt-get install unetbootin
  1. Select disk image and choose ISO.
  2. Now, Browse to the particular ISO that you want to make as an installation media.
  3. Again, choose the type as USB and select your USB drive. Once you click ok, UNetbootin will install the boot media to your USB.

ddrescue

sudo apt install gddrescue

Find block device of USB stick:

sudo fdisk -l
ddrescue path/to/.iso /dev/sdx --force -D

Replace the x and path/to/.iso with your specific device block name and the path for the iso file.

dd

sudo umount /dev/sd??

where ?? is a letter followed by a number, look it up by running lsblk.

sudo dd bs=4M if=path/to/input.iso of=/dev/sd? conv=fdatasync status=progress
sync
<?code>

  - where input.iso is the input file, and /dev/sd? is the USB device you're writing to (run lsblk to see all drives to find out what <?> is for your USB).
  - conv=fdatasync avoids kernel disk caching and ensures write buffers are flushed before dd returns as finished. 
  - The sync bit is important as dd can return before the write operation finishes (in case conv=fdatasync wasn't used).


===== dd/syslinux =====

Sometimes (usually older iso files) dd is not sufficient and the pendrive will not boot. In this case, you may need to install syslinux:

<code>sudo apt-get install syslinux

and then run the following commands:

sudo mkfs -t vfat -I /dev/sdX

You want to run that last command to /dev/sdX and not /dev/sdX1.

Then, proceed with the following commands:

isohybrid /path/to/file.iso --entry 4 --type 0x1c
dd if='/path/to/file.iso' of=/dev/sdX bs=8M conv=fdatasync

or, to see progress of image write:

pv -tpreb /path/to/file.iso | dd of=/dev/sdX bs=8M

or instead of dd, you can use cat instead:

sudo -s
cat /path/to/file.iso > /dev/sdX

Rememeber to issue sync command to flush write cache

sync

Belana etcher

GUI from http://etcher.io

To install:

echo "deb https://deb.etcher.io stable etcher" | sudo tee /etc/apt/sources.list.d/balena-etcher.list
sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv-keys 379CE192D401AB61
sudo apt-get update
sudo apt-get install balena-etcher-electron

To Uninstall:

sudo apt-get remove balena-etcher-electron
sudo rm /etc/apt/sources.list.d/balena-etcher.list
sudo apt-get update

or:

wget "https://dl.bintray.com/etcher/debian/pool/stable/e/etcher/:balena-etcher-electron_1.5.99_amd64.deb"
sudo dpkg -i balena-etcher-electron_1.5.99_amd64.deb

Testing using Qemu

To test if everything has gone right, boot your system from the USB drive. To do so you will have to reboot your system. QEMU can help you in this. QEMU is a machine emulator and virtualizer.

  Make sure qemu is installed
  <code>apt-get install qemu</code>
  run the below command and you will see a virtual machine booting from your USB Drive
qemu -hda /dev/sdb 
howto/bootable-usb.1592941802.txt.gz · Last modified: 2023/05/29 11:53 (external edit)