v1.1更新,添加移除未知PV块
新建了
SVN
服务器给美术当素材版本控制库,数据量挺大的,有八十多个G
,当时创建了虚拟机的时候没注意仅分配了100G
给SVN
,后面把原始数据上传到SVN的时候就爆了,报错提示:no space left on device
。
因此在ESXI6.7
控制台给虚拟机硬盘扩容到500G
,然后SSH
连上虚拟机进行配置!
1. 先给新加的硬盘分区
[root@gitlab 192.168.0.172]# fdisk /dev/sdb
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xafd39243.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2. 分区完通知内核强制重读分区表或重启系统并创建文件系统:
kpartx -af /dev/sda3 #3是新分的区,得具体看是多少
[root@gitlab 192.168.0.172]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=13107136 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=52428544, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=25599, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
3. 新建PV
块
[root@svn ~]# 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@svn ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_svn
PV Size <99.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25343
Free PE 1
Allocated PE 25342
PV UUID aF1qWH-bdd2-Mgh3-5qGb-caFw-NueY-LsrSn3
"/dev/sda3" is a new physical volume of "400.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 400.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID vk2ayU-18XI-MM19-Bc4C-85yE-tSh3-M1RgK6
4. 将新建的PV
加入VG
组
[root@svn ~]# vgextend centos_svn /dev/sda3
Volume group "centos_svn" successfully extended
[root@svn ~]# vgdisplay
--- Volume group ---
VG Name centos_svn
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 498.99 GiB
PE Size 4.00 MiB
Total PE 127742
Alloc PE / Size 25342 / 98.99 GiB
Free PE / Size 102400 / 400.00 GiB
VG UUID Mv6SUs-3jPz-N8ZZ-tx31-vIlV-Us50-ly5DlF
#一定要注意PE大小,如上是4M一块,下面扩容时要用到
5. 给VG
扩容
[root@svn ~]# lvresize -l +102400 /dev/mapper/centos_svn-root
Size of logical volume centos_svn/root changed from 50.00 GiB (12800 extents) to 450.00 GiB (115200 extents).
Logical volume centos_svn/root successfully resized.
#如上所示,4M一块那么400G就是102400块,不用用+400G这样子哦,会有语法错误
如果因为种种意外导致PV块status为unknown时,扩容就会失败,这时pvdisplay就可以看到有PV为unknown,此时可以使用以下命令修复:
sudo vgreduce --removemissing VGNAME #VGNAME对应实际的vg即可
6. 重读PV
大小
#其实也可以使用resize2fs命令,xfs_growfs命令仅适用于xfs文件系统
[root@svn ~]# xfs_growfs /dev/mapper/centos_svn-root
meta-data=/dev/mapper/centos_svn-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 117964800
7. 确认扩容结果
[root@svn ~]# 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 8.9M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos_svn-root 450G 41G 410G 9% /
/dev/sda1 1014M 150M 865M 15% /boot
/dev/mapper/centos_svn-home 46G 33M 46G 1% /home
tmpfs 379M 0 379M 0% /run/user/0