LVM HOWTO

来源:互联网 发布:oracle删除数据库命令 编辑:程序博客网 时间:2024/05/23 14:09

LVM is a linux storage solution and here is the link for a beginner's howto:


lvm howto


1 LVM Overview

The Linux Logical Volume Manager (LVM) is a mechanism for virtualizing disks. It can create "virtual" disk partitions out of one or more physical hard drives, allowing you to grow, shrink, or move those partitions from drive to drive as your needs change. It also allows you to create larger partitions than you could achieve with a single drive.

LVM can be the back-end storage solution for OpenStack Cinder(Block Storage) and Swift(Object Storage).

2 LVM Layout

Basically LVM looks like this:

Thumbnail, click for full-size image.



3 Show Disk Partitions

Show the partitions of the hard disks:

fdisk -l


4 Create Physical Volumes and Display them

Create the physical volumes on the disk partitions:

pvcreate /dev/sda1 /dev/sdb2 /dev/sdc3

pvdisplay 



5 Create Volume Groups and Other Operations for them

Create a volume group named "filevg" on the physical volumes, then show/rename/remove it:

vgcreate filevg /dev/sda1 /dev/sdb2 /dev/sdc3

vgdisplay 

vgrename filevg datavg

vgscan

vgremove datavg




6 Operations of Logical Volumes

Next we create our logical volumes share (40GB), backup (5GB), and media (1GB) in the volume group fileserver. Together they use a little less than 50% of the available space (that way we can make use of RAID1 later on):

lvcreate --name share --size 40G fileserver

lvcreate --name backup --size 5G fileserver

lvcreate --name media --size 1G fileserver

lvdisplay; lvscan;  lvrename;  lvextend;  lvreduce;


7 Build File Systems and Mount the Logical Volumes

Build three file systems on above created logical volumes:


mkfs.ext3 /dev/fileserver/share

mkfs.xfs /dev/fileserver/backup

mkfs.reiserfs /dev/fileserver/media


Now we are ready to mount our logical volumes. I want to mount share in /var/sharebackup in /var/backup, and media in /var/media, therefore we must create these directories first:

mkdir /var/media /var/backup /var/share

Now we can mount our logical volumes:

mount /dev/fileserver/share /var/share
mount /dev/fileserver/backup /var/backup
mount /dev/fileserver/media /var/media

Now try to use them as normal file systems.