How to Configure LVM in AWS Redhat 7 in Aws EC2 Instance











[root@bhandari ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
ââxvda1 202:1 0 1M 0 part
ââxvda2 202:2 0 10G 0 part /
[root@bhandari ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 10G 979M 9.1G 10% /
devtmpfs 477M 0 477M 0% /dev
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 496M 13M 483M 3% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000
[root@bhandari~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
# Start End Size Type Name
1 2048 4095 1M BIOS boot parti
2 4096 20971486 10G Microsoft basic

Attach the Volume in AWS in Volumes table :--


Now the Two more volumes follow the above stop in aws.
[root@bhandari ~]# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  10G  0 disk
ââxvda1 202:1    0   1M  0 part
ââxvda2 202:2    0  10G  0 part /
xvdf    202:80   0  10G  0 disk
xvdg    202:96   0  10G  0 disk
xvdh    202:112  0  10G  0 disk
[root@bhandari~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
#         Start          End    Size  Type            Name
 1         2048         4095      1M  BIOS boot parti
 2         4096     20971486     10G  Microsoft basic
Disk /dev/xvdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/xvdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/xvdh: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@bhandari ~]# yum install lvm2*

Create the Partition of your attach volume :--

[root@bhandari ~]# fdisk  /dev/xvdg
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xb664198d.

Command (m for help): c
DOS Compatibility flag is set (DEPRECATED!)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (63-20971519, default 63):
Using default value 63
Last sector, +sectors or +size{K,M,G} (63-20971519, default 20971519):
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is set
Command (m for help): p
Disk /dev/xvdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
255 heads, 63 sectors/track, 1305 cylinders
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb664198d

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdg1              63    20971519    10485728+  83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
I am using full partition size you can change as for requirement.
[root@bhandari ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt

#         Start          End    Size  Type            Name
 1         2048         4095      1M  BIOS boot parti
 2         4096     20971486     10G  Microsoft basic

Disk /dev/xvdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb664198d
Device Boot      Start         End      Blocks   Id  System
/dev/xvdg1              63    20971519    10485728+  83  Linux
Disk /dev/xvdh: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x100f53dd
Device Boot      Start         End      Blocks   Id  System
/dev/xvdh1            2048    20971519    10484736   83  Linux
Disk /dev/xvdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe278150f
Device Boot      Start         End      Blocks   Id  System
/dev/xvdf1            2048    20971519    10484736   83  Linux

Now Create Physical Volumes below the command

[root@bhandari~]# pvcreate /dev/xvdg1 /dev/xvdh1 /dev/xvdf1
  Physical volume "/dev/xvdg1" successfully created.
  Physical volume "/dev/xvdh1" successfully created.
  Physical volume "/dev/xvdf1" successfully created.

[root@bhandari~]# pvs
  PV         VG Fmt  Attr PSize  PFree
  /dev/xvdf1    lvm2 ---  10.00g 10.00g
  /dev/xvdg1    lvm2 ---  10.00g 10.00g
  /dev/xvdh1    lvm2 ---  10.00g 10.00g

Total Size fo PV

[root@bhandari ~]# pvscan
  PV /dev/xvdh1                      lvm2 [10.00 GiB]
  PV /dev/xvdf1                      lvm2 [10.00 GiB]
  PV /dev/xvdg1                      lvm2 [10.00 GiB]
  Total: 3 [30.00 GiB] / in use: 0 [0   ] / in no VG: 3 [30.00 GiB]

Create the Volume Group
[root@bhandari ~]# vgcreate lvm_bhandari /dev/xvdh1 /dev/xvdf1 /dev/xvdg1
 Volume group "lvm_bhandari" successfully created

[root@bhandari ~]# vgs
  VG           #PV #LV #SN Attr   VSize  VFree
  lvm_bhandari   3   0   0 wz--n- 29.99g 29.99g
[root@bhandari ~]# vgdisplay
  --- Volume group ---
  VG Name               lvm_bhandari
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               29.99 GiB
  PE Size               4.00 MiB
  Total PE              7677
  Alloc PE / Size       0 / 0
  Free  PE / Size       7677 / 29.99 GiB
  VG UUID               K2QJA8-ekWG-1Y51-voYw-vUjH-RdXy-UkCpvY

And More information in VG
[root@bhandari ~]# vgs -v
  VG           Attr   Ext   #PV #LV #SN VSize  VFree  VG UUID                                VProfile
  lvm_bhandari wz--n- 4.00m   3   0   0 29.99g 29.99g K2QJA8-ekWG-1Y51-voYw-vUjH-RdXy-UkCpvY
If you have particular information VG
[root@bhandari ~]# vgdisplay lvm_bhandari

Create LVM 
[root@bhandari ~]# lvcreate -L 15GB -n bhandari_lvm lvm_bhandari
 Logical volume "bhandari_lvm" created.


Create Mount point and Mount it
[root@bhandari ~]# mkfs.ext4 /dev/lvm_bhandari/bhandari_lvm
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
983040 inodes, 3932160 blocks
196608 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
120 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Mount the LVM  /lvm_dir which I am using :--

[root@bhandari ~]# mkdir /lvm_dir
[root@bhandari ~]# mount /dev/lvm_bhandari/bhandari_lvm /lvm_dir
[root@bhandari ~]# df -h
Filesystem                             Size  Used Avail Use% Mounted on
/dev/xvda2                              10G  1.2G  8.9G  12% /
devtmpfs                               477M     0  477M   0% /dev
tmpfs                                  496M     0  496M   0% /dev/shm
tmpfs                                  496M   13M  483M   3% /run
tmpfs                                  496M     0  496M   0% /sys/fs/cgroup
tmpfs                                  100M     0  100M   0% /run/user/1000
/dev/mapper/lvm_bhandari-bhandari_lvm   15G   41M   14G   1% /lvm_dir

Permanent Mount of Lvm Pertition below the command :--
[root@bhandari ~]# vi /etc/fstab
/dev/mapper/lvm_bhandari-bhandari_lvm  /lvm_dir   ext4 defaults 0 0

Check the fstab file entry  mount -a before restart.

How to Configure LVM in AWS Redhat 7 in Aws EC2 Instance How to Configure LVM in AWS Redhat 7 in Aws EC2 Instance Reviewed by Unknown on October 31, 2017 Rating: 5

No comments:

Scribe

http://feeds.feedburner.com/LinuxAndAws
Powered by Blogger.
X

Get Updates On

Linux Tutorial

AWS Tutorial

Devops Tutorial

We are going to send you our resources for free. To collect your copy at first, join our mailing list. So don't miss any updates, stay connected!