[clue-tech] How do I mount a partition on a RAID array?
Jim Ockers
ockers at ockers.net
Thu Aug 30 11:45:57 MDT 2007
Hi everyone,
Top-posting since I am answering my own post. :) I figured it out. For the
following partition table (where /dev/hdx is a symlink to /dev/md2):
Device Boot Start End Blocks Id System
/dev/hdx1 * 1 26625 106498 83 Linux
/dev/hdx2 26626 1860866 7336964 83 Linux
/dev/hdx3 1860867 2385155 2097156 83 Linux
/dev/hdx4 2385156 33554431 124677104 f W95 Ext'd (LBA)
/dev/hdx5 2385156 2647300 1048578 82 Linux swap / Solaris
/dev/hdx6 2647301 2909445 1048578 83 Linux
/dev/hdx7 2909446 3171590 1048578 83 Linux
/dev/hdx8 3171591 33554431 121531362 83 Linux
The following will work:
#!/bin/bash
#skip offset based on end block of previous partition
losetup -o2048 /dev/loop1 /dev/md2 #skip 1st 2048 bytes
losetup -o109056000 /dev/loop2 /dev/md2 #26625*4096
losetup -o7622107136 /dev/loop3 /dev/md2 #1860866*4096
#extended partition adds 2048 bytes for partition table
losetup -o10843342848 /dev/loop6 /dev/md2 #2647300*4096 + 2048
losetup -o11917088768 /dev/loop7 /dev/md2 #2909445*4096 + 2048
losetup -o12990834688 /dev/loop0 /dev/md2 #3171590*4096 + 2048
mount -t ext3 /dev/loop2 /home/ockers/sandbox
mount -t ext2 /dev/loop1 /home/ockers/sandbox/boot
mount -t ext3 /dev/loop3 /home/ockers/sandbox/opt
mount -t ext3 /dev/loop6 /home/ockers/sandbox/opt/data
mount -t ext3 /dev/loop7 /home/ockers/sandbox/tmp
mount -t ext3 /dev/loop0 /home/ockers/sandbox/home
There's no /dev/loop8 and so I had to deviate from the usual partition
naming scheme and call it loop0. I tried making a /dev/loop8 but the
loop driver didn't like it.
It helped to know that the ext[23] magic filesystem number is at 0x438 and
is 53ef, for figuring out what the offset should be.
By the way I think running everything through the loop block device driver
makes it slow and kind of negates the effect of having a super fast RAID
array under the hood. Better to just use the RAID array directly and not
through some abstraction like loop or vmware.
I hope this helps someone,
Jim
--
Jim Ockers, P.Eng. (ockers at ockers.net)
Contact info: please see http://www.ockers.net/
Jim Ockers wrote:
>
> Hi everyone,
>
> I'm trying to save myself several hours of waiting and I thought I'd
> ask the audience for some ideas. How can I mount a RAID partition?
> What I want to do is something like this:
>
> mount -t ext2 /dev/md0p1 /mnt/whatever
>
> There are no major and minor numbers for partitions on RAID arrays,
> because the numbering for md devices is as follows:
>
> [root at dmurray-lnx1 sandbox]# ls -al /dev/md[0123]
> brw-r----- 1 root disk 9, 0 Aug 28 11:39 /dev/md0
> brw-r----- 1 root disk 9, 1 Aug 28 11:39 /dev/md1
> brwxrwxrwx 1 root disk 9, 2 Aug 29 13:14 /dev/md2
> brw-r----- 1 root disk 9, 3 Aug 28 11:51 /dev/md3
>
> So I can't make a block device 9,1 for the first partition on /dev/md0
> because that points to the /dev/md1 RAID array.
>
> How did I get a RAID array with partitions on it, you ask?
>
> I used vmware (patched) to access the Linux RAID array. CentOS5 is
> the VMware host OS, and Red Hat 7.2 is the guest OS. The vmware
> patches in vmgpd (http://mahadri.drigon.com/vmgbd/vmgbd-0.01.tar.bz2)
> let you pretend a RAID array is an IDE disk, so I called /dev/md0
> /dev/hdx for vmware's purposes.
>
> Vmware let the guest OS create 'partitions' on the RAID array just
> as if it was an IDE disk. I.e. /dev/hdx1, /dev/hdx2, and so forth.
>
> [root at dmurray-lnx1 sandbox]# fdisk -l /dev/hdx
>
> Disk /dev/hdx: 177.6 GB, 177682251776 bytes
> 2 heads, 4 sectors/track, 43379456 cylinders
> Units = cylinders of 8 * 512 = 4096 bytes
>
> Device Boot Start End Blocks Id System
> /dev/hdx1 * 1 26625 106498 83 Linux
> /dev/hdx2 26626 1860866 7336964 83 Linux
> /dev/hdx3 1860867 2385155 2097156 83 Linux
> /dev/hdx4 2385156 33554431 124677104 f W95 Ext'd (LBA)
> /dev/hdx5 2385156 2647300 1048578 82 Linux swap / Solaris
> /dev/hdx6 2647301 2909445 1048578 83 Linux
> /dev/hdx7 2909446 3171590 1048578 83 Linux
> /dev/hdx8 3171591 33554431 121531362 83 Linux
>
> Of course the /dev/hdx does not exist because the IDE driver does not
> support the RAID array, so I can't use IDE ioctls to mount the partitions.
> That is, the IDE major & minor numbers won't work, because it's actually
> a RAID array.
>
> Disk /dev/md0: 177.6 GB, 177682251776 bytes
> 2 heads, 4 sectors/track, 43379456 cylinders
> Units = cylinders of 8 * 512 = 4096 bytes
>
> Device Boot Start End Blocks Id System
> /dev/md0p1 * 1 26625 106498 83 Linux
> /dev/md0p2 26626 1860866 7336964 83 Linux
> /dev/md0p3 1860867 2385155 2097156 83 Linux
> /dev/md0p4 2385156 33554431 124677104 f W95 Ext'd (LBA)
> /dev/md0p5 2385156 2647300 1048578 82 Linux swap / Solaris
> /dev/md0p6 2647301 2909445 1048578 83 Linux
> /dev/md0p7 2909446 3171590 1048578 83 Linux
> /dev/md0p8 3171591 33554431 121531362 83 Linux
>
> It seems mount() wants a major & minor number for the filesystem. How
> can I do this, any ideas anyone? Can I use losetup or something like that
> to make a fictitious "device" with legitimate major & minor numbers so
> I can mount() it?
>
> Yes I do need to mount the partitions on the host OS when vmware and the
> guest OS is not running. This will save me hours of copying stuff around.
>
> Thanks for any ideas,
> Jim
>
> --
> Jim Ockers, P.Eng. (ockers at ockers.net)
> Contact info: please see http://www.ockers.net/
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech
>
More information about the clue-tech
mailing list