Linux – How to Mount a .bin Image File

binlinuxmount

I used the AWS import service to import a large (2TB) drive, and they dropped two .bin files in my S3 account. Their instructions say to stripe together to EBS volumes to make a drive large enough to hold the image and then to just use that.

Well I've got everything striped and whatnot, but I don't know what to do with this .bin image. Doesn't seem to work with mount, or at least, not without any options, and I don't know what options to put.

>file -k image-NPX7P-0000.bin
image-NPX7P-0000.bin: x86 boot sector; partition 1: ID=0xb, starthead 1, startsector 63, 3907024821 sectors, extended partition table (last)\011, code offset 0x0

>file -k image-NPX7P-0001.bin
image-NPX7P-0001.bin: data

EDIT: I appended the file info, and from the looks of it, I'd assume the reason I can't mount just 0000 is because 0001 is an extension of it (which tracks with how I assume they did this). But how would I merge the two and mount that?

EDIT2: Using osgx's answer, I was able to get the two bin files catted together, and used kpartx to read the partition table.

> file-sk: /dev/dm-2: x86 boot sector, code offset 0x58, OEM-ID "BSD 4.4", sectors/cluster 64, heads 255, sectors 3907024821 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 476816, reserved3 0x1000000, reserved 0x1, serial number 0x5cb415f7, label: "SOURCE-PSE " DOS executable (COM), boot code –

This still will not mount however. It says it requires a filesystem type, and nothing I've used helps. Also posted to a pastebin because it's long is my kernal config of the relevant (maybe) values:

http://pastebin.com/j7iS7RF3

Best Answer

According to file -k, you have a disk image (may be it is splitted into two volumes); the disk image has partition table of one 2TB (39G sectors of 512 = 2TB) and of type FAT32 (0x0b).

Do a cat to concatenate both images into one

cat image*bin > image.iso

OR (carefull! this will modify first file)

cat image*0001* >> image*0000*

Run a kpartx to read partition table over image.iso via loop1 device (now you will need a root; replace image.iso with image*0000* if you did a second way of catting)

losetup /dev/loop1 image.iso; kpartx -av /dev/loop1;

Output will be like add map loop1p1 ...

Then find the loop1p1 in /dev/mapper

ls -l /dev/mapper
file -sk /dev/mapper/*   # finally check that it is a FAT32

And mount it:

mount -o ro -t auto /dev/mapper/loop1p1 /where/to/mount

Work with fs; umount it; run a kpartx -d -v /dev/loop1; ; unmap loop1 with losetup

(manual used http://nfolamp.wordpress.com/2010/08/16/mounting-raw-image-files-and-kpartx/ )