【学习】Centos7 磁盘扩容

一、背景
zstack创建的centos7虚拟机磁盘不足,加载磁盘后进行扩容。
二、步骤
1.查看当前磁盘情况,找到新挂载的磁盘,此处为/dev/sda
fdisk -l
2.新增磁盘分区
$ fdisk /dev/sda 
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.


Command (m for help): p #查看以分区数量(存在两个sda1和sda2)

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000bc5e0

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

Command (m for help): n # 新增一个分区
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p # 分区类型为主分区
Partition number (3,4, default 3): 3 #因为已经存在两个分区,所以分区号为3
First sector (41943040-83886079, default 41943040): 
Using default value 41943040
Last sector, +sectors or +size{K,M,G} (41943040-83886079, default 83886079): 
Using default value 83886079
Partition 3 of type Linux and of size 20 GiB is set
Command (m for help): t #修改分区类型
Partition number (1-3, default 3): 3 #分区号
Hex code (type L to list all codes): 8e #分区类型为8e
Changed type of partition 'XENIX usr' to 'Linux LVM'

Command (m for help): w # 写入分区表
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
$ reboot # 分区后需要重启
3.硬盘格式化
mkfs.ext3 /dev/sda3
4.添加新LVM到已存在的LVM,进行扩容
pvcreate /dev/sda3
vgdisplay -v #查看vgroup 通过和df -h比对,找到需要扩容的磁盘的VGNANE,此处为root
vgextend root /dev/sda3
lvextend -L +50G /dev/mapper/cl-root
5.文件系统扩容
xfs_growfs /dev/mapper/cl-root 

#查看硬盘信息
df -Th
三、问题总结
1.vgextend root /dev/sda3 执行这步的时候报错vgroup不存在
vgdisplay -v,我把LV Name误填上去,此处应该填VG Name
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值