Setting up Logical Volumes with LVM: Difference between revisions

From Alpine Linux
Line 17: Line 17:
If we later need more space we can add additional physcal volumes with ''vgextend''. All physcal disks/partitions added need to be prepared with ''pvcreate''.
If we later need more space we can add additional physcal volumes with ''vgextend''. All physcal disks/partitions added need to be prepared with ''pvcreate''.


In the volume group we can create logical volumes. To create a volume called ''vservers'' with size 60G on the volume group ''vg0'' we run
In the volume group we can create logical volumes. To create a 1GB volume called ''swap'' and a 7G volume called 'vservers'' on the volume group ''vg0'' we run
  lvcreate -n vservers -L 60G vg0
lvcreate -n swap -L 1G vg0
  lvcreate -n vservers -L 7G vg0


This volume shows up as ''/dev/vg0/vservers'' and can be used as device for mounting. (You will need to create a filesystem first)
This volume shows up as ''/dev/vg0/vservers'' and can be used as device for mounting. (You will need to create a filesystem first)

Revision as of 12:14, 17 October 2007

This document how to create logical volumes in Alpine using lvm2.

LVM is collection of programs that allow larger physical disks to be reassembled into "logical" disks that can be shrunk or expanded as data needs change.

In this document we will use a software raid1 device as physical storage for our logical volumes. We will set up a swap partition and a data partition for vservers

installing LVM software

apk_add lvm2

Preparing the physical volumes

First we need to tell LVM that de partition is available as a physical volume and can be added to a volume group. In this example we use a software raid array as physical volume.

pvcreate /dev/md0

Preparing the Volume Group

We can then create a volume group and add the physical volume /dev/md0

vgcreate vg0 /dev/md0

If we later need more space we can add additional physcal volumes with vgextend. All physcal disks/partitions added need to be prepared with pvcreate.

In the volume group we can create logical volumes. To create a 1GB volume called swap and a 7G volume called 'vservers on the volume group vg0 we run

lvcreate -n swap -L 1G vg0
lvcreate -n vservers -L 7G vg0

This volume shows up as /dev/vg0/vservers and can be used as device for mounting. (You will need to create a filesystem first)