Score:2

Use img file as block device

ph flag

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?

Score:2
zw flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.