Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] mounting disk image

37 views
Skip to first unread message

pat

unread,
Apr 6, 2008, 5:10:11 PM4/6/08
to
Hello,

I have a question about mounting disk image as the disk. I have disk image
which was created using:
dd if=/dev/sda of=./file.iso
and the sda contained two partitions sda1 and sda2. I know, that if I have
only image of the sda1 I can mount it using loop device like
#losetup /dev/loop0 file.iso
#mount -t ... /dev/loop0 /mnt/tmp

But, how to do it if the file structure is: sda -> sda1, sda2? I need to get
data from sda1 and sda2 :-|

Thanks a lot for help.

Pat
--
gento...@lists.gentoo.org mailing list

Alan McKinnon

unread,
Apr 6, 2008, 5:20:20 PM4/6/08
to
On Sunday 06 April 2008, pat wrote:
> Hello,
>
> I have a question about mounting disk image as the disk. I have disk
> image which was created using:
> dd if=/dev/sda of=./file.iso
> and the sda contained two partitions sda1 and sda2. I know, that if I
> have only image of the sda1 I can mount it using loop device like
> #losetup /dev/loop0 file.iso
> #mount -t ... /dev/loop0 /mnt/tmp
>
> But, how to do it if the file structure is: sda -> sda1, sda2? I need
> to get data from sda1 and sda2 :-|


losetup -o <offset_value> /dev/loop<something>

see man losetup

--
Alan McKinnon
alan dot mckinnon at gmail dot com

--
gento...@lists.gentoo.org mailing list

Andrey Falko

unread,
Apr 6, 2008, 5:30:18 PM4/6/08
to

I don't have time to test, but try something like this:

