04 October 2012

Linux Tip: Mount binary image file


Obtain a binary image

We have to create a image file with a file system on it, and we want to save its content. We do a binary image using:
sajan@sajan-desktop:~$ sudo dd if=/dev/sda1 of=/home/sajan/mySecStore.img

Mount the image file

Get information about the file system of the image file using:
sajan@sajan-desktop:~$ sudo fdisk -l -u /home/sajan/mySecStore.img
give size depends upon your requirement. say eg: 1G
Then setup a loopback block device based on the image:
sajan@sajan-desktop:~$ sudo losetup -o 28672 /dev/loop0 /home/sajan/mySecStore.img

Now you can mount your USB key:
sajan@sajan-desktop:~$ sudo mount /dev/loop0 /mnt/mySecStore/

No comments:

Post a Comment