Expand the root directory of linux6.3 under the virtual machine. the root directory uses linxuLVM. Current size, status: [root @ node1 ~] # Df-hFilesystemSizeUsedAvailUse % Mountedon/dev/mapper/vg_oel63-lv_root13G6.5G5.4G55 %/the following process is added with 1 linuxLVM
Expand the root directory of linux6.3 under the virtual machine. the root directory uses linxu LVM.
Current size, Status:
[Root @ node1 ~] # Df-h
Filesystem Size UsedAvail Use % Mounted on
/Dev/mapper/vg_oel63-lv_root
13 GB 6.5G 5.4G 55%/
The following process adds a linux LVM partition, divides it into one PV, adds it to the existing VG, and expands it to the LV.
1. create a partition with the disk type Linux LVM (8e:
Command (m for help): p
Disk/dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x000cd5a1
Device Boot Start End Blocks Id System
/Dev/sda1*1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/Dev/sda2 64 1959 15215616 8e Linux LVM
Command (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 3
First cylinder (1959-2610, default 1959 ):
Using default value 1959
Last cylinder, + cylinders or + size {K, M, G} (1959-2610, default2610 ):
Using default value 2610
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Disk/dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x000cd5a1
Device Boot Start End Blocks Id System
/Dev/sda1*1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/Dev/sda2 64 1959 15215616 8e Linux LVM
/Dev/sda3 1959 2610 5236185 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be usedat
The next reboot or after you run partprobe (8) or kpartx (8)
Syncing disks.
2. add PV:
[Root @ node2 ~] # Pvcreate/dev/sda3
View PV
[Root @ node1 ~] # Pvdisplay
--- Physical volume ---
PV Name/dev/sda2
VG Name vg_oel63
PV Size 14.51 GiB/not usable 3.00 MiB
Allocatable yes (butfull)
PE Size 4.00 MiB
Total PE 3714
Free PE 0
Allocated PE 3714.
Pvuuid qE4s6S-TMVh-xcEx-5p7i-d217-gWxO-g73RMb
"/Dev/sda3" is a new physical volume of "4.99 GiB"
--- NEW Physical volume ---
PV Name/dev/sda3
VG Name PV Size 4.99 GiB
Allocatable NO
PE Size 0 Total PE 0
Free PE 0
Allocated PE 0
Pvuuid nfi7TH-7nbI-UxL4-SJT2-snrk-fRAQ-KcCAI2
3. resize VG
View existing VG
[Root @ node1 ~] # Vgdisplay
--- Volume group ---
VG Name vg_oel63
System ID Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 14.51 GiB
PE Size 4.00 MiB
Total PE 3714
Alloc PE/Size 3714/14 .51 GiB
Free PE/Size 0/0 vg uuid CwNr30-smZm-kc85-3CJP-p4Vi-6h3w-X85P9W
Extension:
[Root @ node1 ~] # Vgextend vg_oel63/dev/sda3
Volume group "vg_oel63" successfully extended
View again
[Root @ node1 ~] # Vgdisplay
--- Volume group ---
VG Name vg_oel63
System ID Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 19.50 GiB
PE Size 4.00 MiB
Total PE 4992
Alloc PE/Size 3714/14 .51 GiB
Free PE/Size 1278/4 .99GiB
Vg uuid CwNr30-smZm-kc85-3CJP-p4Vi-6h3w-X85P9W
4. resize LV
[Root @ node1 ~] # Lvdisplay
--- Logical volume ---
LV Path/dev/vg_oel63/lv_root
LV Name lv_root
VG Name vg_oel63
Lvuuid tsxrdP-KKJc-kD1m-EVl3-VZX0-qprk-1mRHhs
LV Write Access read/write
LV Creation host, time OEL63, 00:50:06 + 0800
LV Status available
# Open 1
LV Size 12.57 GiB
Current LE 3218
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 252: 0
--- Logical volume ---
LV Path/dev/vg_oel63/lv_swap
LV Name lv_swap
VG Name vg_oel63
Lv uuid 9hSLAQ-PCxn-hz9K-HdXZ-updx-CyjW-tXTcN1
LV Write Access read/write
LV Creation host, time OEL63, 00:50:09 + 0800
LV Status available
# Open 2
LV Size 1.94 GiB
Current LE 496
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Blocks device 252: 1
Expand the lv_root size:
[Root @ node1 ~] # Lvextend/dev/vg_oel63/lv_root/dev/sda3
Extending logical volume lv_root to 17.56 GiB
Logical volume lv_root successfully resized
[Root @ node1 ~] # Lvdisplay
--- Logical volume ---
LV Path/dev/vg_oel63/lv_root
LV Name lv_root
VG Name vg_oel63
Lvuuid tsxrdP-KKJc-kD1m-EVl3-VZX0-qprk-1mRHhs
LV Write Access read/write
LV Creation host, time OEL63, 00:50:06 + 0800
LV Status available
# Open 1
LV Size 17.56 GiB
Current LE 4496
Segments 2
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 252: 0
--- Logical volume ---
LV Path/dev/vg_oel63/lv_swap
LV Name lv_swap
VG Name vg_oel63
Lv uuid 9hSLAQ-PCxn-hz9K-HdXZ-updx-CyjW-tXTcN1
LV Write Access read/write
LV Creation host, time OEL63, 00:50:09 + 0800
LV Status available
# Open 2
LV Size 1.94 GiB
Current LE 496
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Blocks device 252: 1
5. execute the reset command
[Root @ node1 ~] # Resize2fs/dev/mapper/vg_oel63-lv_root
Resize2fs 1.41.12 (17-May-2010)
Filesystem at/dev/mapper/vg_oel63-lv_root is mounted on/; on-lineresizing required
Old desc_blocks = 1, new_desc_blocks = 2
Memory Ming an on-line resize of/dev/mapper/vg_oel63-lv_root to4603904 (4 k) blocks.
The filesystem on/dev/mapper/vg_oel63-lv_root is now 4603904 blocks long.
Final result:
[Root @ node1 ~] # Df-h
Filesystem Size UsedAvail Use % Mounted on
/Dev/mapper/vg_oel63-lv_root
18G 6.5G 10G 40%/