Tuesday, 20 November 2012

LINUX LVM Step by Step

## Make partitions with parted tool
root@localhot# parted /dev/sdb

mkpart primary 1 4GB

mkpart primary 4GB 8GB

mkpart primary 8GB 12GB


## Optional 3 steps if you want to create extended and logical partitions
mkpart extended 4GB 12GB

mkpart logical 4GB 8GB

mkpart logical 8GB 12GB
##

set 1 lvm on

set 2 lvm on

set 3 lvm on

parted)quit

## Format drives with ext4 file system
mke2fs -t ext4 -j /dev/sdb1

mke2fs -t ext4 -j /dev/sdb2

mke2fs -t ext4 -j /dev/sdb3

## Step by setp LVM
1. pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3

2. vgcreate volgroupvar /dev/sdb1 /dev/sdb2 /dev/sdb3


## optional to extend volume group adding new drive
follow parted for partition and then pv create and below
vgextend volgroupvar /dev/sdc1



3. lvcreate -L 5GB volgroupvar


## To resize the logical volume

lvextend -L +2GB /dev/volgroupvar/lvol0

lvreduce -L -2GB /dev/volgroupvar/lvol0


lvresize -L 4GB /dev/volgroupvar/lvol0

resize2fs /dev/volgroupvar/lvol0 4G


## to rename the volume group and Logical volume
vgrename volgroupvar volgroupopt

lvrename /dev/volgroupvar/lvol0 lvolopt 

No comments:

Post a Comment