Create a loop device from a file in Linux

Create file and loop device inside /mnt:

sudo -i
cd /mnt
dd if=/dev/zero of=lbfile bs=1M count=1024
losetup -fP lbfile
Check, create partition and mount:
lsblk
cfdisk /dev/loop0
mkfs.ext4 /dev/loop0p1
mkdir loop
mount /dev/loop0p1 /mnt/loop/
touch /mnt/loop/file.txt
After reboot, you will need to run again:
losetup -fP lbfile
and mount