Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mounting a disk image
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
ddc
Guru
Guru


Joined: 29 Aug 2006
Posts: 527

PostPosted: Wed May 07, 2008 6:57 am    Post subject: Mounting a disk image Reply with quote

hi,
what about when we need to mount a disk image ?
off course, the right question is: why would you want to do this ?

Let's me say you have made a a disk image grabbed from a real machine (dd if=/dev/harddisk of=disk-image.raw), and you want to provide your system with a virtual machine (qemu, peralPC ... everything you want) .... well, imagine you have provided your virtual machine with such a disk-image, but you find you want to install some more software on it for your virtual machines (a PPC one, in this example ... but it should be a x86 one)
Last, imagine the real hard was populated by these slice partitions:

mac-fdisk /dev/hdb
# type name length base ( size ) system
/dev/hdb1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/hdb2 Apple_Bootstrap bootstrap 1600 @ 64 (800.0k) NewWorld bootblock
/dev/hdb3 Apple_UNIX_SVR2 gentoo 20971520 @ 1664 ( 10.0G) Unix.ext3
/dev/hdb4 Apple_UNIX_SVR2 my 20971520 @ 20973184 ( 10.0G) Unix.ext3
/dev/hdb5 Apple_UNIX_SVR2 source 8388608 @ 41944704 ( 4.0G) Unix.ext3
/dev/hdb6 Apple_UNIX_SVR2 pipe 204800 @ 50333312 (100.0M) raw
/dev/hdb7 Apple_UNIX_SVR2 swap 1024000 @ 50538112 (500.0M) Unix swap
/dev/hdb8 Apple_HFS macOSX 83886080 @ 51562112 ( 40.0G) HFS
/dev/hdb9 Apple_UNIX_SVR2 services 20919824 @ 135448192 ( 10.0G) Unix.ext3

Now, you have already downloaded the software onto your real system, and you have already grabbed the real disk into his disk-image file, so now you want to transfer it to the disk-imagine.

I think you wanna run your desk as fast as the way you use to transfer the files is to mount the disk image using the loop device. who doesn't want it ?

So the problem is: how to mount an image disk populated by more than one slice partition ?

i mean you should have the following problems to fix

1) If you want access to a hard disk image, you have to calculate the size of the first cylinder.

. This value you need is the offset argument:
. offset = bytes per sector * sectors per cylinder
. I mean a linux command that should looks like this:
. losetup /dev/loop0 disk-image.img -o offset

2) The hard disk image access doesn't work if the image contains more than one partition.
. so what about having 9/10 partitions ?

the same question about when we have a disk-imagine populated by {1..max4} PC partitions ...

how to mount partition from a disk-imagine file ?
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Wed May 07, 2008 7:37 am    Post subject: Reply with quote

Well, you've already found the -o offset option, which I think is the main thing you need for this. Also, you can run fdisk on an image file to list out the partitions. You may wish to use the -u option to fdisk to list sector numbers and avoid all the tedious calculations with cylinders, etc. Most filesystems shouldn't care about extra garbage after the filesystem itself, but if they did, there's nothing preventing you from dd'ing out the partition you want to a separate file, then working with it, and then dd'ing it back into the disk image.

Otherwise, I'm not really sure what you're asking.
Back to top
View user's profile Send private message
ddc
Guru
Guru


Joined: 29 Aug 2006
Posts: 527

PostPosted: Wed May 07, 2008 9:05 am    Post subject: Reply with quote

umm you are suggesting to split a raw image into slices, a slice for each partitions ...
well, we can do it, but personally i don't like very much moving slice down the raw-image and up again into it: this mean doubling the space i need to store the raw-image and his slices, for example ....

.. so i wander if there is a better solution: this is what i am asking here

thank you for the idea about how to get the splice offset ... i think i will read the fdisk source hacking it to have a simply and automatic answer: tool tool of mine, could you look into this file ? tell me only everything i need to note about slices

then including this capability into something can automatize the raw-disk-image mount process
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Wed May 07, 2008 5:55 pm    Post subject: Reply with quote

Well, you only need to split the disk image into separate files if the filesystems don't like seeing extra data after where their filesystem ends. This is because when you use "losetup -o offset", you tell it the start position of the partition, but not the end position.

I don't know of any filesystems that have problems with extra data at the end of the partition, especially any that can be resized (since this is an intermediate state while it's being resized).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum