linux磁盘扩容

1、添加新磁盘(略)
2、查看添加的磁盘

node5:~ # fdisk -l

Disk /dev/xvda: 40 GiB, 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
Disklabel type: dos
Disk identifier: 0x0005f01f

Device     Boot   Start      End  Sectors  Size Id Type
/dev/xvda1         2048  2988031  2985984  1.4G 82 Linux swap / Solaris
/dev/xvda2 *    2988032 83886079 80898048 38.6G 83 Linux

Disk /dev/xvdb: 500 GiB, 536870912000 bytes, 1048576000 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 /dev/mapper/VolGroup00-LogVol00: 500 GiB, 536866717696 bytes, 1048567808 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 /dev/xvdc: 1000 GiB, 1073741824000 bytes, 2097152000 sectors  #此处添加了一块1000G的磁盘
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

3、增加分区

node5:~ # fdisk /dev/xvdc

Welcome to fdisk (util-linux 2.25).
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.
Created a new DOS disklabel with disk identifier 0xd53125b0.

Command (m for help): n     #创建新分区
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p            # p为主分区    e为扩展分区
Partition number (1-4, default 1): 3       #磁盘的编号,不重复即可
First sector (2048-2097151999, default 2048):         #默认即可,直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151999, default 2097151999):   #默认即可,直接回车

Created a new partition 3 of type 'Linux' and of size 1000 GiB.

Command (m for help): t           #输入t
Selected partition 3
Hex code (type L to list all codes): 8e          #输入8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w              #保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

4、初始化分区并加入卷组
4.1、卷扩容添加进LVM组

pvcreate /dev/xvdc3	初始化刚才的分区
node5:~ # pvcreate /dev/xvdc3
  Physical volume "/dev/xvdc3" successfully created

4.2、查看卷组并将初始化的分区加入到虚拟卷组
为卷组VolGroup00添加新的物理卷/dev/xvdc3增加卷组的容量

node5:~ # vgdisplay 
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               500.00 GiB
  PE Size               4.00 MiB
  Total PE              127999
  Alloc PE / Size       127999 / 500.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               VG2XU7-DhS6-4814-UuJJ-2di3-iF2T-HjUq0d

4.3、将初始化的分区加入到虚拟组

node5:~ # vgextend VolGroup00 /dev/xvdc3
  Volume group "VolGroup00" successfully extended

5、扩展逻辑卷的大小
5.1、现在才能扩展逻辑卷的大小

node5:~ # lvextend -L +995G /dev/mapper/VolGroup00-LogVol00
  Size of logical volume VolGroup00/LogVol00 changed from 500.00 GiB (127999 extents) to 1.46 TiB (382719 extents).
  Logical volume LogVol00 successfully resized

5.2、最后使用resizefs2命令重新加载逻辑卷的大小才能生效

node5:~ # resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.42.11 (09-Jul-2014)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /app; on-line resizing required
old_desc_blocks = 32, new_desc_blocks = 94
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 391904256 blocks long.

5.3、检查磁盘容量

node5:~ # df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/xvda2                        38G  3.9G   33G  11% /
devtmpfs                          16G     0   16G   0% /dev
tmpfs                             16G     0   16G   0% /dev/shm
tmpfs                             16G  922M   15G   6% /run
tmpfs                             16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/VolGroup00-LogVol00  1.5T  430G  977G  31% /app     #此为新增加的磁盘容量
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维那些事~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值