Beruflich Dokumente
Kultur Dokumente
Now a day every Server needs more space for day to day requirement for that we need
to extend depending on our needs.
LVM is a method of allocating hard drive space into logical volumes that can be easily
resized as we wish instead of partitions and makes it easier to manage disk space. With
LVM the hard drives (or) set of hard drives are converted into one or more physical
volumes. The physical volumes are combined into volume groups. Each volume group is
divided into logical volumes which are assigned to mountpoints such as /home and
filesystem types such as ext3 or ext4 or xfs
While using logical volumes we can extend across multiple disks, logical volumes or
reduce logical volumes in size without reformatting and re-partitioning the current disk.
Volumes can stripes data across multiple disks this can increase the I/O stats.
LVM Features
It is flexible to expand the space at any time.
Any file systems can be installed and handle.
Migration can be used to recover faulty disk without data loss.
Restore the file system using Snapshot features to earlier stage. etc..
To configure LVM
1) Create LVM enable partitions
2) Convert them as physical volumes
3) Create volume groups from physical volumes
4) Create logical volumes from volume groups and assign mountpoints
Output:
VG Name A Volume Group name.
Format LVM Architecture Used LVM2.
VG Access Volume Group is in Read and Write and ready to use.
VG Status VG can be re-sized, we can expand more if we need more space.
Cur LV Currently created Logical volumes in this Volume Group.
CurPV and Act PV Currently using Physical Disk and its active, so what we can
use this volume group.
PE Size Physical Extends. Size for a disk can be defined using PE or GB size,
4MB is the Default PE size of LVM. For example, if we need to create 5 GB size of
logical volume we can use sum of 1280 PE, i.e 5G/4
Total PE This Volume Group have.
Alloc PE Total PE Used, full PE already Used
Free PE
Permanent Mounting
Its now temporarily mounted, for permanent mount we need to add the entry in fstab,
for that let us get the mount entry from mtab using
#cat /etc/mtab
We need to make slight changes in fstab entry while entering the mount entry contents
copies from mtab; we need to change the rw to defaults
#vim /etc/fstab
Our fstab Entry want to be similar to below sample. Save and exit from fstab using wq!.
/dev/mapper/vg1 /vinuthna ext4 defaults 0 0
Note: Execute the below command to check for the fstab entry systax errors.
#mount -av
To remove an LVM
#umount <mountpoint>
#lvremove <logical volume>
Ex: #lvremove /dev/vg1/lv1
LVM Snapshots are space efficient pointing time copies of lvm volumes. It works only
with lvm and consumes the space only when changes are made to the source logical
volume to snapshot volume. If source volume has a huge changes made to sum of 1GB
the same changes will be made to the snapshot volume. Its best to always have a small
size of changes for space efficient. In case the snapshot runs out of storage, we can use
lvextend to grow. And if we need to shrink the snapshot we can use lvreduce.
A&N Teck Solutions 4
Suresh Reddy (RHCE,RHCSS,CCNA)
suresh.emb@gmail.com
If we have accidentally deleted any file after creating a Snapshot we dont have to worry
because the snapshot has the original file which we have deleted. It is possible if the file
was there when the snapshot was created. Dont alter the snapshot volume; keep as it
while snapshot used to do a fast recovery.
Snapshots cant be use for backup option. Backups are Primary Copy of some datas, so
we cant use snapshot as a backup option.
First, check for free space in volume group to create a new snapshot.
#vgs
Note: when copy more than 500MB of files in lv_vinuthna, you will get error message like
Input/output error, it means out of space in snapshot. If the logical volume becomes full it will
get dropped automatically and we cant use it any more, even though if we extend the size of
snapshot volume. It is the best idea to crate a snapshot with same size of source volume. So it
will never over flow, because it has enough space to take snap of your volume.
To verify the new size and COW table using following command.
#lvdisplay /dev/vg1/vinuthna_data_snap
#lvs
# umount /mnt/lv_vinuthna/
Note: After merge is completed, snapshot volume will be removed automatically. Now
we can see the space of our partition using df command.
# df -Th
# lvs
Open the lvm configuration file and Search for word autoextend
#vim /etc/lvm/lvm.conf
Change the auto extend threshold value 100 to 75 here and auto extend percent is 20. If
the snapshot volume reach 75% it will automatically expand the size of snap volume by
20% more. Thus, we can expand automatically. Save and exit.