LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-30-2009, 10:34 AM   #1
jessica6
LQ Newbie
 
Registered: Feb 2008
Distribution: server=slackware or CentOS; desktop=Suse
Posts: 6

Rep: Reputation: 0
Mounting/accessing individual partitions within a dd image?


I found a thread from 2008.02 regarding this at http://www.linuxquestions.org/questi...-image-618939/ but I will refrain from "necroposting".

When I attempt to follow the instructions:

==
# fdisk -l /media/disk/files.img
Note the device name, start and where it says "512 = n bytes".
If an ext3 partition is /media/disk/files.img2 starting at 660 with n = 8225280 you could 'losetup -o$[660*8225280] /dev/loop0 /media/disk/files.img' and then 'mount /dev/loop0 -t ext3 /mnt/somemountpoint'.
==

I run into some problems. Here's my output:

root@box:/var/misc# fdisk -l image.dd
You must set cylinders.
You can do this from the extra functions menu.

Disk image.dd: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
image.dd1 * 1 22 176683+ 83 Linux
image.dd2 2430 2491 498015 82 Linux swap
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(1023, 254, 63) logical=(2429, 0, 1)
Partition 2 has different physical/logical endings:
phys=(1023, 254, 63) logical=(2490, 254, 63)
image.dd3 23 2429 19334227+ 5 Extended
Partition 3 has different physical/logical endings:
phys=(1023, 254, 63) logical=(2428, 254, 63)
image.dd5 23 508 3903763+ 83 Linux
image.dd6 509 630 979933+ 83 Linux
image.dd7 631 752 979933+ 83 Linux
image.dd8 753 874 979933+ 83 Linux
image.dd9 875 2429 12490506 83 Linux

Partition table entries are not in disk order
root@box:/var/misc#

(I want to access image.dd6, which should be hda6)

root@box:/var/misc# losetup -o$[509*8225280] /dev/loop0 image.dd

root@box:/var/misc# mount /dev/loop0 -t ext2 /mnt2
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

From syslog:
Jul 30 15:21:30 box kernel: VFS: Can't find an ext2 filesystem on dev loop0.

On the running system from which this dd was made, I can verify it is ext2 using cfdisk:

cfdisk 2.12p

Disk Drive: /dev/hda
Size: 20491075584 bytes, 20.4 GB
Heads: 255 Sectors per Track: 63 Cylinders: 2491

Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------
hda1 Boot Primary Linux ext3 180.96
hda5 Logical Linux ext2 3997.49
hda6 Logical Linux ext2 1003.49
hda7 Logical Linux ext2 1003.49
hda8 Logical Linux ext2 1003.49
hda9 Logical Linux ext2 12790.32
hda2 Primary Linux swap 509.97

#

Any help/ideas would be great.

Thanks!
 
Old 07-30-2009, 10:44 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Quote:
(I want to access image.dd6, which should be hda6)

root@box:/var/misc# losetup -o$[509*8225280] /dev/loop0 image.dd

root@box:/var/misc# mount /dev/loop0 -t ext2 /mnt2
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

From syslog:
Jul 30 15:21:30 box kernel: VFS: Can't find an ext2 filesystem on dev loop0.
Is it possible this is as simple as a typo? Note the bold text above; should that not read image.dd6?

Sasha

EDIT - I think I am wrong; I did not fully understand that ALL of the dd# images are INSIDE the image.dd file.

Last edited by GrapefruiTgirl; 07-30-2009 at 10:52 AM. Reason: My mistake -- misread
 
Old 07-30-2009, 11:42 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by jessica6 View Post
I found a thread from 2008.02 (..) I will refrain from "necroposting".
Thanks. So fdisk doesn't recognise the image and therefore mounting the partition fails. I can see two options: 'losetup /dev/loop0 /media/disk/files.img && kpartx -va /dev/loop0 && mount /dev/mapper/loop0p6 /some/mountpoint' or, since there's no tools to adjust BIOS-level representation of disks-on-file* (as far as I know but hey, what do I know) use virtualisation: qemu-img convert the image to VMware VMDK, add it to your VM guest, in the VMware BIOS tweak the C/H/S then boot the guest with a (HELIX or KNOPPIX?) LiveCD/ISO and see if you can mount the partition.

* OK, tools like testdisk accept custom C/H/S but they won't allow you to "export" it as a Live system to use with other tools AFAIK.
 
Old 07-30-2009, 12:25 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
It's not usually necessary to use a separate losetup step. You can add the loop and offset options to your mount command, and it will pass them to losetup and configure a loop device automatically. See the loopback section in "man mount" for more.

Also, in bash at least, arithmetic expansion is now done with the $(()) expression (though it looks like the older $[] still works).

Finally, I believe the number is supposed to be [block size] x [starting block], with block size usually being 512.

So I think your command should be:

Code:
mount -t ext2 -o loop,offset=$((512*509)) /path/to/diskimage /mountpoint
 
Old 07-30-2009, 12:53 PM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
I think the offset is ((509-1)*8225280) + (63*512) = 4178474496.

When you have an image of an entire disk, you need to account for the first track containing the MBR and partition table.
 
Old 07-30-2009, 05:01 PM   #6
jessica6
LQ Newbie
 
Registered: Feb 2008
Distribution: server=slackware or CentOS; desktop=Suse
Posts: 6

Original Poster
Rep: Reputation: 0
Ok, I pieced something together which worked. A single command:

# mount -t ext2 -o loop,offset=$[(509-1)*8225280+63*512] /var/misc/image.dd /mnt2

Thanks everyone!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way of blocking individual programs from accessing the network? TehDooMCat Linux - Networking 7 08-31-2007 02:45 AM
Creating Partitions / image partitions ELEGANCE Linux - General 1 05-17-2006 07:37 AM
Accessing Other Partitions Kul Linux - General 8 01-31-2006 10:08 AM
mounting/accessing windows partitions of dynamic disk jayant chauhan Linux - Hardware 6 04-21-2004 08:47 AM
Mounting Windows NT shared folders for individual users Jake_da_Snake Linux - Networking 6 02-28-2004 02:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration