• 虚拟机(Vmware)磁盘扩容(xfs格式)


     先将虚拟机关机,按上图调整虚拟磁盘大小。

    1.开启并进入虚拟机,打开终端,输入命令 df -Th 查看格式,图示中 /dev/mapper/centos-root 类型为xfs。

    1. [mango@localhost ~]$ df -Th
    2. Filesystem Type Size Used Avail Use% Mounted on
    3. devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
    4. tmpfs tmpfs 1.9G 16K 1.9G 1% /dev/shm
    5. tmpfs tmpfs 1.9G 13M 1.9G 1% /run
    6. tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
    7. /dev/mapper/centos-root xfs 97G 18G 80G 18% /
    8. /dev/sda1 xfs 1014M 185M 830M 19% /boot
    9. tmpfs tmpfs 378M 0 378M 0% /run/user/1004
    10. tmpfs tmpfs 378M 24K 378M 1% /run/user/1000
    11. [mango@localhost ~]$

    2.执行 fdisk -l 命令查看磁盘容量,Disk /dev/sda: 107.4 GB

    1. [root@localhost mango]# fdisk -l
    2. Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
    3. Units = sectors of 1 * 512 = 512 bytes
    4. Sector size (logical/physical): 512 bytes / 512 bytes
    5. I/O size (minimum/optimal): 512 bytes / 512 bytes
    6. Disk label type: dos
    7. Disk identifier: 0x000a56ed
    8. Device Boot Start End Blocks Id System
    9. /dev/sda1 * 2048 2099199 1048576 83 Linux
    10. /dev/sda2 2099200 41943039 19921920 8e Linux LVM
    11. Disk /dev/mapper/centos-root: 104.1 GB, 104144568320 bytes, 203407360 sectors
    12. Units = sectors of 1 * 512 = 512 bytes
    13. Sector size (logical/physical): 512 bytes / 512 bytes
    14. I/O size (minimum/optimal): 512 bytes / 512 bytes
    15. Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
    16. Units = sectors of 1 * 512 = 512 bytes
    17. Sector size (logical/physical): 512 bytes / 512 bytes
    18. I/O size (minimum/optimal): 512 bytes / 512 bytes

    3. 新建分区

    执行命令:fdisk /dev/sda

    然后输入m->n->p->回车->回车->回车->w

    1. WARNING: Re-reading the partition table failed with error 16
    2. The kernel still uses the old table. The new table will be used at
    3. the next reboot or after you run partprobe(8) or kpartx(8)

    然后重起机器,执行命令:reboot ,重启之后执行命令:fdisk -l 查看分区,新的分区号是3

    1. [root@localhost mango]# fdisk -l
    2. Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
    3. Units = sectors of 1 * 512 = 512 bytes
    4. Sector size (logical/physical): 512 bytes / 512 bytes
    5. I/O size (minimum/optimal): 512 bytes / 512 bytes
    6. Disk label type: dos
    7. Disk identifier: 0x000a56ed
    8. Device Boot Start End Blocks Id System
    9. /dev/sda1 * 2048 2099199 1048576 83 Linux
    10. /dev/sda2 2099200 41943039 19921920 8e Linux LVM
    11. /dev/sda3 41943040 209715199 83886080 83 Linux
    12. Disk /dev/mapper/centos-root: 104.1 GB, 104144568320 bytes, 203407360 sectors
    13. Units = sectors of 1 * 512 = 512 bytes
    14. Sector size (logical/physical): 512 bytes / 512 bytes
    15. I/O size (minimum/optimal): 512 bytes / 512 bytes
    16. Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
    17. Units = sectors of 1 * 512 = 512 bytes
    18. Sector size (logical/physical): 512 bytes / 512 bytes
    19. I/O size (minimum/optimal): 512 bytes / 512 bytes

    4.对/dev/sda3进行格式化

    执行命令:mkfs.xfs /dev/sda3

    1. meta-data=/dev/sda3 isize=512 agcount=4, agsize=67108864 blks
    2. = sectsz=512 attr=2, projid32bit=1
    3. = crc=1 finobt=0, sparse=0
    4. data = bsize=4096 blocks=268435455, imaxpct=25
    5. = sunit=0 swidth=0 blks
    6. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
    7. log =internal log bsize=4096 blocks=131071, version=2
    8. = sectsz=512 sunit=0 blks, lazy-count=1
    9. realtime =none extsz=4096 blocks=0, rtextents=0

    5.创建pv

    执行命令:pvcreate /dev/sda3,然后输入y。

    1. WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
    2. Wiping xfs signature on /dev/sda3.
    3. Physical volume "/dev/sda3" successfully created.

    6.处理逻辑卷

    执行命令: vgs

    1. VG #PV #LV #SN Attr VSize VFree
    2. centos 1 3 0 wz--n- <40.00g 4.00m

    执行命令:vgextend centos /dev/sda3

    Volume group "centos" successfully extended

    执行命令: vgs

    1. VG #PV #LV #SN Attr VSize VFree
    2. centos 2 3 0 wz--n- <100.00g 60.00g

    可以看到由原来的40G变成100G。其中60G是空闲的.

    7.扩容

    执行命令 df -h 查看要扩容的文件系统的位置 ,这是是/dev/mapper/centos-root

    1. devtmpfs 7.8G 0 7.8G 0% /dev
    2. tmpfs 7.8G 0 7.8G 0% /dev/shm
    3. tmpfs 7.8G 8.9M 7.8G 1% /run
    4. tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
    5. /dev/mapper/centos-root 100G 40G 60G 60% /
    6. /dev/sda1 1014M 188M 827M 19% /boot
    7. tmpfs 1.6G 0 1.6G 0% /run/user/0

    执行命令 lvextend -l +100%free /dev/mapper/centos-root  

    1. Size of logical volume centos/root changed from <40.00 GiB (244470 extents) to 99 G iB(504414 extents).
    2. Logical volume centos/root successfully resized.

    执行命令 xfs_growfs /dev/mapper/centos-root ,扩容,调整分区。

    1. meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=63249920 blks
    2. = sectsz=512 attr=2, projid32bit=1
    3. = crc=1 finobt=0 spinodes=0
    4. data = bsize=4096 blocks=252999680, imaxpct=25
    5. = sunit=0 swidth=0 blks
    6. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
    7. log =internal bsize=4096 blocks=123535, version=2
    8. = sectsz=512 sunit=0 blks, lazy-count=1
    9. realtime =none extsz=4096 blocks=0, rtextents=0
    10. data blocks changed from 252888680 to 521435136

     最后执行命令 df -h 查看结果,/dev/mapper/centos-root   97G   18G   80G  18% / 扩容成功。

    1. [root@localhost mango]# df -h
    2. Filesystem Size Used Avail Use% Mounted on
    3. devtmpfs 1.9G 0 1.9G 0% /dev
    4. tmpfs 1.9G 16K 1.9G 1% /dev/shm
    5. tmpfs 1.9G 14M 1.9G 1% /run
    6. tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
    7. /dev/mapper/centos-root 97G 18G 80G 18% /
    8. /dev/sda1 1014M 185M 830M 19% /boot
    9. tmpfs 378M 0 378M 0% /run/user/1004
    10. tmpfs 378M 24K 378M 1% /run/user/1000
    11. tmpfs 378M 0 378M 0% /run/user/0

  • 相关阅读:
    Python数据分析案例51——基于K均值的客户聚类分析可视化
    Hadoop、Hive、Spark 之间的关系
    Git远端操作命令
    国产DSP FT-M6678开发-实操篇(仿真器的安装以及连接)
    linux git 流程操作
    抗锯齿渲染
    java垃圾回收-三色标记法
    window 编译生成darknet (cuda11.1+opencv4.5+vs2019)
    上拉加载更多异步请求?
    springboot升级过程中踩坑定位分析记录 | 京东云技术团队
  • 原文地址:https://blog.csdn.net/mangobot/article/details/127865709