LVM logical volume management-creation of PV/VG/LV

Source: Internet
Author: User
Tags hex code

LVM --- logical volume manager (

Logical Volume Manager
)
.
LVM
This helps us easily allocate storage space for applications and users. In
LVM
The logical volume under management can be changed or removed as needed.
LVM
Storage volumes can also be managed by user groups, allowing administrators to use more intuitive names.
(
For example
"Sales ',
'Development ')
Replace physical disk
(
For example
'Sda ',
'Sdb ')
To identify the storage volume.

 

 

Traditional partition Concept

LVM
Logical volume Management

Disk Space independence Cannot be fully utilized, especially for
FS
Only one partition can be matched.
Multiple Disks
PV
Storage pool
VG
And then segment the logical volume according to the application
LV
Improve space utilization
Spatial scalability Repartition Use static or dynamic online expansion of volume group capacity
Data backup When the business is busy,
I/O
Frequent interface read/write
Snapshots can be used to capture the instantaneous and precise copy of a logical volume. Online backup has been completed.
User usability The partition ID cannot meet the requirements of many users. Can be defined according to user requirements
LV
Volume label of logical volume

 

I. Preparations for creating LVM
1. Build the environment: OS: rhel5.3
LVM package
IDE disk/dev/HDB (1024 MB),/dev/HDD (1024 MB)
2. Convert disk partitions --> LVM volume partitions
Final Solution:/dev/HDB --> Create/dev/hdb1 (ID: 5, system: Extended)
/Dev/hdb5 (ID: 8e, system: Linux LVM)
/Dev/HDD --> Create/dev/hdd1 (ID: 5, system: Extended)
/Dev/hdd5 (ID: 8e, system: Linux LVM)
Operation: (for example,/dev/HDB)

 

# Fdisk/dev/HDB
# P (display partition information) --> # N (create partition) --> # E (create extended partition) --> # L (create logical partition)
# Here is the experiment environment to facilitate subsequent increase and decrease operations, so we divide/dev/HDB into one partition.
# T (set disk hex code) --> # 8e (linuxlvm) --> # W (save Operation)
# P

Disk/dev/HDB: 1073 MB, 1073741824 bytes
16 Heads, 63 sectors/track, 2080 Cylinders
Units = cylinders of 1008*512 = 516096 bytes
Device boot start end blocks ID system
/Dev/hdb1 1 2080 1048288 + 5 extended
/Dev/hdb5 1 2080 1048257 8e Linux LVM
# Partprobe (this command allows the kernel to re-read the disk partition table and the modification takes effect)


 

Ii. Create LVM

1. Create a PV Disk
Solution:/dev/HDB --> lvm2 [1024 MB]
/Dev/HDD --> lvm2 [1024 MB]

Operation:

 

# Pvcreate/dev/hdb5/dev/hdd5
# Pvscan
# Pvdisplay

"/Dev/hdb5" is a new physical volume of "1023.69 MB"
--- New physical volume ---
PV name/dev/hdb5
VG name
PV size 1023.69 MB
Allocatable No
PE size (Kbyte) 0
Total pe 0
Free pe 0
Allocated pe 0
Pv uuid zm7103-sjg4-zjob-bel0-dlr1-hhh6-hcg 8kG

"/Dev/hdd5" is a new physical volume of "1023.69 MB"
--- New physical volume ---
PV name/dev/hdd5
VG name
PV size 1023.69 MB
Allocatable No
PE size (Kbyte) 0
Total pe 0
Free pe 0
Allocated pe 0
Pvuuid hAk1Dx-QulA-YV4G-p8wa-7sWw-FiaC-10GorS

 

2. Create a VG storage pool
Solution: lvm2 (/dev/HDB) --> vg1
Lvm2 (/dev/HDD) --> vg2
Operation:

 

# Vgcreate vg1/dev/hdb5
# Vgcreate vg2/dev/hdd5
# Vgscan
# Vgdisplay

--- Volume group ---
VG name vg2
System ID
Format lvm2
Metadata areas 1
Metadata Sequence No 1
VG access read/write
VG status resizable
Max LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG size 1020.00 MB
PE size 4.00 MB
Total PE 255


