how to create a bootable USB-stick!?
There are several means to create a bootable usb from an .iso file on linux.
To end up with a successful bootable usb, one needs to be clear about a few things, some of which are: having a valid verified .iso file, knowing the device name of the usb to which the .iso file is to be copied, and having the software on the linux machine to accomplish the writing to the usb.
The verification of the .iso file can be done using the procedures that the various distros provide and describe. They usually use checksums. Here's an example from linux mint:
linuxmint-installation-guide.readthedocs.io
To find the name of the usb one can plug it in and run the command:
For example:
Code:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 1 14.3G 0 disk
└─sda1 8:1 1 14.3G 0 part
sr0 11:0 1 1024M 0 rom
nvme0n1 259:0 0 465.8G 0 disk
├─nvme0n1p1 259:1 0 476M 0 part /boot/efi
├─nvme0n1p2 259:2 0 14.9G 0 part [SWAP]
└─nvme0n1p3 259:3 0 450.4G 0 part /
It's clear here that sda is the usb device because it's the roughly the correct size, and all the other outputs are the other disks on the machine. The usb is 16 gigabytes, but the lsblk measures in gibibytes, so the 14.3 is a smaller figure. If this is checked on the dmesg output, after the usb has been plugged in, one finds the line showing this:
Code:
[ 6389.508992] sd 9:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
The actual small differences from the 16 GB to 15.4GB are for other reasons the reader can research.
There a few commands to write the .iso file to the usb. In the following examples the .iso file is called: image.iso, and the usb device is: /dev/sda
Code:
dd if=image.iso of=/dev/sda bs=4M
cat image.iso > /dev/sda
cp image.iso /dev/sda
There are options that can be added to the dd command above like "status=progress", and more so that the command will show some progress on screen in the terminal. See the man page for dd.
The user needs in each case above to wait until the command prompt returns signalling that the writing to the usb has completed. Sometimes one can press the <enter> key to check whether a prompt has become available again if the time of writing seems inordinately long.
There are other commands using pv, genisoimage, xorriso-dd-target, which one can check in the their manpages and online.
EDIT:
@wizardfromoz in post #5 below makes the important point that the usb device needs to be unmounted when any of the above commands to write to it are executed.
If the operating system automatically mounts a usb device when it is plugged in, the user must unmount it. If it is automatically mounted, it's often mounted at the mount point:
/media/<user>/
but could be elsewhere.
Whether or not the usb is mounted can be checked with the command:
If the device's name, for example /dev/sda, appears in the output of the mount command, (e.g. it could be /dev/sda1), then the device is mounted and it needs sudo or root privileges to unmount it. If the name in the mount output is /dev/sda1 it can be unmounted with:
or it can unmounted from the mount point:
where <user> is the name that appears in the filesystem.
It should also be noted that one can only unmount a device when that device is not in use, so the user should not be located in the directory where it is mounted, when unmounting it.
Thanks
@wizardfromoz for that important detail. Alas, usbs are not automatically mounted here, so this detail was carelessly omitted originally.