如何增加thin provisioning vm的硬盘space
How to increase the hard disk space of thin provisioning vm
创建了具有 50 GB 硬盘的精简配置虚拟机 (centos 7)。但它不会在需要时自动增加 space 。谁能告诉我如何增加“/”目录的space。
[oracle@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 14G 16K 100% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 912M 985M 49% /dev/shm
tmpfs 1.9G 17M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 147M 351M 30% /boot
tmpfs 380M 0 380M 0% /run/user/1001
tmpfs 380M 0 380M 0% /run/user/1002
以下是 pvs 命令的输出。
[root@inches-rmdev01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 15.51g 40.00m
下面是 vgs 命令的输出。
[root@inches-rmdev01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 15.51g 40.00m
下面是 lvs 命令的输出。
[root@inches-rmdev01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.87g
swap centos -wi-ao---- 1.60g
以下是 fdisk 命令的输出。
[root@inches-rmdev01 ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009a61a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 33554431 16264192 8e Linux LVM
/dev/sda3 33554432 104857599 35651584 8e Linux LVM
Disk /dev/mapper/centos-root: 14.9 GB, 14889779200 bytes, 29081600 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: 1719 MB, 1719664640 bytes, 3358720 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
在 fdisk -l
输出中,您可以看到您有一个 35GB 的磁盘 /dev/sda3
。要扩展您的根卷,您可以将此磁盘添加到 LVM(逻辑卷管理器):
pvcreate /dev/sda3
这会将未使用的磁盘 /dev/sda3
作为新的 pv(物理卷)添加到 LVM。
下一步是扩展您的根 vg(卷组)。在你的情况下很容易,因为你只有一个 vg:
vgextend centos /dev/sda3
现在您已经将 35GB 磁盘添加到您的 vg 中,您可以将其分配到您的 lv(逻辑卷)。
最后,您可以使用 lvextend
命令将 space 添加到您的根卷中(最多 35GB):
如果您想使用整个 35GB,您可以使用:
lvextend -l +100%FREE /dev/mapper/centos-root
如果你只想添加一定的数量(即 1G),你可以使用这个:
lvextend -L +1G /dev/mapper/centos-root
最后调整文件系统的大小:
resize2fs /dev/mapper/centos-root
LVM逻辑是:
1.硬盘fdisk -l
2.物理量pvs
3.卷组vgs
4.逻辑卷lvs
创建了具有 50 GB 硬盘的精简配置虚拟机 (centos 7)。但它不会在需要时自动增加 space 。谁能告诉我如何增加“/”目录的space。
[oracle@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 14G 16K 100% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 912M 985M 49% /dev/shm
tmpfs 1.9G 17M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 147M 351M 30% /boot
tmpfs 380M 0 380M 0% /run/user/1001
tmpfs 380M 0 380M 0% /run/user/1002
以下是 pvs 命令的输出。
[root@inches-rmdev01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 15.51g 40.00m
下面是 vgs 命令的输出。
[root@inches-rmdev01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 15.51g 40.00m
下面是 lvs 命令的输出。
[root@inches-rmdev01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.87g
swap centos -wi-ao---- 1.60g
以下是 fdisk 命令的输出。
[root@inches-rmdev01 ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009a61a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 33554431 16264192 8e Linux LVM
/dev/sda3 33554432 104857599 35651584 8e Linux LVM
Disk /dev/mapper/centos-root: 14.9 GB, 14889779200 bytes, 29081600 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: 1719 MB, 1719664640 bytes, 3358720 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
在 fdisk -l
输出中,您可以看到您有一个 35GB 的磁盘 /dev/sda3
。要扩展您的根卷,您可以将此磁盘添加到 LVM(逻辑卷管理器):
pvcreate /dev/sda3
这会将未使用的磁盘 /dev/sda3
作为新的 pv(物理卷)添加到 LVM。
下一步是扩展您的根 vg(卷组)。在你的情况下很容易,因为你只有一个 vg:
vgextend centos /dev/sda3
现在您已经将 35GB 磁盘添加到您的 vg 中,您可以将其分配到您的 lv(逻辑卷)。
最后,您可以使用 lvextend
命令将 space 添加到您的根卷中(最多 35GB):
如果您想使用整个 35GB,您可以使用:
lvextend -l +100%FREE /dev/mapper/centos-root
如果你只想添加一定的数量(即 1G),你可以使用这个:
lvextend -L +1G /dev/mapper/centos-root
最后调整文件系统的大小:
resize2fs /dev/mapper/centos-root
LVM逻辑是:
1.硬盘fdisk -l
2.物理量pvs
3.卷组vgs
4.逻辑卷lvs