Alloc PE/size 0/0
Free PE/size 255/1020 .00 MB
Vg uuid Wa4Jo8-k3xY-BTng-uV6j-0Ee1-Vp8b-fNVrhQ

--- Volume group ---
VG name vg1
System ID
Format lvm2
Metadata areas 1
Metadata Sequence No 1
VG access read/write
VG status resizable
Max LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG size 1020.00 MB
PE size 4.00 MB
Total PE 255


Alloc PE/size 0/0
Free PE/size 255/1020 .00 MB
Vg uuid UGjfZd-shth-ZRTU-sVVm-MD0s-wzVB-zd7Uwt

 

3. Allocate the LV logical volume
Solution: Work (/dev/hdb5) --> vg1
Study (/dev/hdd5) --> vg2
Operation:

 

# Lvcreate-l 500 m-N work vg1
# Lvcreate-l 500 m-n study vg2
# Lvscan
# Lvdisplay


 

--- Logical volume ---
  LV Name                /dev/vg2/study
  VG Name                vg2
  LV UUID                53VT9v-dyp0-lSST-eDFz-w2Ns-Os0Z-ERnqVU
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size            500.00 MB
  Current LE         125


  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/vg1/work
  VG Name                vg1
  LV UUID                lhgKVg-hi95-W9gw-wOkZ-uyuy-BgZp-RrsCcA
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size            500.00 MB
  Current LE         125


  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

 

4. Partition formatting

 

# Mkfs.
Ext3/dev/vg1/work // or # mkfs-J/dev/vg1/work
# Mkfs.
Ext3/dev/vg2/study //...
# DF
-L

Disk /dev/hda:
8589 MB,
8589934592 bytes
255 heads,
63 sectors/track,
1044 cylinders
Units =
cylinders of
16065 *
512 =
8225280 bytes
 
  Device Boot Start End  Blocks   Id System
/dev/hda1 *

    1    32   257008+
  83  Linux
/dev/hda2     33    97   522112+
  83  Linux
/dev/hda3     98    358  2096482+
83  Linux
/dev/hda4     359   1044 5510295  5  Extended
/dev/hda5     359   549  1534176  83  Linux
/dev/hda6     550   848  2401686  83  Linux
/dev/hda7     849   913  522081   82  Linux swap / Solaris
/dev/hda8     914   978  522081   83  Linux
/dev/hda9     979   1043 522081   83  Linux

Disk /dev/hdb:
1073 MB,
1073741824 bytes
16 heads,
63 sectors/track,
2080 cylinders
Units =
cylinders of
1008 *
512 =
516096 bytes
 
   Device Boot Start End   Blocks Id System
/dev/hdb1       1    2080 1048288+
5 Extended
/dev/hdb5     1    2080 1048257 8e Linux LVM

Disk /dev/hdd:
1073 MB,
1073741824 bytes
16 heads,
63 sectors/track,
2080 cylinders
Units =
cylinders of
1008 *
512 =
516096 bytes

Device   Boot Start End   Blocks  Id  System
/dev/hdd1       1   2080 1048288+
  5   Extended
/dev/hdd5     1   2080 1048257   8e  Linux LVM


 

5. mount a new partition

 

 #mkdir .
.
/
home/work .
.
/
home/study
 #mount .
.
/
dev/vg1/work .
.
/
home/work
 #mount .
.
/
dev/vg2/study .
.
/
home/study
 #df
–Th

Filesystem  Type
  Size
Used Avail Use% Mounted on
/dev/hda2   ext3 494M 212M 257M  46%   /
/dev/hda9   ext3 494M 45M 425M   10%   /var
/dev/hda8   ext3 494M 11M 458M   3%    /opt
/dev/hda6   ext3 2.
3G 68M 2.
1G   4%    /home
/dev/hda3   ext3 2.
0G 1.
7G 182M  91%   /usr
/dev/hda5   ext3 1.
5G 35M 1.
4G   3%    /usr/local

/dev/hda1   ext3 244M 12M 219M   6%    /boot
tmpfs       tmpfs 125M 0  125M   0%    /dev/shm


/dev/mapper/vg1-
work
            ext3  485M 11M 449M  3%    /home/work
/dev/mapper/vg2-
study
            ext3  485M 11M 449M  3%    /home/study


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.