Use img file as block device
I created an img
file using dd (sudo dd if=/dev/zero of=/home/danialbehzadi/dong.img bs=1000K count=32
) and now I want it to be used as a block device, so I can restore a filesystem saved by fasrachiver
into it.
I already tried restoring directly to file:
oper_restore.c#152,convert_argv_to_strdicos(): "dong.img" is not a valid block device
and mounting it and restoring there:
oper_restore.c#152,convert_argv_to_strdicos(): "/mnt" is not a valid block device
Is there a way to make it apperad in /dev directrory as a storage device?
You have to configure loopback device by losetup
as follows:
sudo losetup /dev/loop0 ~/dong.img
and then you'll be able to see this image file as a raw disk at /dev/loop0
:
$ sudo fdisk -l /dev/loop0 Disk /dev/loop0: 31.26 MiB, 32768000 bytes, 64000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
To detach device use sudo losetup -d /dev/loop0
.