Create a logical volume using LVM
Content |
Tested on |
Debian (Etch, Lenny, Squeeze) |
Fedora (14) |
Ubuntu (Hardy, Intrepid, Jaunty, Karmic, Lucid, Maverick, Natty) |
Objective
To create a new logical volume within an existing LVM volume group.
Prerequisites
- a working installation of LVM2, and
- an existing LVM volume group with sufficient free space for the new logical volume.
Scenario
Suppose that the new logical volume to be 256 megabytes in size and named foo
. Volume group vg0
has sufficient free space to accommodate it.
Method
Logical volumes are created using the lvcreate
command:
lvcreate --size 256M --name foo /dev/vg0
The volume will be accessible as either /dev/vg0/foo
or /dev/mapper/vg0-foo
. It may be used in much the same way as a hard drive partition.
Testing
Verify the existence of the logical volume using the lvdisplay
command:
lvdisplay /dev/vg0/foo
This should give a response of the form:
--- Logical volume --- LV Name /dev/vg0/foo VG Name vg0 LV UUID afaHxF-nZrA-S1eo-kjsY-mt6C-p04e-IU8Bqu LV Write Access read/write LV Status available # open 0 LV Size 256.00 MB Current LE 64 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:64
Next steps
Having created a new logical volume you may want to:
- create a filesystem on it, or
- use it as a swap device.
Troubleshooting
See Troubleshooting LVM.
See also
Tags: lvm