dd image and how to ... is more a question???-

Hallo every body!!!
Well there is where i'm in troubel...
The begin:
"I read Kyle Rakin's colum about this moths Lightning hacks strike twice, my interes was focus on the dd image over ssh" before this I've heard about dd but I didn't know how wonderfull (and powerfull) it is.
Next step-the do:
I start make a hole dd over my disk to a image file...
dd if=/dev/sda of=/media/paseo/imagen/imagen.img
this works fine but now...
The problem:
The idea is that I want to mount this image...exactly is the root partition for later recover some files for example--like
mount -t ext3 -o loop /media/paseo/imagen/imagen.img /media/net

thet output of the error msg

mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
En algunos casos se encuentra información en syslog, pruebe
dmesg | tail o algo parecido

this is my dmesg |tail

[16563.291016] mtrr: no more MTRRs available
[25143.183670] VFS: Can't find ext3 filesystem on dev loop0.
[27605.632847] VFS: Can't find ext3 filesystem on dev loop0.
[27609.437021] VFS: Can't find ext3 filesystem on dev loop0.
[36690.146233] VFS: Can't find ext3 filesystem on dev loop0.

so I start searching in the inet
this point me at first time to
http://www.linuxquestions.org/questions/linux-general-1/restore-files-fr...

where I extract that I have to type

fdisk -l -u /media/paseo/imagen/imagen.img

the output of this is

Debe establecer cilindros.
Puede efectuar esta operación desde el menú de funciones adicionales.

Disco /media/paseo/imagen/imagen.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, 0 sectores en total
Units = sectores of 1 * 512 = 512 bytes
Disk identifier: 0xb7d8b185

Disposit. Inicio Comienzo Fin Bloques Id Sistema
/media/paseo/imagen/imagen.img1 63 2152709 1076323+ 82 Linux swap / Solaris
/media/paseo/imagen/imagen.img2 2152710 15759764 6803527+ 83 Linux

from this it make me clear that there was two partitions....
AND I want to mount the second yes... my file system...

in this forum the guy Halgeir point me to ---this page http://edseek.com/~jasonb/articles/linux_loopback.html

where I read on....

and at the point where it gets interest for me (at the last page I told about) with the title "Mounting by First Extracting the Partition"

I make exact what this guy tell about (with my image paramaters) and it don't function...

At the end I make a image (alone) of my root partition /dev/sda2 and have after it mounted whithout any problem...!!!

So my question is how can I extract with dd a partition (the exactly parameters or funtions), from a hole image of a disk!!!

Thanks at all.

Do not work

macaal's picture

Hy!
First thanks for your fast reply, Mitch Frazier...
But I've to inform that it don't work!!!
#mount like you tell me with out to extract
mount -o loop,ro,offset=$((2152710*512)) /media/paseo/imagen/imagen.img /media/net/
#The output
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
En algunos casos se encuentra información en syslog, pruebe
dmesg | tail o algo parecido
#The dmesg |tail
dmesg |tail
[15277.904921] EXT3-fs: write access unavailable, cannot proceed.
[15285.188111] EXT3-fs: INFO: recovery required on readonly filesystem.
[15285.188111] EXT3-fs: write access unavailable, cannot proceed.
[15643.599213] VFS: Can't find ext3 filesystem on dev loop0.
[15746.863089] VFS: Can't find ext3 filesystem on dev loop0.
[15761.026594] VFS: Can't find ext3 filesystem on dev loop0.
[15803.577323] VFS: Can't find ext3 filesystem on dev loop0.
[15864.643090] VFS: Can't find ext3 filesystem on dev loop0.
[15947.770446] EXT3-fs: INFO: recovery required on readonly filesystem.
[15947.770446] EXT3-fs: write access unavailable, cannot proceed.

#and doing the extract process
dd if=/media/paseo/imagen/imagen.img of=/media/paseo/imagen/newimagen.img bs=512 skip=2152710 count=6803527
#give me this result when I try to mount it...
mount -o loop /media/paseo/imagen/newimagen.img /media/net/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
En algunos casos se encuentra información en syslog, pruebe
dmesg | tail o algo parecido
#the dmesg of this is...
dmesg |tail
[16232.413789] EXT3-fs: INFO: recovery required on readonly filesystem.
[16232.413789] EXT3-fs: write access unavailable, cannot proceed.
[16416.988757] kjournald starting. Commit interval 5 seconds
[16416.988757] EXT3-fs warning: mounting fs with errors, running e2fsck is recommended
[16416.988757] EXT3 FS on loop0, internal journal
[16416.988757] EXT3-fs: mounted filesystem with ordered data mode.
[16473.681905] attempt to access beyond end of device
[16473.681929] loop0: rw=0, want=6295576, limit=6235897
[16473.681943] JBD: IO error reading journal superblock
[16473.681957] EXT3-fs: error loading journal.
#So I do some research on my own and find out that the extracted image is in size smaller than that, that I make by hand...
#I clear up
dd if=/dev/sda2 of=/media/paseo/imagen/test.img
#The size of this image is...
du -s /media/paseo/imagen/test.img
4194304 /media/paseo/imagen/test.img
#4Gb
#And the size of the extracted image is...
du -s /media/paseo/imagen/newimagen.img
3117952 /media/paseo/imagen/newimagen.img
#I think here is the point of the problem
#The calculation is wrong so I get a wrong size of the image in the two cases (extract and mount)...
#If some one can find out the right calculation... would be nice...and think would be work...!!!
Thanks at all....!!!

Try Using Parted

Mitch Frazier's picture

Try using parted rather than fdisk to display the offsets and sizes of the partitions. Set the units to bytes and then do a print. Take the byte values and divide them by 512, check to see if they match the values that fdisk is telling you.

Mitch Frazier is an Associate Editor for Linux Journal.

Use dd with an offset and count

Mitch Frazier's picture

This should extract the partition from the disk image:

  % dd if=imagen.img of=newimagen.img bs=512 skip=2152710 count=6803527

Then you should be able to mount it with:

  % mount -o loop,ro newimagen.img /media/net

You should also be able to mount it without extracting it with:

  % mount -o loop,ro,offset=$((2152710*512)) imagen.img /media/net

Mitch Frazier is an Associate Editor for Linux Journal.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix