Use img file as block device

Tags:

Answer: 1

4 hours ago

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?

Added by: Damion O'Keefe II

Answer: 2

12 hours ago

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.

Added by: Dr. Cooper Boyer

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9