source: postlfs/filesystems/aboutlvm.xml@ 60e8d690

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 60e8d690 was 3f2db3a6, checked in by Pierre Labastie <pierre.labastie@…>, 18 months ago

Remove sect1info tags

They only contain a date tag that is nowhere used.

  • Property mode set to 100644
File size: 6.6 KB
Line 
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
12 <title>About Logical Volume Management (LVM)</title>
13
14 <para>
15 LVM manages disk drives. It allows multiple drives and partitions
16 to be combined into larger <emphasis>volume groups</emphasis>, assists in
17 making backups through a <emphasis>snapshot</emphasis>, and allows for
18 dynamic volume resizing. It can also provide mirroring similar to
19 a RAID 1 array.
20 </para>
21
22 <para>
23 A complete discussion of LVM is beyond the scope of this introduction,
24 but basic concepts are presented below.
25 </para>
26
27 <para>
28 To run any of the commands presented here, the <xref linkend='lvm2'/>
29 package must be installed. All commands must be run as the <systemitem
30 class="username">root</systemitem> user.
31 </para>
32
33 <para>
34 Management of disks with lvm is accomplished using the following concepts:
35 </para>
36
37 <variablelist>
38 <varlistentry>
39 <term>physical volumes</term>
40 <listitem>
41 <para>
42 These are physical disks or partitions such as
43 /dev/sda3 or /dev/sdb.
44 </para>
45 </listitem>
46 </varlistentry>
47
48 <varlistentry>
49 <term>volume groups</term>
50 <listitem>
51 <para>
52 These are named groups of physical volumes that
53 can be manipulated by the administrator. The number of physical
54 volumes that make up a volume group is arbitrary. Physical volumes
55 can be dynamically added or removed from a volume group.
56 </para>
57 </listitem>
58 </varlistentry>
59
60 <varlistentry>
61 <term>logical volumes</term>
62 <listitem>
63 <para>
64 Volume groups may be subdivided into logical volumes. Each logical
65 volume can then be individually formatted as if it were a regular
66 Linux partition. Logical volumes may be dynamically resized by
67 the administrator according to need.
68 </para>
69 </listitem>
70
71 </varlistentry>
72 </variablelist>
73
74 <para>
75 To give a concrete example, suppose that you have two 2 TB disks. Also
76 suppose a really large amount of space is required for a very large
77 database, mounted on <filename class='directory'>/srv/mysql</filename>.
78 This is what the initial set of partitions would look like:
79 </para>
80
81 <screen><literal>Partition Use Size Partition Type
82/dev/sda1 /boot 100MB 83 (Linux)
83/dev/sda2 / 10GB 83 (Linux)
84/dev/sda3 swap 2GB 82 (Swap)
85/dev/sda4 LVM remainder 8e (LVM)
86/dev/sdb1 swap 2GB 82 (Swap)
87/dev/sdb2 LVM remainder 8e (LVM)</literal></screen>
88
89 <para>
90 First initialize the physical volumes:
91 </para>
92
93 <screen><userinput>pvcreate /dev/sda4 /dev/sdb2</userinput></screen>
94
95 <note>
96 <para>
97 A full disk can be used as part of a physical volume, but
98 beware that the <command>pvcreate</command> command will destroy any
99 partition information on that disk.
100 </para>
101 </note>
102
103 <para>
104 Next create a volume group named lfs-lvm:
105 </para>
106
107 <screen><userinput>vgcreate lfs-lvm /dev/sda4 /dev/sdb2</userinput></screen>
108
109 <para>
110 The status of the volume group can be checked by running the command
111 <command>vgscan</command>. Now create the logical volumes. Since there
112 is about 3900 GB available, leave about 900 GB free for expansion. Note
113 that the logical volume named <emphasis>mysql</emphasis> is larger than
114 any physical disk.
115 </para>
116
117 <screen><userinput>lvcreate --name mysql --size 2500G lfs-lvm
118lvcreate --name home --size 500G lfs-lvm</userinput></screen>
119
120 <para>
121 Finally the logical volumes can be formatted and mounted. In this
122 example, the jfs file system (<xref linkend='jfsutils'/>) is used for
123 demonstration purposes.
124 </para>
125
126 <screen><userinput>mkfs -t ext4 /dev/lfs-lvm/home
127mkfs -t jfs /dev/lfs-lvm/mysql
128mount /dev/lfs-lvm/home /home
129mkdir -p /srv/mysql
130mount /dev/lfs-lvm/mysql /srv/mysql</userinput></screen>
131
132 <para>
133 It may be needed to activate those logical volumes, for them to
134 appear in <filename class="directory">/dev</filename>. They can all
135 be activated at the same time by issuing, as the
136 <systemitem class="username">root</systemitem> user:
137 </para>
138
139<screen role="root"><userinput>vgchange -a y</userinput></screen>
140
141 <para revision="sysv">
142 The LFS boot scripts automatically make these logical volumes available to
143 the system in the <command>udev</command> script. Edit the
144 <filename>/etc/fstab</filename> file as required to automatically mount
145 them.
146 </para>
147
148 <para>
149 A LVM logical volume can host a root filesystem, but requires the use
150 of an initramfs (initial RAM file system). The initramfs proposed in
151 <xref linkend="initramfs"/> allows to pass the lvm volume in
152 the <parameter>root=</parameter> switch of the kernel command line.
153 </para>
154
155 <para revision="systemd">
156 If not using an initramfs, there is a race condition in <application>
157 systemd</application> preventing mounting logical volumes through
158 <filename>/etc/fstab</filename>. You must create a <quote>mount</quote>
159 unit (see systemd.mount(5)) as in the following example, which mounts
160 the <filename class="directory">/home</filename> directory automatically
161 at boot:
162 </para>
163
164<screen role="root" revision="systemd"><userinput>cat &gt; /etc/systemd/system/home.mount &lt;&lt; EOF
165<literal>[Unit]
166Description=Mount the lvm volume /dev/lfs-lvm/home to /home
167
168[Mount]
169What=/dev/lfs-lvm/home
170Where=/home
171Type=ext4
172Options=default
173
174[Install]
175WantedBy=multi-user.target</literal>
176EOF</userinput></screen>
177
178 <note revision="systemd">
179 <para>
180 The name of the unit must be the name of the mount point with the
181 `/' character replaced by `-', omitting the leading one.
182 </para>
183 </note>
184
185 <para revision="systemd">
186 Next the unit must be enabled with:
187 </para>
188
189<screen role="root" revision="systemd"><userinput>systemctl enable home.mount</userinput></screen>
190
191 <para>
192 For more information about LVM, see the <ulink
193 url="https://tldp.org/HOWTO/LVM-HOWTO/">LVM HOWTO</ulink> and
194 the lvm man pages. A good in-depth
195 <ulink url="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/index">
196 guide</ulink> is available from RedHat<superscript>&reg;</superscript>,
197 although it makes sometimes reference to proprietary tools.
198 </para>
199
200</sect1>
Note: See TracBrowser for help on using the repository browser.