LOOPDEV=$(losetup -f)
echo "[+] Find free loop device: ${LOOPDEV}"
losetup -P $LOOPDEV $1
echo "[+] Attached $IMGNAME with $LOOPDEV"
mount ${LOOPDEV}p1 /mnt
cp $2 /mnt/$3
umount /mnt
losetup -d $LOOPDEV
