Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Storage Management using LVM

14,034 views

Published on

Storage Management using LVM

Published in: Technology
  • Login to see the comments

Storage Management using LVM

  1. 1. Storage Management using LVM Sandeep Tyagi Persistent Systems
  2. 2. Agenda <ul><li>Q & A </li></ul><ul><li>What is LVM </li></ul><ul><li>Body, Parts and Soul </li></ul><ul><li>How to use LVM on Linux </li></ul><ul><li>[ Some situations & LVM ] </li></ul><ul><li>Discussion </li></ul>
  3. 3. Q & A <ul><li>Q & A </li></ul><ul><li>What is LVM </li></ul><ul><li>Body, Parts and Soul </li></ul><ul><li>How to use LVM on Linux </li></ul><ul><li>Discussion </li></ul>
  4. 4. Some Qs <ul><li>WHAT DO YOU DO IF - </li></ul><ul><li>You have some of your partition filled up and you want to expand it </li></ul><ul><li>You want to shrink your partition </li></ul><ul><li>You have your disk/device filled up and you want to add one more disk/device (You need a single file system spread over multiple disks) </li></ul><ul><li>You want to take backup of your file system/partition while you are still using it </li></ul>
  5. 5. A’s <ul><li>SOME OF THE SOLUTIONS - </li></ul><ul><li>For expansion/shrinking a partition </li></ul><ul><li>Take backup of partition delete and recreate it with desired size (Might need a reboot) and restore the earlier data </li></ul><ul><li>Use a tool like partition magic – Generally needs a reboot </li></ul><ul><li>Create a bigger partition, create file system, copy data of original partition and link the directory mounted on old files system to this new bigger partition </li></ul><ul><li>For having partitions spread over multiple disks/devices </li></ul><ul><li>RAID </li></ul>
  6. 6. Limitations <ul><li>In many cases requires rebooting the system </li></ul><ul><li>Complex/proprietary technology (e.g. RAID volume manager) that requires specific skills for maintenance/management </li></ul><ul><li>What if </li></ul><ul><li>You can’t reboot the system OR </li></ul><ul><li>Don’t have the patience/skills to manage/maintain? </li></ul><ul><li>These solutions look viable options but are they appropriate or perfect? </li></ul>
  7. 7. Answer is NO <ul><li>We need a solution </li></ul><ul><li>That solves most of our problems discussed </li></ul><ul><li>Doesn’t force a reboot all the time </li></ul><ul><li>Doesn’t force a backup all the time </li></ul><ul><li>And so on.. </li></ul>
  8. 8. What is LVM <ul><li>Q & A </li></ul><ul><li>What is LVM </li></ul><ul><li>Body, Parts and Soul </li></ul><ul><li>How to use LVM on Linux </li></ul><ul><li>Discussion </li></ul>
  9. 9. Logical Volume Manager (LVM) <ul><li>Presents a higher level of disk storage </li></ul><ul><li>Provides flexibility in allocating storage </li></ul><ul><li>Facility of resizing file system while the file systems are online (though it needs modification/addition in/of tools) </li></ul><ul><li>Facility to manage storage based on user-defined logical groups </li></ul><ul><li>Easy maintenance </li></ul>
  10. 10. Body, Parts and Soul <ul><li>Q & A </li></ul><ul><li>What is LVM </li></ul><ul><li>Body, Parts and Soul </li></ul><ul><li>How to use LVM on Linux </li></ul><ul><li>Discussion </li></ul>
  11. 11. Body, Parts and Soul <ul><li>Physical Volume </li></ul><ul><li>Volume Group </li></ul><ul><li>Logical Volume </li></ul><ul><li>Physical Extents </li></ul><ul><li>Logical Extents </li></ul><ul><li>Device mapper </li></ul><ul><li>Snapshot </li></ul>
  12. 12. Body, Parts and Soul contd… <ul><li>Physical Volume (PV) is created out of </li></ul><ul><li>Physical Device </li></ul><ul><li>Disk </li></ul><ul><li>Anything that looks like a hard disk </li></ul><ul><li>Volume Group (VG) </li></ul><ul><li>Highest level abstraction in LVM </li></ul><ul><li>Consists of one of more Physical Volumes </li></ul><ul><li>Can contain one or more Logical volumes </li></ul>
  13. 13. Body, Parts and Soul contd… <ul><li>Logical Volume </li></ul><ul><li>Is synonym of Partition </li></ul><ul><li>Basic entity on which you can create file systems </li></ul><ul><li>Extents </li></ul><ul><li>Chunk of bytes such as 1k, 4k or 64k </li></ul>
  14. 14. Body, Parts and Soul contd… <ul><li>Physical Extents </li></ul><ul><li>Each Physical volume is divided in to extents called physical extents </li></ul><ul><li>Are of same size as the Logical extents for the volume group </li></ul><ul><li>Logical Extents </li></ul><ul><li>Each logical volume consists of a number of extents called logical extents </li></ul><ul><li>Extent size for all logical volume in a volume group is same </li></ul>
  15. 15. Body, Parts and Soul contd… <ul><li>Snapshot </li></ul><ul><li>A Read only/Read Write image of Logical Volume </li></ul><ul><li>Device Mapper </li></ul><ul><li>A new component in Linux Kernel that enables use of LVM 2 </li></ul>
  16. 17. Body, Parts and Soul contd… <ul><li>To use LVM on Linux system should have - </li></ul><ul><li>Device mapper in your kernel </li></ul><ul><li>Device mapper support library (libdevmapper) </li></ul><ul><li>User space LVM tools </li></ul>
  17. 18. How to use LVM on Linux <ul><li>Q & A </li></ul><ul><li>What is LVM </li></ul><ul><li>Body, Parts and Soul </li></ul><ul><li>How to use LVM on Linux </li></ul><ul><li>Discussion </li></ul>
  18. 19. How to Use LVM on Linux <ul><li>CREATING A NEW LOGICAL VOLUME </li></ul><ul><li>Create a Physical Volume </li></ul><ul><li>Create a Volume group </li></ul><ul><li>Create a Logical Volume </li></ul><ul><li>EXPANDING A LOGICAL VOLUME </li></ul><ul><li>Create a Physical Volume </li></ul><ul><li>Add it to the Volume Group that have the “target” Logical Volume – in case VG does not have enough space to </li></ul><ul><li>Expand the Logical Volume </li></ul>
  19. 20. Create a Physical Volume <ul><li>1. From one or more partitions </li></ul><ul><li>Mark each of the partition to be used as physical volume for Linux LVM by changing partition system id to 0x8e. This can be done with fdisk (using t option) </li></ul><ul><li>Device Boot Start End Blocks Id System </li></ul><ul><li>/dev/cciss/c0d0p1 * 1 382 3068383+ 83 Linux </li></ul><ul><li>/dev/cciss/c0d0p5 6757 7266 4096543+ 82 Linux swap / Solaris </li></ul><ul><li>/dev/cciss/c0d0p6 7267 19716 100004593+ 8e Linux LVM </li></ul><ul><li>/dev/cciss/c0d0p7 19717 25942 50010313+ 8e Linux LVM </li></ul>
  20. 21. Create a Physical Volume contd… <ul><li>2. From the whole disk </li></ul><ul><li>Erase the partition table of the disk. This can be done by zeroing first sector: </li></ul><ul><ul><li>#dd if=/dev/zero of=/dev/hda bs=512 count=1 </li></ul></ul><ul><ul><li>Now create the physical volume from such devices (configured in 1 or 2) </li></ul></ul><ul><ul><li>#pvcreate device_path </li></ul></ul><ul><ul><li>#pvcreate /dev/cciss/c0d0p6 </li></ul></ul><ul><ul><li>#pvcreate /dev/cciss/c0d0p7 </li></ul></ul><ul><ul><li>#pvcreate /dev/hda </li></ul></ul>
  21. 22. Create a Volume Group <ul><li>Out of one or more Physical Volumes described in previous slides create a Volume Group using vgcreate </li></ul><ul><ul><li>#vgcreate diskvg /dev/hda </li></ul></ul><ul><ul><li>#vgcreate partvg /dev/cciss/c0d0p5 /dev/cciss/c0d0p6 </li></ul></ul><ul><ul><li>#vgcreate mixvg /dev/cciss/c0d0p5 /dev/hda </li></ul></ul><ul><li>Simplest version of command is </li></ul><ul><li>#vgcreate vgname pvname_s </li></ul>
  22. 23. Create a Logical Volume <ul><li>Out of VG created create any no of volumes (using lvcreate) </li></ul><ul><li>#lvcreate options [-n lv_name] vg_name </li></ul><ul><li>LV name is optional, if you don’t provide one, LVM will choose one for you. </li></ul><ul><li>Now you can use this logical volume for creating your file system </li></ul>
  23. 24. Other Features <ul><li>Extend or shrink Logical volume </li></ul><ul><li>Expand or shrink VG/Remove PV from VG </li></ul><ul><li>Move LVs/PEs </li></ul><ul><li>Create a snapshot for a read only/read write view of the LV (can be used for online backups and many more things) </li></ul>
  24. 25. Some of the useful commands <ul><li>pvcreate </li></ul><ul><li>pvremove </li></ul><ul><li>pvmove </li></ul><ul><li>pvdisplay </li></ul><ul><li>pvscan </li></ul><ul><li>vgcreate </li></ul><ul><li>vgremove </li></ul><ul><li>vgextend </li></ul><ul><li>vgreduce </li></ul><ul><li>vgdisplay </li></ul><ul><li>vgscan </li></ul><ul><li>lvcreate </li></ul><ul><li>lvremove </li></ul><ul><li>lvextend </li></ul><ul><li>lvreduce </li></ul><ul><li>lvresize </li></ul><ul><li>lvdisplay </li></ul><ul><li>lvmdiskscan </li></ul>
  25. 26. Thanks!!! <ul><li>Resources </li></ul><ul><li>www.tldp.org </li></ul><ul><li>www.google.com </li></ul><ul><li>Search for keywords – LVM, LVM2, Device mapper, LVM HOWTO and many other we saw in previous slides </li></ul><ul><li>“ man” (#man lvm should get you started) </li></ul>
  26. 27. Disclaimer <ul><li>Views expressed in this document are of the authors and does not necessarily represent the view of Persistent Systems. </li></ul><ul><li>Persistent Systems Private Limited (“Persistent”) logo is trademark of Persistent in India and/or other countries. </li></ul><ul><li>Information provided in this document might change without notice. </li></ul><ul><li>Names of products, company and services may be trademarks or service marks of others. </li></ul><ul><li>This document is provided “AS IS” with no expressed or implied warranties. Use the information in this document at your own risk. </li></ul>
  27. 28. Next ??? EVMS !!!

×