Setting up Logical Volumes with LVM: Difference between revisions

From Alpine Linux
(→‎installing LVM software: installing kernel modules)
Line 4: Line 4:


In this document we will use a [[Setting up a software raid1 array | software raid1 device]] as physical storage for our logical volumes. We will set up a swap partition and a data partition for [[ Setting up a basic vserver | vservers ]]
In this document we will use a [[Setting up a software raid1 array | software raid1 device]] as physical storage for our logical volumes. We will set up a swap partition and a data partition for [[ Setting up a basic vserver | vservers ]]
=== installing LVM software ===
=== Installing LVM software ===
First we need to load the kernel driver, ''dm-mod''
 
modprobe dm-mod
 
We also want it to be loaded during next reboot.
 
echo dm-mod >> /etc/modules
 
We also need the userspace programs.
  apk_add lvm2
  apk_add lvm2



Revision as of 12:16, 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

First we need to load the kernel driver, dm-mod

modprobe dm-mod

We also want it to be loaded during next reboot.

echo dm-mod >> /etc/modules

We also need the userspace programs.

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)