[7e1df8f9] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="aboutlvm">
|
---|
| 9 | <?dbhtml filename="aboutlvm.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>About Logical Volume Management (LVM)</title>
|
---|
| 17 |
|
---|
| 18 | <para>LVM manages disk drives. It allows multiple drives and partitions
|
---|
[0d7900a] | 19 | to be combined into larger <emphasis>volume groups</emphasis>, assists in
|
---|
| 20 | making backups through a <emphasis>snapshot</emphasis>, and allows for
|
---|
[7e1df8f9] | 21 | dynamic volume resizing. It can also provide mirroring similar to
|
---|
| 22 | a RAID 1 array.</para>
|
---|
| 23 |
|
---|
| 24 | <para>A complete discussion of LVM is beyond the scope of this introduction,
|
---|
| 25 | but basic concepts are presented below.</para>
|
---|
[0d7900a] | 26 |
|
---|
[7e1df8f9] | 27 | <para>To run any of the commands presented here, the <xref linkend='lvm2'/>
|
---|
| 28 | package must be installed. All commands must be run as the <systemitem
|
---|
| 29 | class="username">root</systemitem> user.</para>
|
---|
| 30 |
|
---|
| 31 | <para>Management of disks with lvm is accomplished using the following
|
---|
| 32 | concepts: </para>
|
---|
| 33 |
|
---|
| 34 | <variablelist>
|
---|
| 35 | <varlistentry>
|
---|
| 36 | <term>physical volumes</term>
|
---|
| 37 | <listitem><para>These are physical disks or partitions such as
|
---|
| 38 | /dev/sda3 or /dev/sdb.</para></listitem>
|
---|
| 39 | </varlistentry>
|
---|
| 40 |
|
---|
| 41 | <varlistentry>
|
---|
| 42 | <term>volume groups</term>
|
---|
| 43 | <listitem><para>These are named groups of physical volumes that
|
---|
| 44 | can be manipulated by the administrator. The number of physical
|
---|
[0d7900a] | 45 | volumes that make up a volume group is arbitrary. Physical volumes
|
---|
| 46 | can be dynamically added or removed from a volume group.
|
---|
[7e1df8f9] | 47 | </para></listitem>
|
---|
| 48 | </varlistentry>
|
---|
| 49 |
|
---|
| 50 | <varlistentry>
|
---|
| 51 | <term>logical volumes</term>
|
---|
| 52 | <listitem><para>Volume groups may be subdivided into logical volumes.
|
---|
| 53 | Each logical volume can then be individually formatted as if it were a
|
---|
| 54 | regular Linux partition. Logical volumes may be dynamically resized by
|
---|
| 55 | the administrator according to need.</para></listitem>
|
---|
| 56 |
|
---|
| 57 | </varlistentry>
|
---|
[0d7900a] | 58 | </variablelist>
|
---|
[7e1df8f9] | 59 |
|
---|
[ec64d28] | 60 | <para>To give a concrete example, suppose that you have two 2 TB disks.
|
---|
[7e1df8f9] | 61 | Also suppose a really large amount of space is required for a very large database,
|
---|
| 62 | mounted on <filename class='directory'>/srv/mysql</filename>. This is what
|
---|
| 63 | the initial set of partitions would look like:</para>
|
---|
| 64 |
|
---|
| 65 | <screen><literal>Partition Use Size Partition Type
|
---|
| 66 | /dev/sda1 /boot 100MB 83 (Linux)
|
---|
| 67 | /dev/sda2 / 10GB 83 (Linux)
|
---|
| 68 | /dev/sda3 swap 2GB 82 (Swap)
|
---|
| 69 | /dev/sda4 LVM remainder 8e (LVM)
|
---|
| 70 | /dev/sdb1 swap 2GB 82 (Swap)
|
---|
[0d7900a] | 71 | /dev/sdb2 LVM remainder 8e (LVM)</literal></screen>
|
---|
[7e1df8f9] | 72 |
|
---|
| 73 | <para>First initialize the physical volumes:</para>
|
---|
| 74 |
|
---|
| 75 | <screen><userinput>pvcreate /dev/sda4 /dev/sdb2</userinput></screen>
|
---|
| 76 |
|
---|
| 77 | <para>Next create a volume group named lfs-lvm:</para>
|
---|
| 78 |
|
---|
| 79 | <screen><userinput>vgcreate lfs-lvm /dev/sda4 /dev/sdb2</userinput></screen>
|
---|
| 80 |
|
---|
| 81 | <para>The status of the volume group can be checked by running the command
|
---|
| 82 | <command>vgscan</command>. Now create the logical volumes. Since there is
|
---|
| 83 | about 3900 GB available, leave about 900 GB free for expansion. Note that the
|
---|
| 84 | logical volume named <emphasis>mysql</emphasis> is larger than any physical
|
---|
| 85 | disk. </para>
|
---|
| 86 |
|
---|
| 87 | <screen><userinput>lvcreate --name mysql --size 2500G lfs-lvm
|
---|
| 88 | lvcreate --name home --size 500G lfs-lvm</userinput></screen>
|
---|
| 89 |
|
---|
| 90 | <para>Finally the logical volumes can be formatted and mounted. In this
|
---|
[0d7900a] | 91 | example, the jfs file system (<xref linkend='jfsutils'/>) is used for
|
---|
[7e1df8f9] | 92 | demonstration purposes.</para>
|
---|
| 93 |
|
---|
| 94 | <screen><userinput>mkfs -t ext4 /dev/lfs-lvm/home
|
---|
| 95 | mkfs -t jfs /dev/lfs-lvm/mysql
|
---|
| 96 | mount /dev/lfs-lvm/home /home
|
---|
| 97 | mkdir -p /srv/mysql
|
---|
| 98 | mount /dev/lfs-lvm/mysql /srv/mysql</userinput></screen>
|
---|
| 99 |
|
---|
| 100 | <para>The LFS boot scripts automatically make these file systems available
|
---|
| 101 | to the system in the checkfs script. Edit the <filename>/etc/fstab</filename>
|
---|
| 102 | file as required to automatically mount them.</para>
|
---|
| 103 |
|
---|
| 104 | <para>A LVM logical volume can host a root filesystem, but requires the use
|
---|
| 105 | of an initramfs (initial RAM file system) and is not discussed here.</para>
|
---|
[0d7900a] | 106 |
|
---|
[7e1df8f9] | 107 | <para>For a more information about LVM, see the <ulink
|
---|
| 108 | url="http://www.tldp.org/HOWTO/LVM-HOWTO/">LVM HOWTO</ulink> and
|
---|
| 109 | the lvm man pages.</para>
|
---|
| 110 |
|
---|
| 111 | </sect1>
|
---|