记一次centos7扩展文件系统
df -k
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1913804 0 1913804 0% /dev
tmpfs 1930684 0 1930684 0% /dev/shm
tmpfs 1930684 12572 1918112 1% /run
tmpfs 1930684 0 1930684 0% /sys/fs/cgroup
/dev/mapper/centos-root 9754624 9238056 516568 95% /
/dev/sda1 201380 175476 25904 88% /boot
tmpfs 386140 12 386128 1% /run/user/42
tmpfs 386140 0 386140 0% /run/user/0
从/dev/mapper/centos-root得知vg为centos, lg为root
fdisk /dev/sda
新建磁盘分区/dev/sda3,按提示操作
fdisk -l
Disk /dev/sda: 69.8 GB, 69793218560 bytes, 136314880 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: 0x000b1eb6
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 24160255 11874304 8e Linux LVM
/dev/sda3 24160256 136314879 56077312 83 Linux
Disk /dev/mapper/centos-root: 9999 MB, 9999220736 bytes, 19529728 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
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 <64.80 GiB
PE Size 4.00 MiB
Total PE 16588
Alloc PE / Size 16586 / <64.79 GiB
Free PE / Size 2 / 8.00 MiB
VG UUID 4fHkqm-Vp9A-e1os-nUL1-cXbc-xsZL-6OpihM
这时的 Free PE / Size
lvdisplay
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID mgTXAr-GuO0-YonU-vZ2K-JImg-uj0o-owOiEF
LV Write Access read/write
LV Creation host, time localhost, 2020-05-09 13:32:39 +0800
LV Status available
# open 1
LV Size 9.31 GiB
Current LE 2384
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 5CY7wb-py0v-xGst-e3cj-Qeqj-6J54-PR4iDU
LV Write Access read/write
LV Creation host, time localhost, 2020-05-09 13:32:40 +0800
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
shutdown -r now
重启
pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
创建PV
vgextend /dev/centos /dev/sda3
Volume group "centos" successfully extended
lvextend /dev/centos/root /dev/sda3
Size of logical volume centos/root changed from 9.31 GiB (2384 extents) to <62.79 GiB (16074 extents).
Logical volume centos/root successfully resized.
resize2fs /dev/centos/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.
这里报错了,执行下面
mount |grep root
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=610304 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2441216, 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 2441216 to 16459776
df -h >>>>>再看成功了
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 13M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 63G 8.9G 54G 15% /
/dev/sda1 197M 172M 26M 88% /boot
tmpfs 378M 12K 378M 1% /run/user/42
tmpfs 378M 0 378M 0% /run/user/0