划分分区组成逻辑卷和扩展根分区
16lz
2021-03-10
场景
将磁盘剩余的空闲空间分区,合并到逻辑卷,扩展根分区
当前环境
[root@web ~]# df -Th文件系统 类型 容量 已用 可用 已用% 挂载点devtmpfs devtmpfs 7.7G 0 7.7G 0% /devtmpfs tmpfs 7.7G 0 7.7G 0% /dev/shmtmpfs tmpfs 7.7G 23M 7.7G 1% /runtmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup/dev/mapper/centos-root xfs 50G 4.2G 46G 9% //dev/vda2 xfs 1014M 123M 892M 13% /boot/dev/vda1 vfat 200M 9.9M 190M 5% /boot/efi/dev/mapper/centos-cce_log_lv xfs 50G 33M 50G 1% /var/paas/log/dev/mapper/centos-cce_run_lv xfs 50G 33M 50G 1% /var/paas/run/dev/mapper/centos-cce_data_lv xfs 50G 33M 50G 1% /var/paas/data/dev/mapper/centos-cce_docker_lv xfs 200G 33M 200G 1% /var/lib/dockertmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/vda还有700GB的空闲空间
[root@web ~]# fdisk /dev/vdaWARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):p磁盘 /dev/vda:1288.5 GB, 1288490188800 字节,2516582400 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:gptDisk identifier: 969EEF2C-6948-4CB3-9524-FF484F98D8B2
# Start End Size Type Name 1 2048 411647 200M EFI System EFI System Partition 2 411648 2508799 1G Microsoft basic 3 2508800 1048573951 498.8G Linux LVM
说明:当前磁盘还剩下788GB的空闲空间
第一步:将剩余空间分区
[root@web ~]# parted /dev/vda(parted) print 错误: 备份 GPT 表不像应该的那样出现在磁盘的末尾。这可能意味这其它操作系统相信磁盘小一些。通过将备份移动到末尾 (并删除旧备份) 来修正?修正/Fix/忽略/Ignore/放弃/Cancel? Fix 警告: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of thespace (an extra 1468006400 blocks) or continue with the current setting? 修正/Fix/忽略/Ignore? Fix Model: Virtio Block Device (virtblk)Disk /dev/vda: 1288GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志 1 1049kB 211MB 210MB fat16 EFI System Partition 启动 2 211MB 1285MB 1074MB xfs 3 1285MB 537GB 536GB lvm(parted) mkpart 分区名称? []? 4 文件系统类型? [ext2]? xfs 起始点? 538GB 结束点? 1288GB (parted) print Model: Virtio Block Device (virtblk)Disk /dev/vda: 1288GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志 1 1049kB 211MB 210MB fat16 EFI System Partition 启动 2 211MB 1285MB 1074MB xfs 3 1285MB 537GB 536GB lvm 4 538GB 1288GB 750GB 4(parted) quit 信息: You may need to update /etc/fstab.
说明:退出自动保存,不像fdisk需要保存
第二步格式化分区
[root@web ~]# mkfs.xfs /dev/vda4meta-data=/dev/vda4 isize=512 agcount=4, agsize=45806208 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=183224832, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=89465, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0
查看当前的逻辑卷名称
[root@web ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 9 VG Access read/write VG Status resizable MAX LV 0 Cur LV 6 Open LV 6 Max PV 0 Cur PV 1 Act PV 1 VG Size 498.80 GiB PE Size 4.00 MiB Total PE 127693 Alloc PE / Size 104448 / 408.00 GiB Free PE / Size 23245 / 90.80 GiB VG UUID NJ00md-D6JB-WGg3-PDZ2-NsE3-fBzK-Y3IjqA
第三步:逻辑化分区/dev/vda4,准备给centos逻辑卷扩容
[root@web ~]# pvcreate /dev/vda4WARNING: xfs signature detected on /dev/vda4 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/vda4. Physical volume "/dev/vda4" successfully created.
第四步:开始扩容
[root@web ~]# vgextend centos /dev/vda4 Volume group "centos" successfully extended[root@web ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 14 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 <1.17 TiB PE Size 4.00 MiB Total PE 306623 Alloc PE / Size 14848 / 58.00 GiB Free PE / Size 291775 / 1.11 TiB VG UUID NJ00md-D6JB-WGg3-PDZ2-NsE3-fBzK-Y3IjqA
说明:磁盘空闲空间增长到1T,说明扩容成功
第五步:扩容/dev/mapper/centos-root逻辑卷分区
[root@web ~]# lvextend -L 1000G /dev/mapper/centos-root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 1000.00 GiB (256000 extents). Logical volume centos/root successfully resized.
第六步:更新逻辑卷分区的大小
[root@web ~]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0
你的赞赏是我请进的动力
赞赏
0人进行了赞赏支持
更多相关文章
- Spark2.x精通:源码剖析BypassMergeSortShuffleWriter具体实现
- Oracle面试题及答案整理,速速收藏
- 分区表
- 2021-2-23:Java 文件映射内存是如何更新到硬盘文件的,什么情况下会
- 操作系统——计算机硬件简介
- 2.33 在windows 2012中创建iSCSI虚拟磁盘和iSCSI目标
- 只有1个字节的文件实际占用多少磁盘空间
- 新建一个空文件占用多少磁盘空间?
- 磁盘分区也是隐含了技术技巧的