Linux two disk mount pointing to a folder LVM Disk Management (i)

Source: Internet
Author: User

Note: The operation of any disk may damage the data inside, please back up the data in advance, remember! Remember! Remember!


0x00: Preface.

In the Linux use process, found a file is very large, such as 5G, but there are two physical disk one Left 4 G, one left 3G, disk space is not enough, so certainly can't put in. If the 5G file is divided, it can be put in, but if there are many files! This is when you can use LVM to help us manage which disk the files are placed on.

Note: LVM is used for partitions with a single hard disk less than 2TB, and if more than 2TB is partitioned, it is not recommended that LVM be recognized.


0x01: Text control.

Physical Disk: The disk that you bought to be able to hold in your hand.

PV: When a physical disk is created as a normal disk 83, when the type is modified to 8e, it becomes the LVM disk system, which is what we call PV.

VG: Volume group (Volume Group), is to put a single PV into a group unified management.

LV: This is the logical partition from the VG, where we can use it as a normal disk and create a new file or folder.


0x02: Release Notes.

1) VMware Workstation Pro 12.5.7 build-5813279

2) CentOS Release 6.9 (Final)


0X03: Construction of experimental environment.

1) Install VM virtual machine and CentOS system installation online a lot, slightly.

2) Create a simulated physical disk in the VM, which is automatically recognized in the virtual machine.

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/10/80e995808d00d2045199e70aef8e7093.jpg-wh_500x0-wm_3 -wmp_4-s_4275999655.jpg "style=" Float:none; "title=" lvm_.jpg "alt=" 80e995808d00d2045199e70aef8e7093.jpg-wh_ "/>

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/10/dfce7b4fe004cc3a1fd17ec7266039a3.jpg-wh_500x0-wm_3 -wmp_4-s_2055886862.jpg "style=" Float:none; "title=" lvm_01.jpg "alt=" Dfce7b4fe004cc3a1fd17ec7266039a3.jpg-wh_ "/ >

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/10/257c40eec2197bbca2f162dc31af5603.jpg-wh_500x0-wm_3 -wmp_4-s_3912232772.jpg "style=" Float:none; "title=" lvm_02.jpg "alt=" 257c40eec2197bbca2f162dc31af5603.jpg-wh_ "/ >

Because doing experiments saves time, we divide 3 disks into 100M, 200M, 300M,

From the capacity we can also intuitively see the disk in action.

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/10/0c6edb23609485286b331dba8c94d4eb.jpg-wh_500x0-wm_3 -wmp_4-s_3910723701.jpg "style=" Float:none; "title=" lvm_03.jpg "alt=" 0c6edb23609485286b331dba8c94d4eb.jpg-wh_ "/ >

Note file names do not repeat

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/10/69ec7ee0264f695b8396bc93e78f3895.jpg-wh_500x0-wm_3 -wmp_4-s_475688824.jpg "style=" Float:none; "title=" lvm_04.jpg "alt=" 69ec7ee0264f695b8396bc93e78f3895.jpg-wh_ "/ >

The other 2 Create the same, repeat the above steps.

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/10/7a8713ce553f42e636899eb29be5bb5f.jpg-wh_500x0-wm_3 -wmp_4-s_3212618640.jpg "style=" Float:none; "title=" lvm_05.jpg "alt=" 7a8713ce553f42e636899eb29be5bb5f.jpg-wh_ "/ >

In the system, use the command to view the number of unallocated disks.

# fdisk-l

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/11/018c09c90831e367af3a4843acc6a8b6.jpg-wh_500x0-wm_3 -wmp_4-s_618719594.jpg "title=" lvm_07.jpg "alt=" 018c09c90831e367af3a4843acc6a8b6.jpg-wh_ "/>

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/11/728404152bdbb3d5a071cc56431ccccf.jpg-wh_500x0-wm_3 -wmp_4-s_231559209.jpg "title=" lvm_06.jpg "alt=" 728404152bdbb3d5a071cc56431ccccf.jpg-wh_ "/>


3) First of all, format the disk as a normal disk.

#fdisk/DEV/SDA

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/11/91d04b4896be6ddfc71d52cf0e44b6b3.jpg-wh_500x0-wm_3 -wmp_4-s_400798703.jpg "style=" Float:none; "title=" lvm_08.jpg "alt=" 91d04b4896be6ddfc71d52cf0e44b6b3.jpg-wh_ "/ >

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/11/8f9e661129ad132d80e6dac166942165.jpg-wh_500x0-wm_3 -wmp_4-s_685778804.jpg "style=" Float:none; "title=" lvm_09.jpg "alt=" 8f9e661129ad132d80e6dac166942165.jpg-wh_ "/ >


0x04: Install LVM, and create.

When a common disk type is modified to 8e, it has become an LVM disk system, which is what we call PV.

The disk is created, but LVM is not the system itself, especially 2.6.9 or less, we need to install it ourselves.

Check to see if the system is installed.

Rpm-qa | GRE LVM

and view the kernel version.

Uname-a

The system shows no installation, we use the command to install.

