LVM:
Image outline:
1) What is LVM and its role:
LVM is called logical volume management, which improves the management and usage flexibility of disk partitions.
The logical volume LVM can effectively manage and allocate disk space. It can combine scattered small partitions into a large volume group and separate the required space from the volume group to make logical volumes, this makes disk resizing easy to use. The backup function also refers to lvm snapshots.
2) create an instance:
Disk-> partition-> ID change 8e-> Save.
I used it for partitioning a disk. You can also divide each disk into one partition.
Device Boot Start End Blocks Id System
/Dev/sdb1 1 1306 10490413 + 8e Linux LVM
/Dev/sdb2 1307 2612 10490445 8e Linux LVM
/Dev/sdb3 2613 3918 10490445 8e Linux LVM
3) create a physical volume: run the pvcreate command.
Pvcreate/dev/sdb1
Pvcreate/dev/sdb2
Pvcreate/dev/sdb3
[Root @ station106 ~] # Pvs (view the created physical volume ).
Pv vg Fmt Attr PSize PFree
/Dev/sda2 vg0 lvm2 a -- 59.99g 7.99g
/Dev/sdb1 lvm2 a -- 10.00g 10.00g
/Dev/sdb2 lvm2 a -- 10.00g 10.00g
/Dev/sdb3 lvm2 a -- 10.00g 10.00g
Pvdisplay to view more details.
[Root @ station106 ~] # Pvdisplay
--- Physical volume ---
PV Name/dev/sdb1
VG Name myvg
PV Size 10.00 GiB/not usable 4.54 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2560
Free PE 2560
Allocated PE 0
Pvuuid XP8QfA-WQDd-1v9p-QKxk-AztZ-Nr9e-QbN6Gu
--- Physical volume ---
PV Name/dev/sdb2
VG Name myvg
PV Size 10.00 GiB/not usable 4.58 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2560
Free PE 2560
Allocated PE 0
Pvuuid f8Dtdd-fV9e-1yB7-1B8P-21mU-CU2f-fQDAxe
--- Physical volume ---
PV Name/dev/sdb3
VG Name myvg
PV Size 10.00 GiB/not usable 4.58 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2560
Free PE 2560
Allocated PE 0
Pvuuid rKNL0x-WXq2-gHYD-T27r-Gf05-a4y3-f4zqzt
4) create a logical volume: Use vgcreate.
[Root @ station106 ~] # Vgcreate myvg/dev/sdb {1, 2, 3}
Volume group "myvg" successfully created
[Root @ station106 ~] # Vgs
VG # PV # LV # SN Attr VSize VFree
Myvg 3 0 0 wz -- n-30.00g 30.00g
5) create a logical volume and lvcreate.
[Root @ station106 ~] # Lvcreate-L 10G-n test myvg
Logical volume "test" created
-L: space size.
-N: logical volume name.
[Root @ station106 ~] # Lvdisplay/dev/myvg/test
--- Logical volume ---
LV Path/dev/myvg/test
LV Name test
VG Name myvg
Lvuuid wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y
LV Write Access read/write
LV Creation host, time station106.magelinux.com, 11:18:43 + 0800
LV Status available
# Open 0
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 253: 4
6) Mount and use the created logical volume.
Format mke2fs-t ext4/dev/myvg/test.
Mount/dev/myvg/test/mnt/mount.
7) if one day the logical volume is not enough. How can I expand from a volume group? The following is an analysis.
Steps for logical volume expansion:
1. First determine the size of the extension and make sure that the volume group has sufficient space.
I want to scale 5 GB now, which is 10 Gb in size. The command is as follows:
[Root @ station106 ~] # Lvextend-L + 5G/dev/myvg/test
Extending logical volume test to 15.00 GiB
Logical volume test successfully resized
2. Expand physical boundaries. The physical boundary refers to the size of the physical edge.
[Root @ station106 ~] # Lvdisplay/dev/myvg/test
--- Logical volume ---
LV Path/dev/myvg/test
LV Name test
VG Name myvg
Lvuuid wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y
LV Write Access read/write
LV Creation host, time station106.magelinux.com, 11:18:43 + 0800
LV Status available
# Open 1
LV Size 15.00 GiB
Current LE 3840
Segments 2
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 253: 4
After the physical boundary is expanded, you will find that the logical volume in the Mount is still the size of itself.
[Root @ station106 ~] # Df-hT
Filesystem Type Size Used Avail Use % Mounted on
/Dev/mapper/vg0-root
Ext4 20G 387 M 19G 3%/
Tmpfs 242 M 0 242 M 0%/dev/shm
/Dev/sda1 ext4 194 M 29 M 156 M 16%/boot
/Dev/mapper/vg0-usr
Ext4 9.9G 1.9G 7.6G 20%/usr
/Dev/mapper/vg0-var
Ext4 20G 288 M 19G 2%/var
/Dev/mapper/myvg-test
Ext4 9.9G 151 M 9.2G 2%/mnt
Extend the logical boundary. The logical boundary refers to the logical volume that is directly recognized after being mounted.
[Root @ station106 ~] # Resize2fs/dev/myvg/test
Resize2fs 1.41.12 (17-May-2010)
Filesystem at/dev/myvg/test is mounted on/mnt; on-line resizing required
Old desc_blocks = 1, new_desc_blocks = 1
Ming an on-line resize of/dev/myvg/test to 3932160 (4 k) blocks.
The filesystem on/dev/myvg/test is now 3932160 blocks long.
[Root @ station106 ~] # Df-hT
Filesystem Type Size Used Avail Use % Mounted on
/Dev/mapper/vg0-root
Ext4 20G 387 M 19G 3%/
Tmpfs 242 M 0 242 M 0%/dev/shm
/Dev/sda1 ext4 194 M 29 M 156 M 16%/boot
/Dev/mapper/vg0-usr
Ext4 9.9G 1.9G 7.6G 20%/usr
/Dev/mapper/vg0-var
Ext4 20G 288 M 19G 2%/var
/Dev/mapper/myvg-test
Ext4, 15G, 153 M, 14G, 2%/mnt
The above is the extended logical volume section.
Recommended reading:
Install Oracle 10g RAC-ASM + bare Device on VMware
Install Oracle on bare devices on AIX
Oracle for AIX bare-device-based tablespace expansion step Aggregation