linux系统下扩容vg大小

几分钟前,我和大家探讨了新增vg如何操作,那么接下来我会和大家聊一下如何把已有的vg进行扩容,基础必会知识,请认真学习~~~~你们的拉菲

1.操作一样,我们还是再添加一块10G的硬盘,我又要吃土了·呜呜呜~~~

这里添加之后名字是sdb

[root@localhost ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/sda3                     18G  4.3G   14G  24% /
devtmpfs                     471M     0  471M   0% /dev
tmpfs                        487M     0  487M   0% /dev/shm
tmpfs                        487M  8.5M  478M   2% /run
tmpfs                        487M     0  487M   0% /sys/fs/cgroup
/dev/sda1                    297M  147M  151M  50% /boot
tmpfs                         98M   20K   98M   1% /run/user/1000
/dev/mapper/vgdata1-Lvdata1  9.7G   37M  9.1G   1% /opt/a
[root@localhost ~]# 

[root@localhost ~]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   20G  0 disk 
├─sda1              8:1    0  300M  0 part /boot
├─sda2              8:2    0    2G  0 part [SWAP]
└─sda3              8:3    0 17.7G  0 part /
sdb                 8:16   0   10G  0 disk 
sdc                 8:32   0   10G  0 disk 
└─vgdata1-Lvdata1 253:0    0  9.9G  0 lvm  
sr0                11:0    1 1024M  0 rom  
[root@localhost ~]# 
[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000dad8d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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/sdc: 10.7 GB, 10737418240 bytes, 20971520 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/vgdata1-Lvdata1: 10.6 GB, 10632560640 bytes, 20766720 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

[root@localhost ~]# 
2.将sdb这个硬盘创建成PV
[root@localhost ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
[root@localhost ~]# vgs
  VG      #PV #LV #SN Attr   VSize   VFree 
  vgdata1   1   1   0 wz--n- <10.00g 96.00m
[root@localhost ~]# 
3.将硬盘sdb扩张到我们vgdata1这个VG中
[root@localhost ~]# vgextend vgdata1 /dev/sdb
  Volume group "vgdata1" successfully extended
[root@localhost ~]# vgs
  VG      #PV #LV #SN Attr   VSize  VFree  
  vgdata1   2   1   0 wz--n- 19.99g <10.09g

4.扩展vgdata1-Lvdata1,新增刚刚添加的10GB
[root@localhost ~]# lvextend -L +9.9G /dev/vgdata1/Lvdata1 
  Rounding size to boundary between physical extents: 9.90 GiB.
  Size of logical volume vgdata1/Lvdata1 changed from 9.90 GiB (2535 extents) to 19.80 GiB (5070 extents).
  Logical volume vgdata1/Lvdata1 successfully resized.
[root@localhost ~]# 

5.将扩展空间赋予文件系统
[root@localhost mapper]# resize2fs /dev/mapper/vgdata1-Lvdata1 
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vgdata1-Lvdata1 is mounted on /opt/a; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/mapper/vgdata1-Lvdata1 is now 5191680 blocks long.

[root@localhost mapper]# 
6.到此扩展成功
[root@localhost mapper]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/sda3                     18G  4.3G   14G  24% /
devtmpfs                     471M     0  471M   0% /dev
tmpfs                        487M     0  487M   0% /dev/shm
tmpfs                        487M  8.5M  478M   2% /run
tmpfs                        487M     0  487M   0% /sys/fs/cgroup
/dev/sda1                    297M  147M  151M  50% /boot
tmpfs                         98M   20K   98M   1% /run/user/1000
/dev/mapper/vgdata1-Lvdata1   20G   44M   19G   1% /opt/a
[root@localhost mapper]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   20G  0 disk 
├─sda1              8:1    0  300M  0 part /boot
├─sda2              8:2    0    2G  0 part [SWAP]
└─sda3              8:3    0 17.7G  0 part /
sdb                 8:16   0   10G  0 disk 
└─vgdata1-Lvdata1 253:0    0 19.8G  0 lvm  /opt/a
sdc                 8:32   0   10G  0 disk 
└─vgdata1-Lvdata1 253:0    0 19.8G  0 lvm  /opt/a
sr0                11:0    1 1024M  0 rom  
[root@localhost mapper]# 

快乐的时光总是很短暂,生活也是一样,要先苦后甜~~~
下一边
待定~~~~~

Logo

更多推荐