Yum-y Install LVM2

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/11/42dd1bb6e40e5fe93ec990ae7052542e.jpg-wh_500x0-wm_3 -wmp_4-s_4119761050.jpg "title=" lvm_11.jpg "alt=" 42dd1bb6e40e5fe93ec990ae7052542e.jpg-wh_ "/>


1) Create PV.

LVM prompt has been installed, with pvscan command prompt did not find PV (physical volumes)

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/11/77c5798889d34fd3efe0d501388794d8.jpg-wh_500x0-wm_3 -wmp_4-s_3885371461.jpg "title=" lvm_12.jpg "alt=" 77c5798889d34fd3efe0d501388794d8.jpg-wh_ "/>

Create PV and rescan and discover a new PV.

# pvcreate/dev/sdb1 # Pvscan

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/11/4be4ff7b101c2ee5b239e2079ab875c8.jpg-wh_500x0-wm_3 -wmp_4-s_4196078525.jpg "title=" lvm_13.jpg "alt=" 4be4ff7b101c2ee5b239e2079ab875c8.jpg-wh_ "/>

Displays PV information because only one PV is created, so there is only one.

# Pvdisplay

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/11/bd3ecd33c44806dce454e620ff7e2ef5.jpg-wh_500x0-wm_3 -wmp_4-s_388810177.jpg "title=" lvm_14.jpg "alt=" Bd3ecd33c44806dce454e620ff7e2ef5.jpg-wh_ "/>

OK, now change a normal disk into the most basic physical disk in LVM. Let's create the VG (Disk Management Group).


2) Create VG (volume group) to manage PV.

# Vgscan//Because the VG has not been created before, so the scan is not displayed. # vgcreate VGDATA/DEV/SDB1//Create Vgdata and add/DEV/SDB1 # vgcreate vgdata/dev/sdb1-s 8M//-s is the specified PE size, default is 4M # VGDISPLA Y//Display VG Information

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/11/0a879a76181530787c9570b0a897af17.jpg-wh_500x0-wm_3 -wmp_4-s_2834229924.jpg "title=" lvm_15.jpg "alt=" 0a879a76181530787c9570b0a897af17.jpg-wh_ "/>

Scan again to find the "vgdata" volume group that was created above the VG.

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/11/438cec71f6b3ff59ad8904a1c372701e.jpg-wh_500x0-wm_3 -wmp_4-s_3853120938.jpg "title=" lvm_16.jpg "alt=" 438cec71f6b3ff59ad8904a1c372701e.jpg-wh_ "/>

3) With a volume group we can create lv,lv that we really use to write data, such as creating a new text.

# Lvscan//scan LV, not previously established LV, nothing shows # lvcreate-l 100m-n lvdata vgdata//Create lv,-l specify LV size for 100m,-n LV name convenient to differentiate, vgdata join to Vgda   Ta Group, created above. # Lvdisplay

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/11/a553f67742486881717eec1f5098dfec.jpg-wh_500x0-wm_3 -wmp_4-s_4146702767.jpg "title=" lvm_17.jpg "alt=" A553f67742486881717eec1f5098dfec.jpg-wh_ "/>

4) format LV and mount

# Mkfs.ext4/dev/vgdata/lvdata//formatted lvdata for EXT4 format. # MKDIR/LVM//Create mount point # MOUNT/DEV/VGDATA/LVDATA/LVM//Mount to LVM # df-h display mounted successfully 100M space system occupies 1.6M also to volume group occupy some, actually occupy 2%.

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/11/9f669b42b605bec08fc7e50499fc2a5d.jpg-wh_500x0-wm_3 -wmp_4-s_2707259800.jpg "title=" lvm_18.jpg "alt=" 9f669b42b605bec08fc7e50499fc2a5d.jpg-wh_ "/>

Well, to this a complete LVM is created.

0x05: Auto mount on BOOT.

mount point of the disk, after the reboot will be lost, you need to write the configuration/etc/fstab, let the system automatically mount.

# echo "/DEV/VGDATA/LVDATA/LVM ext4 defaults 0 0" >>/etc/fstab

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/11/e5cd0b0aaf8f2947dd168411a7374014.jpg-wh_500x0-wm_3 -wmp_4-s_2374752468.jpg "title=" lvm_19.jpg "alt=" E5cd0b0aaf8f2947dd168411a7374014.jpg-wh_ "/>

Reference article:

Https://www.cnblogs.com/gaojun/archive/2012/08/22/2650229.html

http://dreamfire.blog.51cto.com/418026/1084729/

Https://jingyan.baidu.com/article/76a7e409bd923dfc3b6e153d.html

Https://jingyan.baidu.com/article/5553fa82e9d9c365a239343d.html

Https://jingyan.baidu.com/article/59a015e3a65909f79488653d.html

Https://jingyan.baidu.com/article/49711c6148ed72fa441b7c3d.html

Https://jingyan.baidu.com/article/0eb457e5057ad603f1a9053e.html

Https://jingyan.baidu.com/article/48b558e35708ce7f38c09a3e.html

https://www.centos.bz/2012/02/installation-and-usage-of-lvm/


This article is from the "Enlightened Grocery store" blog, please be sure to keep this source http://wutou.blog.51cto.com/615096/1980826

Linux two disk mount pointing to a folder LVM Disk Management (i)

Related Article

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.