侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CentsOS 7 LVM磁盘扩容

2023-12-10 星期日 / 0 评论 / 0 点赞 / 123 阅读 / 7753 字

简要说明哈情况:默认分的磁盘空间不够需要扩容,呵呵!查找资料实践后记录哈步骤。 查看现有磁盘空间占用情况 [root@x cc]# df -h文件系统 容量

简要说明哈情况:默认分的磁盘空间不够需要扩容,呵呵!查找资料实践后记录哈步骤。

  1. 查看现有磁盘空间占用情况
    [root@x cc]# df -h文件系统                    容量  已用  可用   已用% 挂载点/dev/mapper/centos-root   18G  5.7G   12G   33% /devtmpfs                 898M     0  898M    0% /devtmpfs                    913M   53M  861M    6% /dev/shmtmpfs                    913M  8.9M  904M    1% /runtmpfs                    913M     0  913M    0% /sys/fs/cgroup/dev/sda1                497M  211M  286M   43% /boottmpfs                    183M   12K  183M    1% /run/user/1000

     

  2.  对新增的硬盘空间新增分区(具体显示根据系统环境确定)

    [root@x cc]# fdisk /dev/sda欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):n #新增分区......pPartition number (1-4): 3 #新增分区号(1,2已经使用)First cylinder (41943040-62914559, default 41943040): #默认回车......Last cylinder or +size or +sizeM or +sizeK(41943040-62914559, default 62914559): #默认回车命令(输入 m 获取帮助):t #修改分区类型Partition number (1-4): 3 #修改分区类型对应的分区号Hex code (type L to list codes): 8e #8e是lvm磁盘类型......命令(输入 m 获取帮助):p #查看打印分区表命令(输入 m 获取帮助):w #保存退出......[root@x cc]# reboot #重启系统

     

  3.  查看硬盘情况

    [root@x cc]# fdisk -l......   设备 Boot         Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    41943039    20458496   8e  Linux LVM/dev/sda3        41943040    62914559    10485760   8e  Linux LVM......

     

  4.  查看当前分区类型

    [root@x cc]# df -T /dev/sda1文件系统       类型  1K-块   已用   可用 已用% 挂载点/dev/sda1      xfs  ......#CentOS7的默认文件系统类型是xfs

     

  5.  新磁盘创建文件系统

    [root@x cc]# mkfs.xfs /dev/sda3 #xfs如上文件系统类型meta-data=/dev/sda3              isize=256    agcount=4, agsize=655360 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=0        finobt=0data     =                       bsize=4096   blocks=2621440, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=0log      =internal log           bsize=4096   blocks=2560, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0

     

  6.  创建PV(PV【物理卷】是VG【卷组】的组成部分,LV【逻辑卷】就是从VG中划分出来的卷,深究的建议查哈资料)

    [root@x cc]# pvcreate /dev/sda3WARNING: 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@x cc]# vgdisplay #查看vg状态

     

  7.  创建的PV加入VG

    [root@x cc]# vgextend centos /dev/sda3  #centos为查看vg状态得到名称VG name  Volume group "centos" successfully extended

     

  8.  查看LV状态

    [root@x cc]# lvdisplay......  --- Logical volume ---  LV Path                /dev/centos/root  LV Name                root  VG Name                centos  LV UUID                .............  LV Write Access        read/write  LV Creation host, time x, 2016-06-16 09:19:45 +0800  LV Status              available  # open                 1  LV Size                17.47 GiB  Current LE             4472  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:0[root@x cc]# pvdisplay #查看pv状态--- Physical volume ---  PV Name               /dev/sda3  VG Name               centos  PV Size               10.00 GiB / not usable 4.00 MiB  Allocatable           yes   PE Size               4.00 MiB  Total PE              2559  Free PE               2559  Allocated PE          0  PV UUID               ...................

     

  9.  逻辑卷扩容

    [root@x cc]# lvextend -l +2559 /dev/centos/root  Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 27.46 GiB (7031 extents).  Logical volume root successfully resized.#2559为上面pvdisplay查看到的free的PE数量

     

  10.  resize2fs调整大小

    [root@x cc]# resize2fs /dev/mapper/centos-root #/dev/mapper/centos-root为“/”挂载点的名字,df -h命令中查看。resize2fs 1.42.9 (28-Dec-2013)resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时找不到有效的文件系统超级块.-------------------------------------------------------------#这里有个错误(主要因为xfs文件系统:扩展一个现存的XFS文件系统,使用命令行工具xfs_grows)提示解决如下[root@x cc]# lvs  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert  root centos -wi-ao---- 27.46g                                                      swap centos -wi-ao----  2.00g                                                    [root@x cc]# df -lh文件系统                 容量  已用  可用 已用% 挂载点/dev/mapper/centos-root   18G  5.7G   12G   33% /devtmpfs                 898M     0  898M    0% /devtmpfs                    913M   71M  843M    8% /dev/shmtmpfs                    913M  8.9M  904M    1% /runtmpfs                    913M     0  913M    0% /sys/fs/cgroup/dev/sda1                497M  211M  286M   43% /boottmpfs                    183M   12K  183M    1% /run/user/1000[root@x cc]# xfs_growfs /dev/mapper/centos-rootmeta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1144832 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=0        finobt=0data     =                       bsize=4096   blocks=4579328, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=0log      =internal               bsize=4096   blocks=2560, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 4579328 to 7199744[root@x cc]# df -lh文件系统                 容量  已用  可用 已用% 挂载点/dev/mapper/centos-root   28G  5.7G   22G   21% /devtmpfs                 898M     0  898M    0% /devtmpfs                    913M   71M  843M    8% /dev/shmtmpfs                    913M  8.9M  904M    1% /runtmpfs                    913M     0  913M    0% /sys/fs/cgroup/dev/sda1                497M  211M  286M   43% /boottmpfs                    183M   12K  183M    1% /run/user/1000#显示扩展已完成

    PS:具体步骤如上了,已实践测试! 

广告 广告

评论区