Question: I have an LVM logical volume (LV) and would like to create partitions within this LV to provide an ext3 partition and a swap partition. This LV would then get mounted as a disk to a virtual machine (Using Xen).

How would I go about this?

Thanks

Answer: 
I've just done this to refresh my memory. It's on a RHEL 5.6 system but should work anywhere fairly modern. I've done it a few times and it's been slap-your-forehead simple for me once I learned it:

```
lvcreate -L 100M -n lvVMDisk01 vgSystem
fdisk /dev/vgSystem/lvVMDisk01

```

fdisk throws and error at first:

```
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

```

but you just do a "w" to write the new partition table and exit. Then go back in with fdisk again and create your partitions as you like. Here's what "sfdisk -l" shows after I made a single partition as a demo.

```
sfdisk -l /dev/vgSystem/lvVMDisk01

Disk /dev/vgSystem/lvVMDisk01: 12 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/vgSystem/lvVMDisk01p1          0+      4       5-     40131   83  Linux
/dev/vgSystem/lvVMDisk01p2          0       -       0          0    0  Empty
/dev/vgSystem/lvVMDisk01p3          0       -       0          0    0  Empty
/dev/vgSystem/lvVMDisk01p4          0       -       0          0    0  Empty

```

Best of luck!  

Mike
I'm assuming this is on Linux. Certain distros have GUIs available for doing this, so look at your documentation to see if that's available to you which should simplify things.

Failing that, tools for working with LVMs are `pvcreate`, `vgcreate`, `lvcreate`, `mkfs.ext3` and `mkswap`.

Here's an example of starting from a blank disk:

```
# pvcreate /dev/sdb2
# vgcreate VolGroup01 /dev/sdb2
# lvcreate --name LogVol00 --size ?G VolGroup01
# lvcreate --name LogVol01 --size ?G VolGroup01
# mkfs.ext3 /dev/VolGroup01/LogVol00
# mkswap /dev/VolGroup01/LogVol01

```

Where each `--size ?G` argument is the size of the LVs you'd like to create.