Linux Logical Volume Expansion
Keywords: pv (physical volumes), vg (volume group), lv (logical)
In the course of today with linux root partition size is not enough, suddenly remembered a long time did not update the blog, are concerned that the logical volume expansion issues now.
1. Check before expansion
Remember that / dev / mapper / rhel-root and so we will give it expansion, remember a good root partition type for xfs
[Hsun the root @ ~] DF # - hT
file system type has been used% capacity with the available mount point
/ dev / Mapper / XFS 1OG the root-RHEL 6.7 g of 67% 3.4G /
devtmpfs devtmpfs 1.9G 1.9G 0 0% / dev tmpfs tmpfs 1.9G 1.9G. 1% 4.0 K / dev / SHM tmpfs tmpfs 9.2M 1.9G 1.9G. 1% / RUN tmpfs tmpfs 1.9G 1.9G 0 0% / SYS / FS / a cgroup / dev / Mapper / usr-RHEL 68%. 12G 35G 24G, XFS / usr / dev / sda1 XFS 145M 870M 15% of 10-14m / Boot / dev / Mapper / var RHEL XFS-5.5G 2.6G 69% 8.0 g / var / dev / Mapper / 4.0G RHEL XFS-opt 32% 2.8G 1.3G / opt / dev / Mapper / tmp RHEL XFS-34M 4.0G 4.0G. 1% / tmp tmpfs tmpfs 378m 378m 0 0% / RUN / User / 1002 tmpfs tmpfs 378M 0 378M 0% /run/user/20001116 tmpfs tmpfs 378M 0 378M 0% /run/user/0
VG (volume group) can be seen that the root rhel
[root@hsun ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert opt rhel -wi-ao---- 4.00g root rhel -wi-ao---- 13.90g swap rhel -wi-ao---- 8.00g tmp rhel -wi-ao---- 4.00g usr rhel -wi-ao---- <35.00g var rhel -wi-ao---- 8.00g
And vg (Volume group) and pv (physical volume) of free space are 0, so we have to increase a new disk
[root@hsun ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel 1 6 0 wz--n- <69.00g 0 [root@hsun ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <69.00g 0
Our first machine shutdown
[root@hsun ~]# poweroff -f
Powering off.
2, add a new disk (the machine to insert a new hard drive)
Increase hard disk in VMware, the size of 4G. After the increase over the boot
3, disk expansion
Check the new drive after boot 3.1
You can see, just insert the disk has been read out, on my machine as / dev / sdb size of 4G
[root @ Hsun ~] # fdisk the -l | grep / dev / SD Disk / dev / sdb: 4294 MB, 4294967296 bytes, 8388608 sectors Disk / dev / sda: 75.2 GB, 75,161,927,680 bytes, 146.80064 million sectors / dev / sda1 * 2048 2,099,199 1048576 83 Linux / dev / sda2 2.0992 million 146 800 639 72.35072 million 8E Linux LVM
3.2 Creating PV
[root@hsun ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <69.00g 0 [root@hsun ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@hsun ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <69.00g 0 /dev/sdb lvm2 --- 4.00g 4.00g
3.3 PV of space assigned to the VG named rhel
[Hsun the root @ ~ ] # Vgs VG of the Attr #PV #LV #SN VSize vfree RHEL . 1 . 6 0 WZ - N- < 69 .00g 0 [Hsun the root @ ~] # the vgextend RHEL / dev / SDB Volume Group " RHEL " Extended successfully [Hsun the root @ ~ ] # Vgs vG of the Attr #PV #LV #SN VSize vfree RHEL 2 . 6 0 WZ - N- 72 .99g < . 4 .00g see vg volume group has been successfully expanded to 69G 73G , the space remaining unused 4G
3.4 for expansion of the root logical operation
[root@hsun ~]# lvextend -L +3.9G /dev/rhel/root Rounding size to boundary between physical extents: 3.90 GiB. Size of logical volume rhel/root changed from 10.00 GiB (2560 extents) to 13.90 GiB (3559 extents). Logical volume rhel/root successfully resized.
3.5 Refresh capacity
Then refresh capacity, because the partition type xfs, so use the Refresh command xfs_growfs capacity
If the partition type is ext type, the refresh command with resize2fs
[root@hsun ~]# xfs_growfs /dev/rhel/root meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=655360 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 2621440 to 3644416
Now you see a root expansion has been completed, the size of 14G
[Hsun the root @ ~] # DF - hT file system type has been used with the available capacity % mount point / dev / Mapper / XFS RHEL the root-14G . 6 .7G . 7 .3 G 49 % / devtmpfs devtmpfs . 1 .9 g 0 . 1 . 9G 0 % / dev tmpfs tmpfs . 1 .9 g . 4 .0K . 1 .9 g . 1 % / dev / SHM tmpfs tmpfs . 1 .9 g 9.2M . 1 .9 g . 1 % / RUN tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/rhel-usr xfs 35G 24G 12G 68% /usr /dev/sda1 xfs 1014M 145M 870M 15% /boot /dev/mapper/rhel-var xfs 8.0G 5.5G 2.6G 69% /var /dev/mapper/rhel-opt xfs 4.0G 1.3G 2.8G 32% /opt /dev/mapper/rhel-tmp xfs 4.0G 34M 4.0G 1% /tmp tmpfs tmpfs 378M 0 378M 0% /run/user/1002 tmpfs tmpfs 378M 0 378M 0% /run/user/20001116 tmpfs tmpfs 378M 0 378M 0% /run/user/0
Logical expansion ended.
If you have any do not know where or comments, please private letter to me or leave a message in the comments section, after seeing the first time to respond.
I am new to linux, linux chiefs hope that the exhibitions.