visualbox虚拟机下centos8系统扩容
1、使用visualbox命令调整磁盘大小:
C:\Program Files\Oracle\VirtualBox>vboxmanage modifyhd D:\visualpc\centos8\centos8.vdi --resize 40960
2、启动虚拟机:
[root@localhost ~]# df -T /dev/sda1
文件系统 类型 1K-块 已用 可用 已用% 挂载点
/dev/sda1 ext4 999320 135512 794996 15% /boot
[root@localhost ~]# fdisk -l
Disk /dev/sda:40 GiB,42949672960 字节,83886080 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x645551a1
设备 启动 起点 末尾 扇区 大小 Id 类型
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 16777215 14678016 7G 8e Linux LVM
/dev/sda3 16777216 83886079 67108864 32G 8e Linux LVM
Disk /dev/mapper/cl-root:6.2 GiB,6652166144 字节,12992512 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
Disk /dev/mapper/cl-swap:820 MiB,859832320 字节,1679360 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
[root@localhost ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=2097152 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=8388608, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=4096, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# pvcreate /dev/sda3
WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created.
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name cl
PV Size <7.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1791
Free PE 0
Allocated PE 1791
PV UUID 8LSBYx-cuPV-4uCu-Bbyf-aNia-Wx9j-r8Fxn7
"/dev/sda3" is a new physical volume of "32.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 32.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 3VbOQ8-04fx-2ve9-id0h-fsoA-4lt1-QZg3d9
[root@localhost ~]# vgextend cl /dev/sda3
Volume group "cl" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name cl
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 38.99 GiB
PE Size 4.00 MiB
Total PE 9982
Alloc PE / Size 1791 / <7.00 GiB
Free PE / Size 8191 / <32.00 GiB
VG UUID lf5AJi-Vh4c-8knL-Nect-ed23-bVWC-6idwKS
[root@localhost ~]# lvextend -l +8191 /dev/cl/root
Size of logical volume cl/root changed from <6.20 GiB (1586 extents) to 38.19 GiB (9777 extents).
Logical volume cl/root successfully resized.
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name cl
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 38.99 GiB
PE Size 4.00 MiB
Total PE 9982
Alloc PE / Size 9982 / 38.99 GiB
Free PE / Size 0 / 0
VG UUID lf5AJi-Vh4c-8knL-Nect-ed23-bVWC-6idwKS
[root@localhost ~]# xfs_growfs /
meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=406016 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1624064, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log 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 1624064 to 10011648
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 900M 0 900M 0% /dev
tmpfs 915M 0 915M 0% /dev/shm
tmpfs 915M 9.2M 906M 2% /run
tmpfs 915M 0 915M 0% /sys/fs/cgroup
/dev/mapper/cl-root 39G 6.4G 32G 17% /
/dev/sda1 976M 133M 777M 15% /boot
tmpfs 183M 28K 183M 1% /run/user/42
overlay 39G 6.4G 32G 17% /var/lib/docker/overlay2/b65a315af56b57a2f1eedd864721249341f59765a99305e9dd6977e37e418e
e8/merged
tmpfs 183M 4.0K 183M 1% /run/user/0
3、扩容成功