Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mounting raid partition from disk image file.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
snarksdad
n00b
n00b


Joined: 23 Sep 2016
Posts: 19

PostPosted: Tue Oct 18, 2016 5:05 pm    Post subject: mounting raid partition from disk image file. Reply with quote

Fellow Gentooers..

This must be something simple I am just missing.

I have a disk image file I created with dd.
It looks like this:

fdisk -l fred.image.dd

Disk fred.image.dd: 4131 MB, 4131864576 bytes
255 heads, 63 sectors/track, 502 cylinders, total 8070048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00033357

Device Boot Start End Blocks Id System
fred.image.dd1 2048 18431 8192 83 Linux
fred.image.dd2 22528 862207 419840 fd Linux raid autodetect
fred.image.dd3 866304 931839 32768 fd Linux raid autodetect

So I want to mount partition 2, I tried:

mount -o loop,offset=22528 fred.image.dd /mnt/loop

Which results with "mount: you must specify the filesystem type"


When I mount the physical device:
mount /dev/sdd2 /mnt/mydisk
I would get:
mount: unknown filesystem type 'linux_raid_member'

So there I use mdadm to "Assemble" a drive that I can mount:

mdadm -A -R /dev/md9 /dev/sdd2
mdadm: /dev/md9 has been started with 1 drive.

and then:

mount /dev/md9 /mnt/mydrive

Which succeeds and all is good.

So is there an analogous command option from mdadm that "emulates" the offset/assemble when using an image file
or is there some better way to mount this partition from the image file...

Thanks,
Snarksdad
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54244
Location: 56N 3W

PostPosted: Tue Oct 18, 2016 5:30 pm    Post subject: Reply with quote

snarksdad,

The piece of the puzzle you are missing is the raid metadata version.
For metadata version 0.90, the raid metadata is at the end of the volume, so what you are trying to do works.
For metadata version 1.2, the raid metadata is at the start of the partition, where your mount expects the filesystem to start, so this fails.

No matter, on Linux, everything is a file, so
Code:
mdadm -A -R /dev/mdX /path/to/fred.image.dd2
should start mdX just as with the physical drive.
You can then mount mdX in the normal way.

The alternative is to look up the size of of the raid superblock, then use the offset= option to mount, so mount finds the actual start of the filesystem.
This is left as an exercise for the reader

For a read only mount, it doesn't matter much. For a rw mount the first option is preferred as it updates the raid metadata too.

Code:
$ sudo mdadm -E /dev/sda5
Password:
/dev/sda5:
          Magic : a92b4efc
        Version : 0.90.00
   ...

That should work on your image too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
snarksdad
n00b
n00b


Joined: 23 Sep 2016
Posts: 19

PostPosted: Tue Oct 18, 2016 6:26 pm    Post subject: Reply with quote

NeddySeagoon wrote:
snarksdad,

The piece of the puzzle you are missing is the raid metadata version.
For metadata version 0.90, the raid metadata is at the end of the volume, so what you are trying to do works.
For metadata version 1.2, the raid metadata is at the start of the partition, where your mount expects the filesystem to start, so this fails.

No matter, on Linux, everything is a file, so
Code:
mdadm -A -R /dev/mdX /path/to/fred.image.dd2
should start mdX just as with the physical drive.
You can then mount mdX in the normal way.


Hmm. Well I guess I had already tried this:
mdadm -A -R /dev/md9 /root/fred.image.dd2

mdadm: cannot open device /root/fred.image.dd2: No such file or directory
mdadm: /root/fred.image.dd2 has no superblock - assembly aborted

Which I figured meant mdadm is not actually not opening the image file (fred.image.dd)...

So I tried it on the image file itself (hoping mdadm would provide useful feedback):

mdadm -A -R /dev/md9 /root/fred.image.dd

mdadm: /root/fred.image.dd is not a block device.
mdadm: /root/fred.image.dd has no superblock - assembly aborted


Thanks,
Snarksdad
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Tue Oct 18, 2016 6:34 pm    Post subject: Reply with quote

if you have partitions in a file, use `losetup --find --show --partscan file` and you'll get it via /dev/loopXpY which you can then assemble into a RAID and mount.
Back to top
View user's profile Send private message
snarksdad
n00b
n00b


Joined: 23 Sep 2016
Posts: 19

PostPosted: Tue Oct 18, 2016 7:04 pm    Post subject: Reply with quote

frostschutz wrote:
if you have partitions in a file, use `losetup --find --show --partscan file` and you'll get it via /dev/loopXpY which you can then assemble into a RAID and mount.


Not familiar with this command, output not real helpful...

losetup --find --show --partscan fred.image.dd

/dev/loop1

# mount /dev/loop1 /mnt/test
mount: you must specify the filesystem type
root@localhost ~ #

root@localhost ~ # mount -o loop /dev/loop1 /mnt/loop
mount: you must specify the filesystem type

root@localhost ~ #
root@localhost ~ # mdadm -A -R /dev/md9 /dev/loop1
mdadm: Cannot assemble mbr metadata on /dev/loop1
mdadm: /dev/loop1 has no superblock - assembly aborted



What does one do with /dev/loop1?

Thanks,
Snarksdad
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Tue Oct 18, 2016 7:45 pm    Post subject: Reply with quote

there should be partitions ( /dev/loopXpY )

cat /proc/partitions
ls -l /dev/loop*
Back to top
View user's profile Send private message
snarksdad
n00b
n00b


Joined: 23 Sep 2016
Posts: 19

PostPosted: Wed Oct 19, 2016 3:43 pm    Post subject: Reply with quote

frostschutz wrote:
there should be partitions ( /dev/loopXpY )

cat /proc/partitions
ls -l /dev/loop*


Oh. I get it....
mdadm -A -R /dev/md9 /dev/loop1p2

mdadm: /dev/md9 has been started with 1 drive.

mount /dev/md9 /mnt/loop
mount: warning: /mnt/loop seems to be mounted read-only.

That does seem to work....

Thanks!

Snarksdad
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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