# Pastebin ETP3AQ9d function make_loop() { img="${image_dir}/${image_name}.img" num_parts=$(fdisk -l $img | grep "${img}[1-2]" | wc -l) if [ "$num_parts" = "2" ]; then extra=1 part_type1=$(fdisk -l $img | grep ${img}1 | awk '{print $6}') part_type2=$(fdisk -l $img | grep ${img}2 | awk '{print $6}') if [[ "$part_type1" == "c" ]]; then bootfstype="vfat" elif [[ "$part_type1" == "83" ]]; then bootfstype=${bootfstype:-"$fstype"} fi rootfstype=${rootfstype:-"$fstype"} loopdevice=$(losetup --show -fP "$img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" elif [ "$num_parts" = "1" ]; then part_type1=$(fdisk -l $img | grep ${img}1 | awk '{print $6}') if [[ "$part_type1" == "83" ]]; then rootfstype=${rootfstype:-"$fstype"} fi rootfstype=${rootfstype:-"$fstype"} loopdevice=$(losetup --show -fP "$img") rootp="${loopdevice}p1" fi }