blog.area23.at - a simple url encoder/decoder

 a simple url encoder/decoder
 http://blog.area23.at

Labels

Wirtschaft (135) Österreich (103) Pressefreiheit (80) IT (64) code (37) Staatsschulden (34) EZB (25) Pensionssystem (14) music (3) France (1)

2021-01-11

linux: flashing an (iso)image to usb stick

This article contains all main informations to create (rawwrite) a bootable usb stick from an existing iso (loopback) image under linux.

classic way diskdump (dd)

Find correct usb device file 

First we had to find correct linux device file for your plugged/connected usb flash (e.g. lsblk):

  lsblk --list --fs ; lsusb -v ; lshw ; hal-device ; dmesg ; echo "..."

or use that (almost) auto usb devive verifying simple shell script:

get_usb_device() {
    local device_path=$1        # such as /dev/sdc
    for devlink in /dev/disk/by-id/usb*; do
        if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
            # echo "$device_path" is usb device 
			# echo "$(lsblk -no NAME,FSTYPE,SIZE,STATE,OWNER,TYPE,MOUNTPOINT,LABEL,MODEL "$device_path")
			echo Fetching detailed information for usb device "$device_path" by 'hdparm -I "$device_path"'
			echo -en "$(hdparm -I "$device_path") \n\n"
			echo use cache size as base for block size in disk dumnp later 'bs=...'

			return 0
        fi
    done
	
	echo "$device_path" is not an usb device
    return 1
}

  REMOVABLE_DRIVES=""
  for _device in /sys/block/*/device; do
      if echo $(readlink -f "$_device")|egrep -q "usb"; then
          _disk=$(echo "$_device" | cut -f4 -d/)
          REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
      fi
  done
 
  for _usbdevice in "$REMOVABLE_DRIVES"; do

    if get_usb_device "$_usbdevice"; then
      echo "# use following code to create your bootable usb stick: "
      echo sudo umount -l "$_usbdevice" ; sudo dd if="$HOME"/'path_to_your_image.iso' of="$_usbdevice" bs=4K && sync
      echo "# correct bs (block size) by cache size of usb device! "
    else
      echo failed verifying usb by executing command: get_usb_device "$_usbdevice"
    fi
  done

Flash your iso image to usb device file with dd

Finally use linux disk dump (dd) for creating image.

  sudo umount -l  /dev/usb_device_to_flash ; sudo dd if=path_to_your_iso_image of=usb_device_to_flash bs=block_size_based_on_devive_cache && sync ; 
  # default block site always are any factors of 4K

Advanced tools like Usbimager or WoeUSB

Using more advanced graphical tools such as usbimager or WoeUSB to create bootable USB flash stick.


Keine Kommentare:

Kommentar veröffentlichen