LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2012, 07:05 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,623

Rep: Reputation: 51
Image of a whole disk. Mounting one of its partitions.


Kernel 2.6.21.5, Slackware 12.0

Hi:
I have disk.img, an image of a whole disk, comprising track 0, a FAT32 partition and an ext3 partition. Is it possible to mount one of these partitions? A command like 'mount ./disk.img /mnt -t<some_type> -o loop' will fail, because disk.img should be a filesystem and is not.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-18-2012, 07:20 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Should be doable by using mount ./disk.img /mnt -t<some_type> -o loop,offset=<some uint> where the offset uint could be found from the partition table?
 
Old 02-18-2012, 07:41 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
...else try
Code:
losetup -o $[512*offset] /dev/loopn /path/to/disk.img
or
Code:
kpartx -a /path/to/disk.img
if you don't care mounting all partitions.
 
Old 02-18-2012, 07:42 AM   #4
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 343Reputation: 343Reputation: 343Reputation: 343
Hi there,

Quote:
Originally Posted by catkin View Post
Should be doable by using mount ./disk.img /mnt -t<some_type> -o loop,offset=<some uint> where the offset uint could be found from the partition table?
yes, true - but finding the correct offset is some tedious work. Of course, you could simply try multiples of the sector size (normally 512 bytes) until you get something reasonable.

But, you're right, that information is in the partition table, which is in the very first sector of the disk image. The actual starting sector for the first partition is the DWORD at offset 01C6h, for the second partition at 01D6h (see Explanation for details).
This assumes that you still use traditional partitioning; GPT is a bit more sophisticated.

[X] Doc CPU
 
1 members found this post helpful.
Old 02-18-2012, 11:17 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,623

Original Poster
Rep: Reputation: 51
Thank you all. A little shortsightedness of mine, so many times in mount manual and not having followed the losetup(8) reference!

I did:
Code:
# hexdump -C disk.img   

I got:

offset   id    sec
1C6      0C    0000003F
1D6      83    000234C9

Then

# losetup -f
/dev/loop0
# losetup -o <3F * 512> /dev/loop0 ./disk.img
# losetup -f
/dev/loop1
# losetup -o <234C9 * 512> /dev/loop1 ./disk.img
# 
# mount -tvfat /dev/loop0 /mnt/win
# mount -text3 /dev/loop1 /mnt/lin
EDIT: I reread unSpawn's post and saw the command interpreter can do the math, even in hex.

Last edited by stf92; 02-18-2012 at 11:26 AM.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting an encrypted disk image ismail_ridge_view Linux - Newbie 1 01-25-2012 08:47 AM
Mounting partitions contained within a raw disk image TJNII Linux - General 2 08-22-2011 11:53 AM
Mounting/accessing individual partitions within a dd image? jessica6 Linux - General 5 07-30-2009 06:01 PM
problem mounting a disk image zero79 Debian 2 05-03-2005 03:15 PM
auto mounting of hard disk partitions rm1 Programming 3 11-08-2004 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration