Implementing LVM under Linux

Source: Internet
Author: User
Tags kali linux

LVM Overview

LVM is the short name for Logical Disk volume management (Logical Volume Manager), which is a Linux environment for managing disk partitions

a mechanism;

LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management;

through LVM, the administrator does not have to move the disk's files to the new disk to take full advantage of the new storage space, but instead directly extend the file system across the disk, which is what we often say dynamically resizing partitions.


LVM creation

A. Adding a hard disk or creating a partition

in the all devices in a Linux system are stored as files. The device is generally stored under the/dev directory, with SDA, SDA1, sda2 ..., sdb,sdb1...,hda,hdb. Now the device is generally the SD name, the old hard disk is named after ha. The purpose of partitioning is to facilitate management.   

B. Creating a physical volume ( Physical Volume )

Material A volume refers to a hard disk partition or a device that has the same functionality as a logical partition ( such as RAID) , is LVM The basic storage logic block, but compared to the basic physical storage media (such as partitions, disks, etc.), it contains LVM the relevant management parameters.

c. Create a volume group ( Volume Group)

LVM volume groups are similar to physical hard disks in non-LVM systems, which consist of physical volumes. You can create one or more LVM partitions (logical volumes) on a volume group, and an LVM volume group consists of one or more physical volumes.

d. Create a logical volume ( Logical Volume )  

LVM logical volumes are similar to hard disk partitions in non- LVM Systems, which can be created on top of a logical volume ( e.g. /home or / usr wait ).

Attention:

PV,vg,LV Three relations: the PV ratio is a plate of the Earth,VG is a earth , because the earth is made up of multiple plates, and a region is divided on the earth and marked as Asia, then Asia is equivalent to an LVM.

E. Create file System 650) this.width=650; "Width=" "height=" src= "/e/u261/themes/default/images/spacer.gif" Style= "border:1px solid rgb (221,221,221); background-position:50% 50%;background-repeat:no-repeat; alt=" Spacer.gif "/>

F. Formatting and use of the mount


Create a Demo

This demo was created in Kali Linux.

First, check the partition status and Mount status

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8F/07/wKioL1jR5IvgcGjfAAiAQyd2Gdg516.png-wh_500x0-wm_ 3-wmp_4-s_2053160206.png "style=" Float:none; "title=" 2017-03-20 10-56-18 screen. png "alt=" Wkiol1jr5ivgcgjfaaiaqyd2gdg516.png-wh_50 "/>

Create partitions, type primary, and then view with p after creation.

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8F/09/wKiom1jR5JHBZgr6AAhaThEEkf0408.png-wh_500x0-wm_ 3-wmp_4-s_3183672072.png "style=" Float:none; "title=" 2017-03-20 10-57-22 screen. png "alt=" Wkiom1jr5jhbzgr6aahatheekf0408.png-wh_50 "/>

Change the partition format to 8e. The partition format of LVM

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/09/wKiom1jR5JeTouHGAAhmcfauszI153.png-wh_500x0-wm_ 3-wmp_4-s_119813009.png "style=" Float:none; "title=" 2017-03-20 10-57-50 screen. png "alt=" Wkiom1jr5jetouhgaahmcfauszi153.png-wh_50 "/>

Save, exit.

use partprobe to reread a partition without rebooting

Create a physical volume

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8F/09/wKiom1jR5KODQtgmAAgk7u1nseU652.png-wh_500x0-wm_ 3-wmp_4-s_3452276054.png "style=" Float:none; "title=" 2017-03-20 11-00-46 screen. png "alt=" Wkiom1jr5kodqtgmaagk7u1nseu652.png-wh_50 "/>

Create a volume group

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8F/09/wKiom1jR5K6gWQX0AAc8bEoJmvQ122.png-wh_500x0-wm_ 3-wmp_4-s_154997826.png "style=" Float:none; "title=" 2017-03-20 11-02-03 screen. png "alt=" Wkiom1jr5k6gwqx0aac8beojmvq122.png-wh_50 "/>

Creating a logical Volume

-L: Specify the size of the LV

-N: Specifies the name of the LV Rainbow: denotes the division of the LV from this VG

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8F/07/wKioL1jR5PGgnMfbAAewbLF61Ds110.png-wh_500x0-wm_ 3-wmp_4-s_277882575.png "style=" Float:none; "title=" 2017-03-20 11-04-05 screen. png "alt=" Wkiol1jr5pggnmfbaaewblf61ds110.png-wh_50 "/>

the LV is formatted (using MKFS for formatting), then LV can store data

The LV partition is mounted to the specified directory, and the data can be stored like a normal directory

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/07/wKioL1jR5PzzQKOPAAf7BxTs_x4187.png-wh_500x0-wm_ 3-wmp_4-s_526056582.png "style=" Float:none; "title=" 2017-03-20 11-07-42 screen. png "alt=" Wkiol1jr5pzzqkopaaf7bxts_ X4187.png-wh_50 "/>

permanent mount: If you want to start when the system starts LV , it is best to test1 Write/etc/ fstable in the file

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8F/09/wKiom1jR5P_yno6VAAOBh5b--38802.png-wh_500x0-wm_ 3-wmp_4-s_3549436608.png "style=" Float:none; "title=" 2017-03-20 11-12-46 screen. png "alt=" wkiom1jr5p_ Yno6vaaobh5b--38802.png-wh_50 "/>


LVM expansion

When there is not enough space in the volume group to extend the size of the logical volume, the capacity of the volume group needs to be increased, and the only way to increase the volume group capacity is to add a new physical volume to the volume group.

Use Vgextend command to add a new physical volume to the volume group. The Lvextend command is added to the logical volume.

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8F/09/wKiom1jR53fABptLAADJ5-QTuLA776.png-wh_500x0-wm_ 3-wmp_4-s_1517488948.png "style=" Float:none; "title=" Picture 1.png "alt=" Wkiom1jr53fabptlaadj5-qtula776.png-wh_50 "/>

E2fsck presets will only check for the wrong file system, plus-f is a mandatory check. Check the LVM device for the relationship between Inode and block

The RESIZE2FS command file System Management RESIZE2FS command is used to increase or shrink the size of the "EXT2/EXT3" file system that is not loaded, allowing increased capacity to take effect.

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8F/09/wKiom1jR53fBjA2kAACGhaCAzbE701.png-wh_500x0-wm_ 3-wmp_4-s_173613456.png "style=" Float:none; "title=" Picture 2.png "alt=" Wkiom1jr53fbja2kaacghacazbe701.png-wh_50 "/>



Problem solving

1. fdisk command

A: Setting a bootable tag

B: Modify the BSD disk label

C: set DOS operating system compatibility tag

D: Delete a partition

L: Show the known partition type

The 8e is a Linux swap partition witha linux partition, Linux LVM Partitioning,

FD is a system-level raid partition

M: Display Help information

N: Add a new partition

O: Create a new, blank DOS partition Table

P: Displays the current partition table of the disk

Q: quit the fdisk program without saving any changes

S: Create a new blank Sun disk label

T: Change the system number of a partition (e.g. change the linux Swap partition to a linux partition)

U: Change display recording unit

V: Verify the disk partition table

W: Save the modified result and exit the fdisk program

X: Special Features

2. When creating a physical volume, Cant open/dev/sda1 exclusively. Mounted filesystem?

Uninstalling the file system with the Umount command

The Umount command is used to unload a file system that has already been loaded. The file system can be umount with a device name or mount point , but it is best to uninstall it by Mount point to avoid confusion when using bound mounts (one device, multiple mount points).

3, PVCREATE/DEV/SDB1 error can ' t initialize physical volume "/DEV/SDB1" of volume Group "MYVG" Without-ff

This is due to the fact that the original logical volume, the logical volume group, and the physical volume are not unloaded. Use pvremove, Vgremove, lvremove to uninstall.

4, No free sectors available The entire disk has been divided and allocated.

in general, Linux system root partition (generally Ext2, EXT3, ReiserFS format) is unable to change the capacity, unauthorized deletion of changes, boot can not enter the system, or in the GDM error. Linux is best used to re-add a hard disk for LVM partitioning under virtual machines.

5. Related Concepts

PE (physical extent)

each physical volume is classified as a The basic unit of PE (physical extents) , (which I understand as a physical block, the following LE is the corresponding logical block) with a unique number of PE is can be the smallest unit of LVM addressing. the size of the PE is configurable and defaults to 4MB.  

LE(logical extent)

logical volumes are also classified as An addressable basic unit of LE (Logical extents) . In the same volume group,the size ofLE is the same as the PE , and one by one corresponds.  





This article from "Rainbow 18 lang" blog, reproduced please contact the author!

Implementing LVM under Linux

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.