9

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

UltimateBrent
  • 459
  • 2
  • 7
  • 13

4 Answers4

9

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/ )

osgx
  • 583
  • 11
  • 26
  • I hope you have 6 TB of disk space (2TB for original files; 2TB for image.iso; 2 TB for recovered data). In the similar situation (recover a 2 TB) I had no such disk space and still have no. – osgx Aug 03 '11 at 00:17
  • 1
    Well my genius knows no bounds. I did the second method, thinking I wouldn't need the extra space at least for that part, but didn't think about it catting to the other file and needing 3TB total. So I gotta regrab the files. That'll take a while then I'll post my results. – UltimateBrent Aug 03 '11 at 00:44
  • No dice: losetup /dev/loop1 image-NPX7P-0000.bin; kpartx -av /dev/loop1; /dev/loop1: Permission denied /dev/mapper/control: open failed: Permission denied Failure to communicate with kernel device-mapper driver. device mapper prerequisites not met – UltimateBrent Aug 06 '11 at 00:43
  • you can't mount an image without dev-mapper. Are you root? What is OS? – osgx Aug 06 '11 at 00:50
  • okay, so I did it as root instead of sudo and it worked, don't get that, but whatever. Still won't mount, this is the 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 – UltimateBrent Aug 06 '11 at 00:54
  • `mount -o ro -t vfat /dev/dm-2 /where/to/mount` ? What the error of mount? – osgx Aug 06 '11 at 01:50
  • Gives the wrong fs type error, and dmesg | tail gives: [12418.336620] FAT: IO charset iso8859-1 not found -- I tried utf8 and iso9660, but they didn't work either – UltimateBrent Aug 06 '11 at 04:11
  • Akin It! try to get config of your kernel (e.g /proc/config.gz or /boot/config... ) and grep for "CONFIG_NLS_" "CONFIG_FAT_DEFAULT". Can you reinstall the kernel on this machine? – osgx Aug 06 '11 at 10:43
  • Yeah, I could do whatever, it's just an EC2 machine. I've got the results, but I'm going to post it back into the question with updated progress so the whole thing is here. – UltimateBrent Aug 07 '11 at 08:09
  • 1
    UltimateBrent, ok. try to find nls modules and modprobe them. Can you copy exact dmesg and mount output for `mount -o ro -t vfat /dev/dm-2 /where/to/mount` and `mount -o ro -t auto /dev/dm-2 /where/to/mount ` and `mount -o ro,codepage=850,iocharset=iso8859-1 -t vfat /dev/dm-2 /where/to/mount `. May be you should open new question (community will help faster in mounting a plain fat than me) with your output of `file -sk /dev/dm-2`, mount commands tryed and the dmesg/mount errors reported. – osgx Aug 07 '11 at 09:40
  • K, this is definitely down the rabbit hole, gonna make a new question – UltimateBrent Aug 07 '11 at 19:53
  • http://serverfault.com/questions/298636/unable-to-mount-fat-drive-in-linux – UltimateBrent Aug 07 '11 at 20:04
  • 1
    Thought I would post here to complete the loop. I just ended that ec2 instance and found a suse pre-made that had vfat ready to go, and your mount option worked like a charm. I owe you big time osgx! – UltimateBrent Aug 08 '11 at 05:33
4

Try to mount it with the -o loop option.

ninjalj
  • 255
  • 3
  • 7
2

use bchunk and convert into iso then you can easily mount http://goinggnu.wordpress.com/2007/05/08/howto-mount-bincue-files-in-linux/

hardik
  • 129
  • 3
  • There's no cue file, just the bin – UltimateBrent Jul 30 '11 at 19:34
  • If you have a bin file without cue you can always try creating new text file with this content: FILE “yourbinfilenamehere.bin” BINARY TRACK 01 MODE1/2352 INDEX 01 00:00:00 But I think osgx's solution is the correct answer. – Chris Hasiński Aug 03 '11 at 03:26
2

Convert the file to an ISO and work with it from there. I've used iat (Iso9660 Analyzer Tool) with success.

Install it (under Ubuntu where I live - YMMV):

sudo apt-get install iat

Use it:

iat inputFile.bin > newShiny.iso
FPC
  • 121
  • 2