Linux file System online expansion in combat

Source: Internet
Author: User

1. A brief introduction to LVM


LVM, logic Volume manager, logical volume management. The architecture diagram for LVM is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/39/89/wKioL1O6Xx2yP5r3AAJQ8MbX44w519.jpg "title=" LVM " alt= "Wkiol1o6xx2yp5r3aajq8mbx44w519.jpg"/>

Description


First, the focus needs to focus on the 3 concepts of the PV (physical volume) physical volume, the VG (volume Group) volume group, The LV (logic volume) logical volume.


Second, for an LVM type of partition, can be composed of PV;VG is composed of a PV; VG can not be used directly, it is similar to the extended partition, as the VG in the PV increases or decreases, the VG will automatically increase or decrease, the upper layer of the VG is similar to the logical partition, LV,LV, By formatting the LV (that is, by creating a file system), it is ready to use after it is mounted.




2. Online expansion operation sharing


Experimental environment

Operating system: RedHat Enterprise Linux Server release 5.0-32bit

File system: Ext3


Experimental steps

The first step is to create 2 LVM partitions


Use the FDISK command to create a partition type of 8e (LINUX LVM) with option T, as shown below:

/DEV/SDB6 200781 8e Linux LVM

/dev/sdb7 200781 8e Linux LVM



The second step is to create the PV


[[email protected]/]# pvcreate/dev/sdb{6,7}

Physical volume "/DEV/SDB6" successfully created

Physical volume "/DEV/SDB7" successfully created


[Email protected]/]# PVs

PV VG Fmt Attr PSize pfree

/DEV/SDB6 lvm2--196.08M 196.08M

/dev/sdb7 lvm2--196.08M 196.08M


More detailed and specific information can be viewed through pvdisplay.


Step Three: Create VG


[[email protected]/]# vgcreate myvg/dev/sdb{6,7}

Volume Group "MYVG" successfully created

[Email protected]/]# VGS

VG #PV #LV #SN Attr vsize vfree

MYVG 2 0 0 wz--n-384.00m 384.00M



Fourth step: Create LV

[[email protected]/]# lvcreate-l 4m-n mylv1 myvg

  Logical Volume "Mylv1" created

[[email protected]/]# LVs

  LV    VG   Attr   lsize Origin snap%  move Log copy% 

  mylv1 myvg-wi-a-4.00M       


note that in order to demonstrate the experimental effect, only a 4M-sized LV is created here.



Fifth step: Format the LV, and mount the use


[Email protected]/]# mke2fs-j/DEV/MYVG/MYLV1


[Email protected]/]# mount/dev/myvg/mylv1/users


[Email protected]/]# DF-LH

Filesystem Size used Avail use% mounted on

/dev/sda2 3.8G 3.3G 384M 90%/

/dev/sda3 14G 1.1G 12G 9%/Home

/DEV/SDA1 46M 11M 34M 24%/boot

Tmpfs 252M 0 252M 0%/dev/shm

/dev/mapper/myvg-mylv1

3.9M 1.1M 2.7M 29%/users


[Email protected]/]# cd/users

[Email protected] users]# ls-l

Total 12

drwx------2 root root 12288 Jul 6 16:40 Lost+found

[Email protected] users]# Cp/etc/inittab.

[Email protected] users]# ls-l

Total 15

-rw-r--r--1 root root 1666 Jul 6 16:41 Inittab

drwx------2 root root 12288 Jul 6 16:40 Lost+found

[[email protected] users]# LVS

LV VG Attr lsize Origin snap% Move Log copy%

mylv1 Myvg-wi-ao 4.00M                   



It is important to note that DF is looking at the size of the file system. Above, we created the EXT3 file system for LV and hung it under the/users directory, copying a file to/users.



Sixth step: Adjust the size of the file system online


[Email protected] users]# lvextend-l 32M/DEV/MYVG/MYLV1 = = "This is physical expansion

Extending logical Volume MYLV1 to 32.00 MB

Logical Volume MYLV1 successfully resized


[[email protected] users]# LVS

LV VG Attr lsize Origin snap% Move Log copy%

MYLV1 Myvg-wi-ao 32.00M

[[email protected] users]# resize2fs-p/DEV/MYVG/MYLV1 = = "This is the logical expansion

RESIZE2FS 1.39 (29-may-2006)

Filesystem at/dev/myvg/mylv1 is mounted on/users; On-line resizing required

Performing an on-line resize of/dev/myvg/mylv1 to 32768 (1k) blocks.

The filesystem on/dev/myvg/mylv1 is now 32768 blocks long.



[Email protected] users]# DF-LH

Filesystem Size used Avail use% mounted on

/dev/sda2 3.8G 3.3G 384M 90%/

/dev/sda3 14G 1.1G 12G 9%/Home

/DEV/SDA1 46M 11M 34M 24%/boot

Tmpfs 252M 0 252M 0%/dev/shm

/dev/mapper/myvg-mylv1

32M 1.1M 30M 4%/users


[Email protected] users]# Cat/users/inittab

#

# Inittab This file describes how the INIT process should set up

# The system in a certain run-level.

#

# Author:miquel van Smoorenburg, <[email protected]>



Through the logical architecture diagram of LVM, it needs to be clear that if the file system is to be scaled up, it should be divided into 2 steps, first physical capacity expansion, then logical expansion. The so-called physical expansion, from the physical point of view, the LV expansion, of course, the size of LV itself received the limitations of the VG, the so-called logical expansion, by the logical boundary of the file system is re-determined, is dependent on the physical boundary.


3. Summary

With the LVM tool, we show you a way to expand your Linux file system online without restarting the server, without having to mount the file system again, and without having to make any changes to your application.


This article is from the "I want to surpass myself" blog, please be sure to keep this source http://zhangfengzhe.blog.51cto.com/8855103/1435410

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.