Linux Getting Started learning notes

Source: Internet
Author: User
Tags extend

LVM logical Volumn Manager Logical Volume management

can increase or decrease the size of the volume space freely

PV Physical volumn (physical volume) The actual partitioning device is zoned PV, PV is the LVM physical mark

VG Volumn Group (volume group) divides PV into VG, which is equivalent to combining LVM to use a large hard drive

PE physical extend (physical extension) the smallest unit of VG, default is 4M,VG maximum support 65,535 PE, equivalent to block

LV logical volumn (logical volume) an LVM device that can actually be used, rather than dividing the VG into usable partitions

1, dividing PV
Create PV using the Pvcreate command
[Root@dns ~]# PVCREATE/DEV/SDB1
Physical volume "/DEV/SDB1" successfully created
[Root@dns ~]# PVCREATE/DEV/SDC1
Physical volume "/DEV/SDC1" successfully created
[Root@dns ~]# PVCREATE/DEV/MD1
Physical volume "/DEV/MD1" successfully created

commands for viewing related information Pvscan Pvdisplay

Remove PV Command pvremove/dev/sdb1

2, dividing the VG

[Root@dns ~]# vgcreate li/dev/md1--Create a VG called Li, add/dev/md1
Volume Group "Li" successfully created

[Root@dns ~]# vgextend li/dev/sdb1--Enter Li this vg to add PV, to use Vgextend
Volume Group "Li" successfully extended
[Root@dns ~]# Vgextend LI/DEV/SDC1
Volume Group "Li" successfully extended

commands for viewing related information Vgscan Vgdisplay

[Root@dns ~]# vgreduce li/dev/sdc1--vgreduce is the opposite of Vgextend, which removes PV from the VG.
Removed "/DEV/SDC1" from volume group "li"

The command to remove VG is Vgremove, which is the opposite of vgcreate

3, create LV

[Root@dns ~]# lvcreate-l 500m-n li01 Li--in this vg of Li, divides a lv called li01, the size of 500m
Logical volume "li01" created
[Root@dns ~]# lvcreate-l 500m-n li02 li
Logical volume "li02" created
[Root@dns ~]# lvcreate-l 125-n li03 Li--The lowercase l parameter specifies the number of PE, here 4m*125=500m
Logical volume "li03" created
[Root@dns ~]# lvcreate-l 1g-n aa01 AA
Logical volume "AA01" created

The related parameters to view are Lvscan Lvdisplay

[Root@dns ~]# Lvscan--after creation, you can see these actually available LV stores in/DEV/VG name/lv name
ACTIVE '/DEV/AA/AA01 ' [1.00 GB] Inherit
ACTIVE '/dev/li/li01 ' [500.00 MB] Inherit
ACTIVE '/dev/li/li02 ' [500.00 MB] Inherit
ACTIVE '/dev/li/li03 ' [500.00 MB] Inherit

[Root@dns ~]# MKFS.EXT3/DEV/AA/AA01--The format of LV can be mounted using

Remove LV Use Lvremove

Completely remove LVM, we must first Lvremove, then Vgremove, finally Pvremove

--------------------------------

The expansion of the LV

1, first consider whether there is room for VG to expand, if not, then to expand the VG, the use of vgextend

2, expand LV
[Root@dns ~]# lvextend-l 1.5G/DEV/AA/AA01--Extend the/dev/aa/aa01 LV to 1.5g
Extending logical Volume AA01 to 1.50 GB
Logical Volume AA01 successfully resized

[Root@dns ~]# Df-h
FileSystem Size Used Avail use% mounted on

/dev/mapper/aa-aa01 1008M 34M 924M 4%/mnt--View the size that has been mounted, no change

[Root@dns ~]# RESIZE2FS/DEV/AA/AA01--Use this command to synchronize online
RESIZE2FS 1.39 (29-may-2006)
FileSystem at/dev/aa/aa01 is mounted on/mnt; On-line resizing required
Performing a on-line resize of/dev/aa/aa01 to 393216 (4k) blocks.
The filesystem on/dev/aa/aa01 is now 393216 blocks long.

[Root@dns ~]# Df-h
FileSystem Size Used Avail use% mounted on

/dev/mapper/aa-aa01 1.5G 34M 1.4G 3%/mnt--View again, the LV has been mounted extended, and the data has no effect

Here are two ways to do this
[Root@dns ~]# lvextend-l +100M/DEV/AA/AA01
[Root@dns ~]# lvextend-l +25/DEV/AA/AA01

The narrowing of the LV

[Root@dns ~]# resize2fs/dev/aa/aa01 1g--to shrink it, the error has been mount
RESIZE2FS 1.39 (29-may-2006)
FileSystem at/dev/aa/aa01 is mounted on/mnt; On-line resizing required
On-line shrinking from 444416 to 262144 not supported.

[Root@dns ~]# umount/mnt/

[Root@dns ~]# resize2fs/dev/aa/aa01 1g--umount and then use the RESIZE2FS command, the request to go first e2fsck detection
RESIZE2FS 1.39 (29-may-2006)
Please run ' e2fsck-f/dev/aa/aa01 '.

[Root@dns ~]# e2fsck-f/DEV/AA/AA01

[Root@dns ~]# resize2fs/dev/aa/aa01 1g--after detection, use the RESIZE2FS command to zoom out and mount to see if the size shrinks

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.