CentOS7根目录磁盘扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[root@xycvt99 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 17G 12M 100% /
devtmpfs 8.0G 0 8.0G 0% /dev
tmpfs 16G 1.4G 15G 9% /dev/shm
tmpfs 8.1G 106M 7.9G 2% /run
tmpfs 8.1G 0 8.1G 0% /sys/fs/cgroup
/dev/sdb1 197G 52G 135G 28% /opt
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 1.7G 0 1.7G 0% /run/user/0
tmpfs 1.7G 0 1.7G 0% /run/user/1009
[root@xycvt99 ~]# sudo fuser -km /opt
/opt: 3261ce 3590ce 3863ce 4628ce 9801ce 9829 9835ce 11643ce 11695ce 12835 14394ce 14396ce 14399ce 14401ce 14406ce 14408ce 14412ce 14415ce 14417ce 14420ce 14422ce 14424ce 14426ce 14428ce 14430ce 14432ce 14436ce 14438ce 14441ce 14443ce 14445ce 14447ce 14464ce 14466ce 14468ce 14470ce 14474ce 14476ce 14478ce 14480ce 14482ce 14817ce 14819ce 14822ce 14824ce 14826ce 14829ce 14831ce 15012ce 15026ce 15040ce 15465ce 15846ce 15848ce 15854ce 15856ce 15858ce 15860ce 15862ce 15864ce 15866ce 15868ce 15870ce 15872ce 15878ce 15890ce 15940ce 16429 16435 16437 16439 16442 16444 16446 16448 16563 16587ce 16959ce 16964ce 16981ce 16996 17002 17004 17006 17008 17010 17012 17014 17029ce 17048ce 17065ce 17092ce 17095 17100ce 17106ce 17111ce 17115ce 17935ce 30058 30308ce 30345
[root@xycvt99 ~]# umount /opt
[root@xycvt99 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 17G 5.9M 100% /
devtmpfs 8.0G 0 8.0G 0% /dev
tmpfs 16G 52K 16G 1% /dev/shm
tmpfs 8.1G 106M 7.9G 2% /run
tmpfs 8.1G 0 8.1G 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 1.7G 0 1.7G 0% /run/user/0
tmpfs 1.7G 0 1.7G 0% /run/user/1009

[root@xycvt99 ~]# fdisk -l

Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0x2294ea50

Device Boot Start End Blocks Id System
/dev/sdb1 2048 419430399 209714176 83 Linux

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000c339c

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 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

[root@xycvt99 ~]# lvextend -L +200G /dev/mapper/centos-root
Insufficient free space: 51200 extents needed, but only 0 available
[root@xycvt99 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <19.00g 0
[root@xycvt99 ~]# vgextend centos /dev/sdb
Device /dev/sdb excluded by a filter.
[root@xycvt99 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <19.00g 0
[root@xycvt99 ~]# vgextend centos /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
Volume group "centos" successfully extended
[root@xycvt99 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 218.99g <200.00g
[root@xycvt99 ~]# lvextend -L +200G /dev/mapper/centos-root
Insufficient free space: 51200 extents needed, but only 51199 available
[root@xycvt99 ~]# lvextend -L +199G /dev/mapper/centos-root
Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <216.00 GiB (55295 extents).
Logical volume centos/root successfully resized.
[root@xycvt99 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 17G 6.6M 100% /
devtmpfs 8.0G 0 8.0G 0% /dev
tmpfs 16G 52K 16G 1% /dev/shm
tmpfs 8.1G 106M 7.9G 2% /run
tmpfs 8.1G 0 8.1G 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 1.7G 0 1.7G 0% /run/user/0
tmpfs 1.7G 0 1.7G 0% /run/user/1009
[root@xycvt99 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4455424, 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 4455424 to 56622080
[root@xycvt99 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 216G 17G 200G 8% /
devtmpfs 8.0G 0 8.0G 0% /dev
tmpfs 16G 52K 16G 1% /dev/shm
tmpfs 8.1G 106M 7.9G 2% /run
tmpfs 8.1G 0 8.1G 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 1.7G 0 1.7G 0% /run/user/0
tmpfs 1.7G 0 1.7G 0% /run/user/1009