Lvcreate

From LQWiki
Jump to navigation Jump to search

lvcreate is a utility for creating LVM logical partitions inside the volume group specified. An example command is shown:

lvcreate -L10G -nhome vg

In this example we tell the volume, vg, that we want a new "partition" that is 10 GB, and named home. A device will be created in /dev/vg/home that you can treat exactly as you would a hard drive partition (i.e. /dev/hda1).

Workflow

# vgscan
  Reading all physical volumes.  This may take a while...
# vgcreate
  Please provide volume group name and physical volumes
  Run `vgcreate --help' for more information.
# fdisk -l /dev/sda

Disk /dev/sda: 598.8 GB, 598879502336 bytes
255 heads, 63 sectors/track, 72809 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406   83  Linux
/dev/sda2            1276       72809   574596855   8e  Linux LVM
# vgcreate vg /dev/sda2
  No physical volume label read from /dev/sda2
  Physical volume "/dev/sda2" successfully created
  Volume group "vg" successfully created
# lvcreate -L400G -ntst vg
  Logical volume "tst" created
# fdisk -l /dev/vg/tst

Disk /dev/vg/tst: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/vg/tst doesn't contain a valid partition table