source: postlfs/filesystems/aboutlvm.xml@ 8558044

11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 8558044 was 8558044, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove spaces at the end of lines

I know it is somewhat useless, but I don't like them for
two reasons: first they cannot be seen, and I do not like things I
cannot see. Second, git highlights them, and this is disturbing...

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