(from: http://lwn.net/Articles/110426/)

losetup /dev/loop0 file.iso
blockdev --rereadpt /dev/loop0
mount /dev/loop0p2 /mnt/temp (for p2 replace with other partition,
check ls /sys/block/loop0/dev)
--
gento...@lists.gentoo.org mailing list

pat

unread,
Apr 6, 2008, 6:00:19 PM4/6/08
to
On Sun, 6 Apr 2008 23:16:54 +0200, Alan McKinnon wrote

Thanks. How to count the offset? And where can I get the partitions offsets?

pat

unread,
Apr 6, 2008, 6:00:25 PM4/6/08
to
On Sun, 6 Apr 2008 17:19:33 -0400, Andrey Falko wrote

Thanks, but it ends with:
BLKRRPART: Invalid argument

The problem can be that I did dd at disk with broken partition table. So over
the disk image I've run testdisk utility and it found the partitions - labels
and the correct sizes (as far as I remember). There are two partitions NTFS
and FAT32 and using the testdisk utility, it enables me to browse the FAT
partition, so I thing the testdisk succeeded.

Any idea at that?

Thanks a lot.

pat

unread,
Apr 6, 2008, 6:20:16 PM4/6/08
to
On Mon, 7 Apr 2008 00:07:58 +0200, Alan McKinnon wrote

> On Sunday 06 April 2008, pat wrote:
> > On Sun, 6 Apr 2008 23:16:54 +0200, Alan McKinnon wrote
> >
> > > On Sunday 06 April 2008, pat wrote:
> > > > Hello,
> > > >
> > > > I have a question about mounting disk image as the disk. I have
> > > > disk image which was created using:
> > > > dd if=/dev/sda of=./file.iso
> > > > and the sda contained two partitions sda1 and sda2. I know, that
> > > > if I have only image of the sda1 I can mount it using loop device
> > > > like #losetup /dev/loop0 file.iso
> > > > #mount -t ... /dev/loop0 /mnt/tmp
> > > >
> > > > But, how to do it if the file structure is: sda -> sda1, sda2? I
> > > > need to get data from sda1 and sda2 :-|
> > >
> > > losetup -o <offset_value> /dev/loop<something>
> > >
> > > see man losetup
> >
> > Thanks. How to count the offset? And where can I get the partitions
> > offsets?
>
> Is the original disk still intact? Then fdisk would tell you the offset

>
> --
> Alan McKinnon
> alan dot mckinnon at gmail dot com
>
> --
> gento...@lists.gentoo.org mailing list

Well, yes and no :-( The partition table of the original table has crashed, so
I've created the ISO image of the disk and now playing with it ... but, the
original drive is still untouched. So, I should play with hard drive directly
instead using the dd copy? To partition table recovery in the ISO image I've
used the testdisk utility.

Any suggestions?

Thanks a lot.

Alan McKinnon

unread,
Apr 6, 2008, 6:20:26 PM4/6/08
to
On Sunday 06 April 2008, pat wrote:
> On Sun, 6 Apr 2008 23:16:54 +0200, Alan McKinnon wrote
>
> > On Sunday 06 April 2008, pat wrote:
> > > Hello,
> > >
> > > I have a question about mounting disk image as the disk. I have
> > > disk image which was created using:
> > > dd if=/dev/sda of=./file.iso
> > > and the sda contained two partitions sda1 and sda2. I know, that
> > > if I have only image of the sda1 I can mount it using loop device
> > > like #losetup /dev/loop0 file.iso
> > > #mount -t ... /dev/loop0 /mnt/tmp
> > >
> > > But, how to do it if the file structure is: sda -> sda1, sda2? I
> > > need to get data from sda1 and sda2 :-|
> >
> > losetup -o <offset_value> /dev/loop<something>
> >
> > see man losetup
>
> Thanks. How to count the offset? And where can I get the partitions
> offsets?

Is the original disk still intact? Then fdisk would tell you the offset


Andrey Falko

unread,
Apr 6, 2008, 6:20:34 PM4/6/08
to
On Sun, Apr 6, 2008 at 6:07 PM, Alan McKinnon <alan.m...@gmail.com> wrote:
> On Sunday 06 April 2008, pat wrote:
> > On Sun, 6 Apr 2008 23:16:54 +0200, Alan McKinnon wrote
> >
> > > On Sunday 06 April 2008, pat wrote:
> > > > Hello,
> > > >
> > > > I have a question about mounting disk image as the disk. I have
> > > > disk image which was created using:
> > > > dd if=/dev/sda of=./file.iso
> > > > and the sda contained two partitions sda1 and sda2. I know, that
> > > > if I have only image of the sda1 I can mount it using loop device
> > > > like #losetup /dev/loop0 file.iso
> > > > #mount -t ... /dev/loop0 /mnt/tmp
> > > >
> > > > But, how to do it if the file structure is: sda -> sda1, sda2? I
> > > > need to get data from sda1 and sda2 :-|
> > >
> > > losetup -o <offset_value> /dev/loop<something>
> > >
> > > see man losetup
> >
>
> > Thanks. How to count the offset? And where can I get the partitions
> > offsets?
>
> Is the original disk still intact? Then fdisk would tell you the offset
>
>
>
I'm pretty sure you can fdisk -l test.iso....maybe not, but worth a
try if you don't have the original disk :).

>
> --
> Alan McKinnon
> alan dot mckinnon at gmail dot com
>
> --
> gento...@lists.gentoo.org mailing list
>
>
--
gento...@lists.gentoo.org mailing list

Alan McKinnon

unread,
Apr 6, 2008, 6:30:51 PM4/6/08
to
On Monday 07 April 2008, pat wrote:

> Well, yes and no :-( The partition table of the original table has
> crashed, so I've created the ISO image of the disk and now playing
> with it ... but, the original drive is still untouched. So, I should
> play with hard drive directly instead using the dd copy? To partition
> table recovery in the ISO image I've used the testdisk utility.
>
> Any suggestions?

To be safe I would mount the .iso devices read-only till you are sure
you have found the correct offsets. Only use the original disk if you
really have no other option

pat

unread,
Apr 6, 2008, 6:30:57 PM4/6/08
to
On Sun, 6 Apr 2008 18:18:57 -0400, Andrey Falko wrote

Well, I'm not the low level guru :-) This is the first time I playing with
data/partitions recovery :-\

The fdisk gives me:
Partition 1 has different physical/logical endings:
phys=(1023, 254, 63) logical=(19456, 254, 63)
/mnt/tmp/recovery.dd.2.iso5 16612 19457 22860463+ c W95
FAT32 (LBA)

Which number should I use?

pat

unread,
Apr 6, 2008, 6:40:36 PM4/6/08
to
On Mon, 7 Apr 2008 00:24:55 +0200, Alan McKinnon wrote

OK. Thanks.

Stroller

unread,
Apr 7, 2008, 12:40:08 AM4/7/08
to

On 6 Apr 2008, at 22:03, pat wrote:
> ...

> I have a question about mounting disk image as the disk. I have
> disk image
> which was created using:
> dd if=/dev/sda of=./file.iso
> and the sda contained two partitions sda1 and sda2. I know, that if
> I have
> only image of the sda1 I can mount it using loop device like
> #losetup /dev/loop0 file.iso
> #mount -t ... /dev/loop0 /mnt/tmp
>
> But, how to do it if the file structure is: sda -> sda1, sda2? I
> need to get
> data from sda1 and sda2 :-|

Hi there,

I have a similar disk image I need to access in the same way. I asked
about this on the list a while ago & received some helpful replies.

Unfortunately I got busy with work right after posting, and haven't
had a chance to try them, yet, but maybe you'll find them useful:
http://thread.gmane.org/gmane.linux.gentoo.user/193263

Stroller.
--
gento...@lists.gentoo.org mailing list

David Relson

unread,
Apr 7, 2008, 7:20:09 AM4/7/08
to

On an occasion or two, I've had linux installs overwrite a partition
table when I wasn't paying close occasion. Using google I found
TestDisk which is a program that is able to recover partition tables.
I've used it successfully 2 or 3 times. I've also encountered one
situation where I broke the partition table with dd and TestDisk wasn't
able to help. So, mileage varies :->

David
--
gento...@lists.gentoo.org mailing list

0 new messages