[root@host-192-168-0-10 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTP
vda 252:0 0 100G 0 disk
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
[root@host-192-168-0-10 ~]# df -h
Filesystem Size Used Avail Use%
/dev/mapper/rhel-root 18G 4.1G 14G 23%
devtmpfs 1.9G 0 1.9G 0%
tmpfs 1.9G 84K 1.9G 1%
tmpfs 1.9G 8.7M 1.9G 1%
tmpfs 1.9G 0 1.9G 0%
/dev/vda1 497M 158M 339M 32%
tmpfs 380M 16K 380M 1%
tmpfs 380M 0 380M 0%
# fdisk /dev/sda
To create new partitions for the OS to use. These new partitions will be added to the VG so we can extend the LV that the “/” partition is on. My newly created partition in the example is /dev/sda3. For new disks you would use /dev/sdb, or /dev/sdc. If you are using an extended /dev/sda like in my case, you will need to reboot for the changes to be seen
[root@host-192-168-0-10 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e92ca
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 41943039 20458496 8e Linux LVM
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (41943040-209715199, default 41943040):
Using default value 41943040
Last sector, +sectors or +size{K,M,G} (41943040-209715199, default 209715199):
Using default value 209715199
Partition 3 of type Linux and of size 80 GiB is set
Command (m for help): p
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e92ca
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 41943039 20458496 8e Linux LVM
/dev/vda3 41943040 209715199 83886080 83 Linux
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 used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@host-192-168-0-10 ~]# partprobe
[root@host-192-168-0-10 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 100G 0 disk
├─vda1 252:1 0 500M 0 part /boot
├─vda2 252:2 0 19.5G 0 part
│ ├─rhel-root 253:0 0 17.5G 0 lvm /
│ └─rhel-swap 253:1 0 2G 0 lvm [SWAP]
└─vda3 252:3 0 80G 0 part
[root@host-192-168-0-10 ~]# pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created
[root@host-192-168-0-10 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 2 0 wz--n- 19.51g 40.00m
[root@host-192-168-0-10 ~]# vgextend rhel /dev/vda3
Volume group "rhel" successfully extended
[root@host-192-168-0-10 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 2 2 0 wz--n- 99.50g 80.04g
[root@host-192-168-0-10 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- 17.47g
swap rhel -wi-ao---- 2.00g
[root@host-192-168-0-10 ~]# lvextend -L +80G /dev/rhel/root
Size of logical volume rhel/root changed from 17.47 GiB (4472 extents) to 97.47 GiB (24952 extents).
Logical volume root successfully resized.
[root@host-192-168-0-10 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- 97.47g
swap rhel -wi-ao---- 2.00g
Online resize of the actual filesystem now on that LV
[root@host-192-168-0-10 ~]# xfs_growfs /dev/rhel/root
meta-data=/dev/mapper/rhel-root isize=256 agcount=4, agsize=1144832 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=4579328, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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 4579328 to 25550848
[root@host-192-168-0-10 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 98G 4.1G 94G 5% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 84K 1.9G 1% /dev/shm
tmpfs 1.9G 8.7M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 497M 158M 339M 32% /boot
tmpfs 380M 16K 380M 1% /run/user/42
tmpfs 380M 0 380M 0% /run/user/0
[root@host-192-168-0-10 ~]#
阅读(1547) | 评论(0) | 转发(0) |