Centos7新加磁盘扩容根分区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | df -Th lsblk fdisk /dev/sdb lsblk pvcreate /dev/sdb1 pvdisplay vgdisplay vgextend centos /dev/sdb1 vgdisplay pvdisplay lvdisplay lvextend -l +100%FREE /dev/centos/root df -Th xfs_growfs /dev/centos/root df -Th |
实例:
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | [root@iser-monitor01 alertmanager] # df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 50G 15G 36G 29% / devtmpfs devtmpfs 16G 0 16G 0% /dev tmpfs tmpfs 16G 0 16G 0% /dev/shm tmpfs tmpfs 16G 8.4M 16G 1% /run tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda2 xfs 1014M 153M 862M 16% /boot /dev/sda1 vfat 200M 9.9M 190M 5% /boot/efi /dev/mapper/centos-opt xfs 15G 33M 15G 1% /opt /dev/mapper/centos-home xfs 8.8G 34M 8.8G 1% /home /dev/mapper/centos-var xfs 25G 901M 25G 4% /var tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@iser-monitor01 alertmanager] # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 98.8G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-home 253:1 0 8.8G 0 lvm /home ├─centos-var 253:2 0 25G 0 lvm /var └─centos-opt 253:3 0 15G 0 lvm /opt sdb 8:16 0 1000G 0 disk sr0 11:0 1 1024M 0 rom [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # 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 0x47379b16. The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I /O ) size boundary is recommended, or performance may be impacted. 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-2097151999, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-2097151999, default 2097151999): Using default value 2097151999 Partition 1 of type Linux and of size 1000 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re- read partition table. Syncing disks. [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 98.8G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-home 253:1 0 8.8G 0 lvm /home ├─centos-var 253:2 0 25G 0 lvm /var └─centos-opt 253:3 0 15G 0 lvm /opt sdb 8:16 0 1000G 0 disk └─sdb1 8:17 0 1000G 0 part sr0 11:0 1 1024M 0 rom [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created. [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name centos PV Size 98.80 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 25293 Free PE 0 Allocated PE 25293 PV UUID ODqte0-9QiK-RlxG-8xb0-aYvJ-yfHT-KcR865 "/dev/sdb1" is a new physical volume of "<1000.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size <1000.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID Fv2FF9-TUW9-lZID-NFO3-ukAI-ECh3-mNXtQL [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 5 VG Access read /write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 1 Act PV 1 VG Size 98.80 GiB PE Size 4.00 MiB Total PE 25293 Alloc PE / Size 25293 / 98.80 GiB Free PE / Size 0 / 0 VG UUID t7qcU4-pN1v-DaeN-keN1-oWDI-4tLY-epo0Xg [root@iser-monitor01 alertmanager] # vgextend centos /dev/sdb1 Volume group "centos" successfully extended [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 6 VG Access read /write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 2 Act PV 2 VG Size 1.07 TiB PE Size 4.00 MiB Total PE 281292 Alloc PE / Size 25293 / 98.80 GiB Free PE / Size 255999 / <1000.00 GiB VG UUID t7qcU4-pN1v-DaeN-keN1-oWDI-4tLY-epo0Xg [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name centos PV Size 98.80 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 25293 Free PE 0 Allocated PE 25293 PV UUID ODqte0-9QiK-RlxG-8xb0-aYvJ-yfHT-KcR865 --- Physical volume --- PV Name /dev/sdb1 VG Name centos PV Size <1000.00 GiB / not usable 3.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 255999 Free PE 255999 Allocated PE 0 PV UUID Fv2FF9-TUW9-lZID-NFO3-ukAI-ECh3-mNXtQL [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # lvdisplay --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID gleQmV-qoeH-ZHz3-HSUG-IvDh-a77j-mIMkDn LV Write Access read /write LV Creation host, time localhost, 2019-12-19 16:17:52 +0800 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID V63xl5-dp70-FIlc-rjHm-93nm-LoJz-wWfi36 LV Write Access read /write LV Creation host, time localhost, 2019-12-19 16:17:55 +0800 LV Status available # open 1 LV Size 8.80 GiB Current LE 2253 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/var LV Name var VG Name centos LV UUID WqXYBN-MpWJ-WuIv-06oh-CDhp-f38c-14W587 LV Write Access read /write LV Creation host, time localhost, 2019-12-19 16:17:56 +0800 LV Status available # open 1 LV Size 25.00 GiB Current LE 6400 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/centos/opt LV Name opt VG Name centos LV UUID BDLVE6-sYIw-a4yD-Vodu-83Fl-UyAi-sgixFk LV Write Access read /write LV Creation host, time localhost, 2019-12-19 16:17:58 +0800 LV Status available # open 1 LV Size 15.00 GiB Current LE 3840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 [root@iser-monitor01 alertmanager] # lvextend -l +100%FREE /dev/centos/root Size of logical volume centos /root changed from 50.00 GiB (12800 extents) to <1.03 TiB (268799 extents). Logical volume centos /root successfully resized. [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 50G 15G 36G 29% / devtmpfs devtmpfs 16G 0 16G 0% /dev tmpfs tmpfs 16G 0 16G 0% /dev/shm tmpfs tmpfs 16G 8.4M 16G 1% /run tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda2 xfs 1014M 153M 862M 16% /boot /dev/sda1 vfat 200M 9.9M 190M 5% /boot/efi /dev/mapper/centos-opt xfs 15G 33M 15G 1% /opt /dev/mapper/centos-home xfs 8.8G 34M 8.8G 1% /home /dev/mapper/centos-var xfs 25G 901M 25G 4% /var tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@iser-monitor01 alertmanager] # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 98.8G 0 part ├─centos-root 253:0 0 1T 0 lvm / ├─centos-home 253:1 0 8.8G 0 lvm /home ├─centos-var 253:2 0 25G 0 lvm /var └─centos-opt 253:3 0 15G 0 lvm /opt sdb 8:16 0 1000G 0 disk └─sdb1 8:17 0 1000G 0 part └─centos-root 253:0 0 1T 0 lvm / sr0 11:0 1 1024M 0 rom [root@iser-monitor01 alertmanager] # xfs_growfs /dev/centos/root meta-data= /dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=4096 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=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 275250176 [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # [root@iser-monitor01 alertmanager] # df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 1.1T 15G 1.1T 2% / devtmpfs devtmpfs 16G 0 16G 0% /dev tmpfs tmpfs 16G 0 16G 0% /dev/shm tmpfs tmpfs 16G 8.4M 16G 1% /run tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda2 xfs 1014M 153M 862M 16% /boot /dev/sda1 vfat 200M 9.9M 190M 5% /boot/efi /dev/mapper/centos-opt xfs 15G 33M 15G 1% /opt /dev/mapper/centos-home xfs 8.8G 34M 8.8G 1% /home /dev/mapper/centos-var xfs 25G 901M 25G 4% /var tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@iser-monitor01 alertmanager] # |
本文作者:香菜哥哥
本文链接:https://www.cnblogs.com/yizhipanghu/p/15028786.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步