WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] bsd disklabel & lvm

Whoops!  I replied, but it only went to Dylan, not the list.  In the
interests of completeness, I repeat my response:

On Fri, 2007-07-20 at 13:04 -0700, Dylan Martin wrote:
> > >Okay, here's another question that no one will be able to answer.
> > >
> > >I have an OpenBSD HVM domU, and I wanted to mount its filesystem in
> > >my Linux dom0.  The domU's disk lives on a logical volume.  Kpartx
> > >does detect that partition 4 contains the disklabel, but that's as far
> > >as I get.
> > >
> > >I think my fedora kernel just doesn't support disklabels...
> > >
> > >Anyone know how this is supposed to work?
> > >  
> > So why use them. Disklabels for ext2 and ext3 are useful abut the 
> > partitions can still be accessed as /dev/hda1, /dev/VolGroup00/whatever, 
> > or if you use "kpartx -a /dev/VolGroup00/whatever" then you can access 
> > /dev/mapper/whatever0, /dev/mapper/whatever1, etc.
> > 
> > Or did you do something too clever and use LVM instide of the OpenBSD 
> > DomU and need to go through extra arcanery?
> 
> I think there is some file system label and disklabel confusion here.
> Disklabel is like fdisk for bsd.. sort of.  In PC hardware when
> running bsd, you first have to partition your disk using fdisk.  If
> you're only running one OS, you just make one partition with all the
> space in it.  Then you take that partition and break it up into
> sub-partitions (for lack of a better word) using disklabel.  I think
> the reason for this has to do with PC hardware vs. other kinds that
> don't use dos-type partition tables.

To clarify, Linux fdisk partitions are called "slices" in BSD.  Inside
each slice, BSD's disklabel splits the slice into up to 8 "partitions".
named "a" through "h".  "a" refers to the root.  "b" is used as swap.
"c" is the "whole" disk.  "d" through "h" can be used for filesystems
such as /usr, /var, etc.

> Anyway, the upshot is that in order for Linux to see my OpenBSD
> partitions, it would have to read the disklabel to know where my
> filesystems are.
> 
> Another way to say it is:
> 
> [dom0          ...]
> [lv           ] 
> [fdisk part   ]
> [disklabel    ]
> [wd0a][wd0d]..

If you have UFS support in your Linux kernel, you can mount these
filesystems.  The trick, however, is in knowing how your disk is laid
out.  You can use Linux' "fdisk" to see this.  Let's assume that this
is the slave drive on your second IDE controller, hence Linux calls it
/dev/hdd.  Bring up fdisk and have it look at /dev/hdd:

        # fdisk /dev/hdd

Do a "p" command to see your partitions as Linux knows them.  Hopefully,
you'll see a partition with an "a5" or "BSD/386" partition ID.  If so,
then you can get fdisk to read the the BSD disklabel info by typing in a
"b" command.  You should then get a "BSD disklabel" prompt.  Type in "p"
again to display the disklabel info.

Now, once you sort out what you want to mount, you need to know how
Linux will refer to the BSD partitions.  This will vary depending on
whether there are any Linux partitions on the drive, as the BSD "a"
partition will show up as the first non-Linux partition, "b" as the
second, "c" as the third, "d" as the fourth and so on.  Some examples:

1. Disk has two Linux partitions (hdd1 and hdd2) and one BSD partition
or "slice" (hdd3).  In this case:

    /dev/hdd1 will be a Linux partition
    /dev/hdd2 will be a Linux partition
    /dev/hdd4 will be the BSD "a" partition
    /dev/hdd5 will be the BSD "b" partition
    /dev/hdd6 will be the BSD "c" partition
    /dev/hdd7 will be the BSD "d" partition

and so on.  Note that /dev/hdd3 is the BSD partition, but you can't
use it for mounts.

2. Disk has one regular Linux partition (hdd1), one Linux extended
partition (hdd2) with two logical partitions (hdd5, hdd6), and one BSD
slice (hdd3).  In this case:

    /dev/hdd1 will be a Linux partition
    /dev/hdd5 will be a Linux partition (first logical in hdd2)
    /dev/hdd6 will be a Linux partition (second logical in hdd2)
    /dev/hdd7 will be the BSD "a" partition
    /dev/hdd8 will be the BSD "b" partition
    /dev/hdd9 will be the BSD "c" partition
    /dev/hdd10 will be the BSD "d" partition

Again, /dev/hdd3 isn't available for mounting as it's the actual BSD
partition.  /dev/hdd2 also isn't available as it's the Linux extended
partition.  /dev/hdd4 doesn't appear since there is no fourth partition
and Linux always starts logical partitions at "5".

3. Disk is a single BSD drive:

    /dev/hdd1 is the BSD "a" partition
    /dev/hdd2 is the BSD "b" partition

and so on.

Hope that makes sense.  To mount, say, the "d" partition from the second
example as /media/bsd-d:

    # mkdir /media/bsd-d
    # mount -t ufs /dev/hdd10 /media/bsd-d

Note that I don't have a BSD drive handy so I can't test this, but it's
what I've done in the past.

The most important thing to remember is that if you have a mixed Linux
and BSD drive, make SURE the BSD partition is AFTER any Linux extended
partitions or you may get wrong partition assignments and screw up
the BSD stuff.  If all you're interested in is getting the data off
the BSD partitions and onto Linux partitions, then mount the BSD stuff
read-only:

    # mount -t ufs -o ro /dev/hdd10 /media/bsd-d

Good luck!
----------------------------------------------------------------------
- Rick Stevens, Principal Engineer             rstevens@xxxxxxxxxxxx -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
- Linux is like a wigwam...no windows, no gates...and apache inside! -
----------------------------------------------------------------------

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users