Adding Logical volume

 Create Logical Volume

#ff0000;">we have new

#ff0000;">/dev/sdb drive

#ff0000;">now we will be creating different partitions and creating volume groups and logical volumes and mount it to the directory


  • check /dev/sdb with the following command
[root@rhce1 ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0
  • now create a partion called /dev/sdb1 of size  1G (1024Mb)
[root@rhce1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf0881c67.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended tovg, volume group, 
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +1G

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0881c67

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          128        8001   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


[root@rhce1 ~]# partprobe
  • Now create physical volume with /dev/sdb1
[root@rhce1 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

[root@rhce1 ~]# pvs
  PV         VG   Fmt  Attr PSize PFree
 /dev/sdb1        lvm2 a--  1004.03m 1004.03m
  • Now create  a volume group     [you need to add volume group on top of physical volume, so put the name of physical volume that u want to create volume group in. u could also add multiple physical volume]

[eg: vgcreate appvg /dev/sdb1 /dev/sdb2]

[root@rhce1 ~]# vgcreate appvg /dev/sdb1
  Volume group "appvg" successfully created
[root@rhce1 ~]# vgs
  VG    #PV #LV #SN Attr   VSize    VFree
  appvg   1   0   0 wz--n- 1000.00m 1000.00m
  sysvg   1   6   0 wz--n-   67.75g   56.75g
  •  we will be creating 200 mb logical volume
[root@rhce1 ~]# lvcreate -L 200M -n testlv appvg
  Logical volume "testlv" created
[root@rhce1 ~]# lvs
  LV         VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  testlv     appvg -wi-a----- 200.00m
  homelv     sysvg -wi-ao----   2.00g
  optlv      sysvg -wi-ao----   1.00g
  tmplv      sysvg -wi-ao----   1.00g
  usrlocallv sysvg -wi-ao----   1.00g
  usrlv      sysvg -wi-ao----   4.00g
  varlv      sysvg -wi-ao----   2.00g


  • Now format the logical volume to EXT4
[root@rhce1 ~]# mkfs.ext4 /dev/appvg/testlv
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


  •  Make directory where yoou want to mount
[root@rhce1 ~]# mkdir /test


  •  now open /etc/fstab
vi /etc/fstab
  • and add mount path to fstab file to make mount permanent, if u want to mount temp then u can use mount command, but if u want it permanently then add it to fstab
/dev/mapper/appvg-testlv        /test                ext4    defaults        1 2

To check what is /etc/fstab and what format this file uses click this link

  • now mount
[root@rhce1 ~]# mount -a
[root@rhce1 ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda2                     9.9G  457M  8.9G   5% /
tmpfs                         1.6G  168K  1.6G   1% /dev/shm
/dev/sda1                     248M   34M  202M  15% /boot
/dev/mapper/sysvg-homelv      2.0G   68M  1.9G   4% /home
/dev/mapper/sysvg-optlv      1008M  494M  464M  52% /opt
/dev/mapper/sysvg-tmplv      1008M  507M  451M  53% /tmp
/dev/mapper/sysvg-usrlv       4.0G  3.0G  790M  80% /usr
/dev/mapper/sysvg-usrlocallv 1008M   34M  924M   4% /usr/local
/dev/mapper/sysvg-varlv       2.0G  378M  1.5G  20% /var
/dev/mapper/appvg-testlv      194M  5.6M  179M   4% /test


PS[if you just want to mount it temp the u can use this command


mount -t ext4 /dev/appvg/testlv /test

removing pv,vg,lv and partition < click here

Increasing logical volume and increasing volume group

create a new partition and filesystem