A very professional LinuxLVMHOWTO

Source: Internet
Author: User
Article Title: a very professional LinuxLVMHOWTO. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

1. Introduction
Welcome, dear reader.

The purpose of writing this document is to tell you What LVM is, how it works, and how you use it to make your life easier. Although there is an lvm faq, it is still in German and described from different perspectives. It is a "real" HOWTO, and it is also very expert in teaching understanding (hopefully.

I want to clarify that I am not the author of a Linux Logical Volume Manager. I pay tribute to those authors and hope to cooperate with them.

What is incredible is that I don't even know LVM developers. I hope this will change soon. I apologized to them in advance.

1.1 disclaimer & permission
Distributing this document is intended to be useful to you, but it does not provide any guarantee, nor is there any implied guarantee for sales or adaptation to special purposes.

If your disk has melted, your company has fired you-this is by no means our fault. Sorry. Remember to back up frequently and do experiments on systems without important data.

In addition, Richard Allen does not speak on behalf of his boss.

Linux is a registered trademark of Linus Torvalds.

Original english text (if the translation is incorrect, the original text shall prevail)

This document is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of MERCHANTABILITY or fitness for a participant PURPOSE.

If your disks melt and your company fires you-its never our fault. Sorry. Make frequent backups and do your experiments on non-mission critical systems.

Furthermore, Richard Allen does not speak for his employer.

Linux is a registered trademark of Linus Torvalds.

1.2 Prerequisites
Not too many. If you have installed Linux and created a file system (fdisk/mkfs), you are ready. However, you must be cautious when operating as root! Incorrect commands or operating device files may damage existing data.

If you know how to configure HP/ux lvm, you have almost done everything. Linux works like processing on HP.

1.3 precautions
There are several notes for this document. Although I write most of it, I really don't want it to stop. I firmly believe in Open Source. I encourage you to feedback, update, patch, and so on. Do not tell us about typographical or common errors.

If you feel that you are more qualified to maintain a part, or you think you can create and maintain a new part, you are welcome. The howto sgml format is available through CVS. I expected this would be a cooperation plan.

In this document, you will find many FIXME notifications. Patches are always welcome! No matter where you find FIXME, you must understand that you are stepping on an unknown domain. This is not to say that there are no errors in other places, but to say that there is something special attention here. If you have verified anything, please let me know and I will delete this FIXME notification.

1.4 access, CVS & updates
This HOWTO specification is located here.

We now have anonymous CVS access, which is widely used in the world. This makes it easier for you to get the latest version of HOWTO and provide changes and enhancements.

If you want to obtain the HOWTO through CVS, we will teach you how to do it:

$ Export CVSROOT =: pserver: anon@outpost.ds9a.nl:/var/cvsroot
$ Cvs login
CVS password: [enter cvs (without s)]
$ Cvs co lvm-howto
Cvs server: Updating lvm-howto
U lvm-howto/lvm-howto.sgml


If you find an error or want to add something, fix it locally, Run "cvs diff-u", and send the result to us.

A Makefile is provided to help you create postscript, dvi, pdf, html, and plain text formats. You may need to install sgml-tools, ghostscript, and tetex to obtain all formats.

1.5 orchestration of this document
We will first explain some basic knowledge required. We try our best to include examples for understanding.


2. What is LVM?
Traditionally, the size of a partition is static. This requires a system installer not to consider "how much data I want to store in this partition", but "how much data I want to store in this partition ". When a user has no space in the partition, he or she must re-partition (which may require the entire operating system to be reinstalled) or use the assembly machine like a symbolic connection.

A partition is a series of continuous data blocks on a physical disk. Most Unix-like systems now have the ability to break down physical disks into many units. The storage units on multiple drives can converge into a "logical volume" which can be allocated to the partition. In addition, units can be added and deleted from partitions as space requirements change.

This is the basic logical volume manager (LVM)

For example, suppose you have a 1 GB disk and it takes 600 MB to create a "/home" partition. Suppose you have no space, so you decide that "/home" requires 1 GB. With the traditional partitioning concept, you have to have another drive of at least 1 GB size. Add the disk, create a new/home, and copy the existing data.

However, with LVM configuration, you only need to add a 400 MB (or larger) disk and add its storage unit to the "/home" partition. Other tools allow you to adjust the size of the original file system, so you only need to adjust the "/home" size to use a larger partition, and then return to the business.

For a very special processing, LVM can even make its own "snapshot", which enables you to back up non-removable targets. We return to this exciting possibility. Later, there will be many other real applications.

In the following sections, we explain the basic elements of LVM and its usage.


3. Basic Principles
OK. Don't stop with fear, but LVM has many terms you need to understand to avoid your file system being compromised.

We start from below, more or less.

Physical media The physical media
You should feel that the word "physical" has a great extension, although we initially assumed it was just a hard disk or a partition. For example,/dev/hda,/dev/hda6,/dev/sda. You can convert any continuous block on a block device to one...

Physical Volume (PV)
A pv is just a physical medium with a lot of management data added to it-once you add it, LVM considers it to be... .

Physical partition Physical Extents (PE)
Physical partitions are like some big data blocks, usually several MB. PE can be allocated to one...

Volume Group (VG)
A vg is composed of multiple physical partitions (possibly from multiple physical volumes or hard disks ). Although this may make you think that a VG is composed of several hard disks (such as/dev/hda and/dev/sda), more specifically, it contains many PES provided by these hard disks.

>; From this volume group, PE can be allocated to one...

Logical Volume (LV)
Yes, we finally get somewhere. A logical volume is the final result of our work, where we store information. This is equivalent to the idea of traditional partitioning.
Like using a common partition, you can create one on a logical volume...

File System Filesystem
The file system is the form you want it to become: Standard ext2, ReiserFS, NWFS, XFS, JFX, NTFS, and so on... For linux kernels, there is no difference between common partitions and logical volumes.
I tried to draw an ASCII image to visualize it.

A physical volume contains many physical partitions:

+ ----- [Physical Volume] ------ +
| PE |
+ ------------------------------ +

A volume group contains two physical volumes (PVs) with six physical partitions:

+ ------ [Volume Group] ----------------- +
| + -- [PV] -------- ++ -- [PV] --------- + |
| PE |
| + -------------- ++ --------------- + |
+ --------------------------------------- +

We will make further expansion:

+ ------ [Volume Group] ----------------- +
| + -- [PV] -------- ++ -- [PV] --------- + |
| PE |
| + -- + --- ++-+ ---- + --- + |
| + -----/|
|
| +-+ --- +-+ ---- + -- + |
| Logical |
| Volume |
|
|/Home |/var |
| + ----------- ++ ------------ + |
+ --------------------------------------- +


This shows us two file systems that span two disks. The/home file system contains four physical partitions and the/var file system contains two.

Bert hubert is writing a tool to describe LVM more realistically. Here it provides some appearance on the screen. It looks better than an ASCII image.

3.1 Show & Tell
Okay, these concepts are hard to understand ('We are LVM of Borg...), so the following is an example of creating a logical volume. Do not paste this example to your console, because it will damage data, unless it happens that your computer's/dev/hda3 and/dev/hdb2 are not used.

If you have any questions, view the ASCII image above.

You should first set the partition type of/dev/hda3 and/dev/hdb2 to 0x8e, which indicates "Linux LVM ". Note that your fdisk version may not recognize this type, so it is displayed as "Unknown ":


# Fdisk/dev/hda

Command (m for help): p

Disk/dev/hda: 255 heads, 63 sectors, 623 cylinders.
Units = cylinders of 16065*512 bytes

Device Boot Start End Blocks Id System
/Dev/hda1 1 2 16033 + 83 Linux
/Dev/hda2 3 600 4803435 83 Linux
/Dev/hda3 601 607 56227 + 83 Linux
/Dev/hda4 608 614 56227 + 83 Linux

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e

Command (m for help): p

Disk/dev/hda: 255 heads, 63 sectors, 623 cylinders.
Units = cylinders of 16065*512 bytes

Device Boot Start End Blocks Id System
/Dev/hda1 1 2 16033 + 83 Linux
/Dev/hda2 3 600 4803435 83 Linux
/Dev/hda3 601 607 56227 + 8e Unknown
/Dev/hda4 608 614 56227 + 83 Linux

Command (m for help): w

 

[1] [2] [3] [4] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.