Download presentation
Presentation is loading. Please wait.
Published byHarold Marsh Modified over 8 years ago
1
Logical Volume Management in Linux November 2006 Slide 1 Welcome Logical Volume Management in Linux Jeff Muse St. Louis Unix Users Group http://www.sluug.org/~jmuse/presentations
2
Logical Volume Management in Linux November 2006 Slide 2 What Is It? In computer storage, logical volume management or LVM is a method of allocating space on mass storage devices that is more flexible than conventional partitioning schemes. In particular, a volume manager can concatenate, stripe together or otherwise combine partitions into larger virtual ones that can be resized or moved, possibly while it is being used. Volume management is a form of virtualization because it turns storage into a more easily allocatable and fluid resource. http://en.wikipedia.org/wiki/Logical_volume_management
3
Logical Volume Management in Linux November 2006 Slide 3 What Unix Systems Use LVM? ManyUnix operating systems ship with LVMs:operating systems Many Unix operating systems ship with LVMs:operating systems AIXAIX - Logical Volume ManagerLogical Volume Manager FreeBSDFreeBSD - Vinum/GvinumVinum HP-UXHP-UX - HP Logical Volume Manager, since HP-UX Release 9.0 in July 1992. LinuxLinux - Logical Volume Manager (LVM) and Enterprise Volume Management System (EVMS).Logical Volume ManagerEnterprise Volume Management System Both are front-ends to the Linux device mapper.device mapper SolarisSolaris - Solaris Volume Manager (SVM) in Solaris 9 & Solstice DiskSuite (SDS) to Solaris 8.Solaris Volume ManagerSolstice DiskSuite ZFS in Solaris 10 includes volume management features.
4
Logical Volume Management in Linux November 2006 Slide 4 What Other Systems Use LVM? Some other operating systems ship with LVMs:operating systems Microsoft WindowsMicrosoft Windows - Logical Disk Manager (LDM), Windows 2000 or later NT based OSes.Logical Disk Manager OS/2OS/2 - (LVM), from version 4.5, including eComStation.eComStation Symantec's Veritas Volume Manager (VxVM), a proprietary LVMVeritas Volume Manager Now included in Symantec's Storage Foundation Suite Provides LVM on a variety of (Unix like) OSes and MS Windows
5
Logical Volume Management in Linux November 2006 Slide 5 What about LVM for Linux? We are going to focus only on LVM for Linux LVM (Linux) is an implementation for Linux Kernel Written in 1998 by Heinz Mauelshagen of Sistina Software (now part of Red Hat) Design based on HP-UX Includes most features expected of a volume manager http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29
6
Logical Volume Management in Linux November 2006 Slide 6 Who Should Use It? Those who need filesystems that are larger than that which one disk can accommodate Those who anticipate that their storage requirements will change over time Those who need performance available from disk striping (or use RAID)
7
Logical Volume Management in Linux November 2006 Slide 7 What Does It Do? LVM lets us add or remove space from existing partitions LVM lets us have one filesystem that spreads across multiple disks LVM lets us take snapshots of filesystems so that we don't back up inconsistent data
8
Logical Volume Management in Linux November 2006 Slide 8 What Does It NOT Do? Do not expect LVM to provide: Redundancy. If one disk in a volume dies, you lose all the data on that disk at a minimum If you need redundancy, use RAID 1 or RAID 5 in addition to or instead of LVM Extra data protection. LVM does not provide any additional level of data protection. The need for backups remains.
9
Logical Volume Management in Linux November 2006 Slide 9 When to use LVM You will want to use it when you run out of space on partition one, but you still have space on partition two, and maybe even partition three... It works just as well on a desktop as it does on an enterprise class server, and... You planned ahead when you configured your disk(s)
10
Logical Volume Management in Linux November 2006 Slide 10 When NOT to use it Assuming you are comfortable using it, there's really no reason not to use it Unless... You didn't plan ahead by setting it up when you partitioned your disks.
11
Logical Volume Management in Linux November 2006 Slide 11 Why Use It? LVM gives us a flexible way to manage disks and filesystems It is easier to change a logical volume than a partition created via fdisk – no more backup, re-partition, re- format, restore More and more Linux distributions are including LVM It is so complicated that management is afraid to fire you.
12
Logical Volume Management in Linux November 2006 Slide 12 What are Prerequisites? LVM2 (LVM1 is stable but not latest and greatest) LVM2 is mostly backwards-compatible with LVM1 Kernel device mapper support (part of 2.6.9 and later)device mapper Your distribution probably has everything you need Some distributions give you choice of setting it up at install time
13
Logical Volume Management in Linux November 2006 Slide 13 Anatomy of LVM Physical Volume (PV) Volume Group (VG) Physical Extents (PE) Logical Volume (LV) Metadata
14
Logical Volume Management in Linux November 2006 Slide 14 Physical Volume (PV) A Physical Volume (PV) is where your data gets written You need to assign a disk or partition for use by LVM with the pvcreate command
15
Logical Volume Management in Linux November 2006 Slide 15 Volume Group (VG) A Volume Group (VG) is a container for the space provided by your PVs. There can be multiple VGs on a system, dividing available space between them.
16
Logical Volume Management in Linux November 2006 Slide 16 Physical Extents (PE) Physical Extents (PEs) are chunks of space something like blocks on a traditional filesystem. They are associated with a specific VG.
17
Logical Volume Management in Linux November 2006 Slide 17 Logical Volume (LV) A Logical Volume (LV) is a collection of PEs from a specific VG There can be multiple LVs contained within a VG The LV is where you place your filesystem Ext2, Ext3, ReiserFS, XFS, JFS, etc. Create filesystems using mke2fs, mkreiserfs, or whatever your chosen filesystem requires
18
Logical Volume Management in Linux November 2006 Slide 18 Metadata Each PV, VG, and LV has metadata associated with it. LVM metadata theoretically lets you pull disks out of one machine, insert them into another, and reassemble your volumes easily even if the device names change.
19
Logical Volume Management in Linux November 2006 Slide 19 A Word About LVM Names Names for volume groups and logical volumes are completely arbitrary They can be almost anything you want They are specified at creation time It is common practice to: include “vg” in the names of volume groups, and include “lv” in the names of logical volumes. This arbitrary naming is a source of much confusion.
20
Logical Volume Management in Linux November 2006 Slide 20 Confused Yet?
21
Logical Volume Management in Linux November 2006 Slide 21 Diagram of an Example LVM Setup sd a sd b sd c sales_v g hr_v g acct_v g eng_v g sales_lv0 1 sales_lv0 2 hr_lv0 1 hr_lv02 acct_lv0 1 acct_lv02 eng_lv0 1 eng_lv0 2 Physical Volumes... Create 4 VGs from 3 PVs Contain Volume Groups... VGs have PEs available for use Which hold Logical Volumes Make filesystem on LVs Mount these LVs
22
Logical Volume Management in Linux November 2006 Slide 22 Overview of the Process Create the Physical Volumes (PVs) Create the Volume Groups (VGs) Physical Extents (PEs) are created automatically when you create the VGs (but you can define the PE size when you create a VG). Create the Logical Volumes (LVs) Use the Logical Volumes (LVs) Make filesystems on the LVs Mount the LVs as needed
23
Logical Volume Management in Linux November 2006 Slide 23 Create the Physical Volumes (PVs) Identify disks or partitions as available to LVM: If you're using a partition, make sure it is partition type 0x8e (Linux LVM) via fdisk If using an entire disk, zero out the partition table with dd # pvcreate /dev/sda /dev/sdb /dev/sdc This command sets up UUID's and metadata needed by LVM /dev/sda, /dev/sdb, and /dev/sdc are now able to hold volume groups (VGs)
24
Logical Volume Management in Linux November 2006 Slide 24 Create the Volume Groups (VGs) # vgcreate sales_vg /dev/sda /dev/sdb /dev/sdc It's not necessary to use all the PVs you've created vgcreate can also be used to define PE sizes (-s flag) # vgcreate -s 32M sales_vg /dev/sda /dev/sdb /dev/sdc Turn on the new VG: # vgchange -a sales_vg
25
Logical Volume Management in Linux November 2006 Slide 25 Physical Extent (PE) Limitations Physical Extent (PEs) sizes affect use Too many PEs on a large filesystem can hurt performance. The default PE size is 4M, but can go all the way up to 16G. Under LVM1, if you were using 4M PEs, you couldn't create a filesystem larger than 256G. This is not true under LVM2.
26
Logical Volume Management in Linux November 2006 Slide 26 Create a Logical Volume (LV) # lvcreate –size 10G –name sales_lv01 sales_vg This is where we would define a stripe if we want it: # lvcreate -i 3 -I 8 –size 10G -name sales_lv01 sales_vg -i indicates number of stripes -I indicates stripe size in kilobytes (must be powers of 2)
27
Logical Volume Management in Linux November 2006 Slide 27 Using the Logical Volume (LV) Make your favorite filesystem on your new LV # mke2fs -j /dev/vg/sales_lv01 # mkreiserfs /dev/vg/sales_lv01 The device mapper created /dev/vg/sales_lv*device mapper There was no mknod required! Mount your new filesystems like any others # mount /dev/vg/sales_lv01 /samba/sales/
28
Logical Volume Management in Linux November 2006 Slide 28 Physical Volume Utilities pvremove Remove all data associating disk or partition with an PV # pvremove /dev/sdd pvdisplay Lots of information about your physical volumes pvscan Quick summary of your PVs
29
Logical Volume Management in Linux November 2006 Slide 29 Volume Group Utilities vgextend, vgreduce add or remove PVs to a VG # vgextend vol_group /dev/sdd # vgreduce vol_group /dev/sdd vgremove remove an entire VG # vgremove vol_group All the LV's in the VG need to be removed first
30
Logical Volume Management in Linux November 2006 Slide 30 Other Volume Group Utilities vgdisplay everything you ever wanted to know about your VG – and then some vgscan – list all VGs and rebuild cached metadata
31
Logical Volume Management in Linux November 2006 Slide 31 Physical Extent Utilities Are there any Physical Extent (PE) utilities? Nope! PE size can be found via vgdisplay Do PEs magically appear? Nope – they are defined when you create your VG! Do you change them? Nope!
32
Logical Volume Management in Linux November 2006 Slide 32 Extending a Logical Volume lvextend # lvextend –size 15G /dev/vol_group/lv01 # lvextend –size +15G /dev/vol_group/lv01 The + adds an additional amount rather than specifying an end value. The LV can be mounted while it's being extended, but might need an fsck first, even if it's clean.
33
Logical Volume Management in Linux November 2006 Slide 33 Gotcha! Extending a LV is not enough to make more space available on your filesystem. You must resize filesystem to specify the new size. # resize2fs /dev/vol_group/lv01 15G # resize_reiserfs -s 15G /dev/vol_group/lv01
34
Logical Volume Management in Linux November 2006 Slide 34 Removing a Logical Volume lvremove # lvremove lv01 The LV must be unmounted before being removed
35
Logical Volume Management in Linux November 2006 Slide 35 More Logical Volume Utilities lvscan – scan (all disks) for LVs lvdisplay – extensive information about each LV lvrename – rename a LV lvresize – resize a LV
36
Logical Volume Management in Linux November 2006 Slide 36 Special Case of LVM on / Your root partition can be included as part of an LVM, although this is not always recommended You need an initrd that at a minimum includes vgscan and vgchange You can either add device mapper support into your initrd or compile it statically into your kerneldevice mapper You need a separate /boot partition Some installers may not support installing / onto a LV
37
Logical Volume Management in Linux November 2006 Slide 37 Snapshots Snapshots capture the state of a filesystem at a given time Useful for backing up data on filesystems that are constantly changing – similar to fssnap on Solaris Need as much available space in your VG as will change on original LV (if you've got 300M of available space and have 500M of altered data, snapshot will be unusable) # lvcreate –size 600M -s -n backup -o ro /dev/vol_group/lv01
38
Logical Volume Management in Linux November 2006 Slide 38 Snapshots (continued) mount /dev/vol_group/backup to some arbitrary mount point You don't need to specify a filesystem type Backup /dev/vol_group/backup with your favorite backup utility umount /dev/vol_group/backup lvremove /dev/vol_group/backup to delete
39
Logical Volume Management in Linux November 2006 Slide 39 Security Issues LVM has not had any known security issues.
40
Logical Volume Management in Linux November 2006 Slide 40 Costs and Savings Money – all those disks get expensive! Adding really large disk is expensive Combining smaller disks might save money Time Be aware of the high learning curve! Setting up LVM requires additional up-front planning and implementation Effort Most of the effort is at front end, the design and setup Pays for itself the first time you resize a logical volume!
41
Logical Volume Management in Linux November 2006 Slide 41 Future Looks stable for the time being GUI tools may improve usability Novell/SuSE - YaST Mandriva – Disk Druid Fedora/Red Hat - “system-config-lvm”
42
Logical Volume Management in Linux November 2006 Slide 42 Book References Any good books? Not that I've seen So, any in the works? None that I'm aware of
43
Logical Volume Management in Linux November 2006 Slide 43 Internet References How-To's In Increasing Order of Usability The HOW-TO for LVM on TLDP is confusing for newcomers to LVMTLDP Daniel Robbins has a number of articles on ibm.com, but they are very dated Gentoo's LVM installation document is a good step-by- step guide ( http://www.gentoo.org/doc/en/lvm2.xml )http://www.gentoo.org/doc/en/lvm2.xml
44
Logical Volume Management in Linux November 2006 Slide 44 Internet References (continued) Other Internet references of interest: http://www.linux.org.mt/article/lvm http://en.wikipedia.org/wiki/Device_mapper http://www.redhat.com/magazine/009jul05/features/lvm2/ http://fedoranews.org/mediawiki/index.php/Expanding_Linux_Partitions_with_LVM http://www.linuxdevcenter.com/pub/a/linux/2006/04/27/managing-disk-space-with-lvm.html http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch27_:_Expanding_Disk_Capacity
45
Logical Volume Management in Linux November 2006 Slide 45 Caution Regarding Web References If it tells you to patch your kernel, it is out of date. If it refers to sistina.com, it is out of date. If it tells you that small PE's limit the size of your LV, it is out of date. You will find that a fair number of hits referred to by google are out of date.
46
Logical Volume Management in Linux November 2006 Slide 46 Credits Thanks go to Stan Reichardt for helping with the OpenOffice.org Impress application and organizing difficult material
47
Logical Volume Management in Linux November 2006 Slide 47 Questions? Logical Volume Management in Linux Jeff Muse St. Louis Unix Users Group http://www.sluug.org/~jmuse/presentations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.