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).
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
I think you may be confusing terms. Partitions are done on physical disks, you can't partition a logical volume.
With LVM, you have volume groups (made up of physical volumes) that you can further chunk into logical volumes, but if you have all of your space allocated to a single logical volume, you can't further "partition" it. You'd have to shrink your disk, shrink your LV and then create a new logical volume.
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.
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:
fdisk throws and error at first:
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.
Best of luck!
Mike
I think you may be confusing terms. Partitions are done on physical disks, you can't partition a logical volume.
With LVM, you have volume groups (made up of physical volumes) that you can further chunk into logical volumes, but if you have all of your space allocated to a single logical volume, you can't further "partition" it. You'd have to shrink your disk, shrink your LV and then create a new logical volume.
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
andmkswap
.Here's an example of starting from a blank disk:
Where each
--size ?G
argument is the size of the LVs you'd like to create.