Mount or open disk I backed up with dd

1

I used the command dd in order to generate a full copy of a disk (a SD card). Now I'm trying to retrieve the information that was stored in there, but I don't know how to read the contents of the file. I used the comand dd if=/dev/mmcblk0 of=/home/user/devmmcblk0.img bs=1M to generate the file. The SD card is 16GB and so is the file, as ubuntu reports. The format of the file was fat32. I used the following command to install it: mount -t vfat /home/user/devmmcblk0 /mnt but it says fstype incorrect, incorrect option, wrong superblock in /dev/loop0. also I tried to install some linux in virtualbox and add the image file as secondary disk, but it won't let virtualbox mount it, giving the following error

Código Resultado: 
VBOX_E_IPRT_ERROR (0x80BB0005)
Componente: 
Medium
Interfaz: 
IMedium {05f2bbb6-a3a6-4fb9-9b49-6d0dda7142ac}
Receptor: 
IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
Receptor RC: 
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

Any help in regards of recovering the information will be highly appreciated.

EDIT I've been asked the output of several commands so I'll add them here for everyone to see

  • file -s devmmcblk0.img: devmmcblk0.img: x86 boot sector
  • mount -t vfat -o ro,loop /home/user/devmmcblk0 /mnt: mount: wrong fs type, bad option, bad superblock on /dev/loop0
  • fdisk -lu devmmcblk0.img:

    Disk devmmcblk0.img: 16.0 GB, 16003891200 bytes 255 heads, 63 sectors/track, 1945 cylinders, total 31257600 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 Disk identifier: 0x00000000

     Device Boot      Start         End      Blocks   Id  System
    devmmcblk0.img1            8192    31257599    15624704    c  W95 FAT32 (LBA)
    
linux
ubuntu
virtualbox
mount
dd
asked on Super User May 13, 2016 by mrbolichi • edited May 13, 2016 by mrbolichi

3 Answers

0

Update: please try with readonly option this time,

sudo mount -t vfat -o ro,loop /home/user/devmmcblk0 /mnt

Update2:

Seeing all the obstacles when dealing with the loopback device manually, perhaps you may want to try a higher level approach? Please see if

sudo testdisk devmmcblk0.img

gives any good news

Update3:

It is likely to be an exfat formatted partition that requires exfat-fuse and exfat-utils for proper mount.

answered on Super User May 13, 2016 by hkdtam • edited May 18, 2016 by hkdtam
0

You should mount the partition, it starts with an offset inside your file.

sudo mount -o offset=$((512*8192)),ro,loop -t vfat /home/user/devmmcblk0.img /mnt

Notes:

  • loop may not be necessary.

  • 512 is sector size as reported by fdisk.

  • 8192 is the start sector.

Your image covers whole SD card; it's similar to (e.g.) /dev/sdb. If it was SD card, then there would be /dev/sdb1 available to mount. Mounting sdb1 would be mounting sdb with appropriate offset automagically. With image file there is no such magic – you have no special devmmcblk0.img1. It is possible to create such a file by hand, yet cumbersome and not really necessary (edit: kpartx in KevinB's answer does that). The easiest way is to pass the right offset to mount command.

answered on Super User May 13, 2016 by Kamil Maciorowski • edited May 13, 2016 by Kamil Maciorowski
0

kpartx is also an option. From a website on the internet:

# kpartx -l gothbook.img
loop1p1 : 0 512000 /dev/loop1 63
loop1p2 : 0 512000 /dev/loop1 512063
loop1p3 : 0 45056000 /dev/loop1 1024063
loop1p5 : 0 8388608 /dev/loop1 46090548
loop1p6 : 0 39070017 /dev/loop1 54492543
loop1p7 : 0 62733762 /dev/loop1 93562623

I can see from the output of kpartx that my drive image contains 6 partitions. I can see their starting offsets. The first column tells me the names of the device files that will be created if I choose to add these device partitions. Lets add them now.

# kpartx -a -v gothbook.img
add map loop1p1 (253:6): 0 512000 linear /dev/loop1 63
add map loop1p2 (253:7): 0 512000 linear /dev/loop1 512063
add map loop1p3 (253:8): 0 45056000 linear /dev/loop1 1024063
add map loop1p5 (253:9): 0 8388608 linear /dev/loop1 46090548
add map loop1p6 (253:10): 0 39070017 linear /dev/loop1 54492543
add map loop1p7 (253:11): 0 62733762 linear /dev/loop1 93562623

# ls -l /dev/mapper
total 0
crw-rw---- 1 root root  10, 62 2010-06-15 17:40 control
brw-rw-r-- 1 neil neil 253,  6 2010-08-16 00:28 loop1p1
brw-rw-r-- 1 neil neil 253,  7 2010-08-16 00:28 loop1p2
brw-rw-r-- 1 neil neil 253,  8 2010-08-16 00:28 loop1p3
brw-rw-r-- 1 neil neil 253,  9 2010-08-16 00:28 loop1p5
brw-rw-r-- 1 neil neil 253, 10 2010-08-16 00:28 loop1p6
brw-rw-r-- 1 neil neil 253, 11 2010-08-16 00:28 loop1p7

The preceeding command added six device map files to /dev/mapper. Each of these device files corresponds to a partition from that hard drive image. We can now use these device files to mount these partitions and access any files they contain. I want to mount the fifth partition (/dev/mapper/loop1p6) and have a look at its files.

# mkdir /mnt/sysimage
# mount /dev/mapper/loop1p6 /mnt/sysimage
# ls /mnt/sysimage
bin    dev   initrd.img      lost+found  opt   sbin     sys  var
boot   etc   initrd.img.old  media       proc  selinux  tmp  vmlinuz
cdrom  home  lib             mnt         root  srv      usr  vmlinuz.old

After mounting the device file, you can access the files contained on that partition. When you are done, don’t forget to umount the partition and disconnect the device map files using kpartx. # umount /mnt/sysimage # kpartx -d -v gothbook.img

answered on Super User May 13, 2016 by KevinB

User contributions licensed under CC BY-SA 3.0