How To Configure LVM on Linux / CentOS / Redhat

ADVERTISEMENT

Page index:
Overview
Setup Physical Volumes
Setup Volume Groups
Setup Logical Volume Group
Extending Volume Group
Extending Logical Volume
Reducing Logical Volume

Page 4 of 7
Logical Volume Creation:

ADVERTISEMENT
Article will continue after the ad

Now we are actually going to the main article. Use of the following command creates the LV called “data” size of 45 GB in the VG (smbserver).

-L – Size in the KB/MB/GB.

-l – Size in PE (Physical Extend 1PE=4MB)

-n – name of the LV

[root@SRV01 ~]# lvcreate -L 45G -n data smbserver

Logical volume “data” created

Scan for Logical Volume.

[root@SRV01 ~]# lvscan

ACTIVE ‘/dev/smbserver/data’ [45.00 GB] inherit

The following command shows the brief details about the LV called (data). You can use the command without second argument (data) that will brief all LV’s in server.

[root@SRV01 ~]# lvdisplay data

— Logical volume —

LV Name /dev/smbserver/data

VG Name smbserver

LV UUID nxVGXD-s3Ke-6Sdo-XSWK-o4ti-ircf-n5Pmum

LV Write Access read/write

LV Status available

# open 0

LV Size 45.00 GB

Current LE 11520

Segments 3

Allocation inherit

Read ahead sectors auto

– currently set to 256

Block device 253:0

Remove for testing purpose.

[root@SRV01 ~]# lvremove data smbserver

Volume group “data” not found

Do you really want to remove active logical volume “data”? [y/n]: y

Logical volume “data” successfully removed

Create it again.

[root@SRV01 ~]# lvcreate -L 45G -n data smbserver

Logical volume “data” created

LV is created, now we have to use the LV for storing the user stuff for that we have to mount the LV on mount point, so we need to format the partition using following command prior to mount.

[root@SRV01 ~]# mke2fs -j /dev/smbserver/data

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

5898240 inodes, 11796480 blocks

589824 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=0

360 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

Create the mount point.

[root@SRV01 ~]# mkdir -p /smbserver/data

Mount it.

[root@SRV01 ~]# mount /dev/smbserver/data /smbserver/data/

Confirm the mounted partition.

[root@SRV01 ~]# mount

/dev/sda3 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda8 on /tmp type ext3 (rw)

/dev/sdb5 on /opt type ext3 (rw)

/dev/sda7 on /home type ext3 (rw)

/dev/sda6 on /var type ext3 (rw)

/dev/sda5 on /usr type ext3 (rw)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sdb6 on /vm type ext3 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

none on /var/lib/xenstored type tmpfs (rw)

/dev/hdc on /media/CentOS_5.3_Final type iso9660 (ro,noexec,nosuid,nodev,uid=0)

/dev/mapper/smbserver-data on /smbserver/data type ext3 (rw)

[root@SRV01 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 965M 467M 449M 51% /

/dev/sda8 5.5G 144M 5.1G 3% /tmp

/dev/sdb5 9.2G 276M 8.5G 4% /opt

/dev/sda7 4.8G 398M 4.1G 9% /home

/dev/sda6 6.2G 1.4G 4.5G 24% /var

/dev/sda5 9.5G 3.3G 5.7G 37% /usr

/dev/sda1 487M 30M 432M 7% /boot

tmpfs 217M 0 217M 0% /dev/shm

/dev/sdb6 11G 155M 9.9G 2% /vm

none 217M 104K 217M 1% /var/lib/xenstored

/dev/hdc 3.7G 3.7G 0 100% /media/CentOS_5.3_Final

/dev/mapper/smbserver-data

45G 181M 42G 1% /smbserver/data

Put on /etc/fstab to automount the partition when system starts.

[root@SRV01 ~]# vi /etc/fstab

LABEL=/ / ext3 defaults 1 1

/dev/sda8 /tmp ext3 defaults 1 2

/dev/sdb5 /opt ext3 defaults 1 2

LABEL=/home /home ext3 defaults 1 2

LABEL=/var /var ext3 defaults 1 2

LABEL=/usr /usr ext3 defaults 1 2

LABEL=/boot /boot ext3 defaults 1 2

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

LABEL=SWAP-sda2 swap swap defaults 0 0

/dev/smbserver/data /smbserver/data ext3 defaults 0 0

/dev/sdb6 /vm ext3 defaults 1 2

Let’s create one more LV using the following command. Use of the following command creates the LV called “backup” size of 10 GB in the VG (smbserver).

[root@SRV01 ~]# lvcreate -L 10G -n backup smbserver

Logical volume “backup” created

Mount new LV using above similar steps.

After creation of two LV. Details of the Volume group (smbserver) will be like below.

[root@SRV01 ~]# vgdisplay smbserver

— Volume group —

VG Name smbserver

System ID

Format lvm2

Metadata Areas 3

Metadata Sequence No 5

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 3

Act PV 3

VG Size 59.98 GB

PE Size 4.00 MB

Total PE 15354

Alloc PE / Size 14080 / 55.00 GB

Free PE / Size 1274 / 4.98 GB

VG UUID qU2OUf-gqKB-B1fd-VBjt-6W7H-tE4z-nt782r

Page 3: Setup Volume Groups

Page 5: Extending Volume Group

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

Shares