侧边栏壁纸
博主头像
TLYAN

只要芝麻,不要西瓜.............纯大神之作
古人有雲:吃得苦中苦方為人上人

  • 累计撰写 113 篇文章
  • 累计收到 5 条评论
lvm的vg扩容
2020-05-13 09:49:06 2123阅读 0评论 0点赞

以下暂时是网上资料  经过了修补,但是因为是第一次操作我全部格式化了,所以下面操作部分待验证(待修复补充)


本次扩容的目的是要扩展 / 的整体容量,具体操作如下:

1、首先查看是否存在未分配的磁盘

[root@NH-Test-44 ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00020122

Device Boot Start End Blocks Id System
/dev/vda1 * 3 409 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 409 104023 52221760 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/vdb: 10.7 GB, 10737418240 bytes  //大概是这样子,实际上这里已经被格式化了
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

2、格式化成lvm特定的8e格式

[root@localhost ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb86ae868.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-145634, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-145634, default 145634):
Using default value 145634

Command (m for help): t   //注意这步的操作
Selected partition 1
Hex code (type L to list codes): 8e          //写8e
Changed system type of partition 1 to 8e (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 22: Invalid argument.
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.

3、格式化成pv
[root@localhost ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created


[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name nfs_vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.80 GiB
PE Size 4.00 MiB
Total PE 2509
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 0 / 0
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

4、vg扩展
[root@localhost ~]# vgextend nfs_vg  /dev/vdb1   (nfs_vg 是上面你需要扩展的VG名字  如我们的LV教程这里是nfs_vg
Volume group "nfs_vg" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name nfs_vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 79.80 GiB
PE Size 4.00 MiB
Total PE 20428
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 17919 / 70.00 GiB
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

5、还要继续操作如下2步,不然看不到磁盘的增加

[root@NH-Test-44 ~]# df -h
Filesystem                 Size  Used  Avail  Use%  Mounted on
/dev/mapper/vmvg-root  //   
                                45G   12G   32G    27%         /
tmpfs                        3.9G    0      3.9G   0%        /dev/shm
/dev/vda1                  190M  88M   93M   49%       /boot


lvextend -l +100%FREE /dev/nfs_vg/vg_1   //扩容对应的lvm,在这里目录 / 对应的lvm卷名字为/dev/nfs_vg/vg_1

resize2fs -p /dev/nfs_vg/vg_1 //文件系统扩容(占满LV)

再用df -h查看磁盘容量就会发现增大了很多。

版权所有:《小唐博客-唐联艳-我可以告诉你》 => 《lvm的vg扩容
本文地址:https://www.tlyan.com/post-45.html
除非注明,文章均为 《小唐博客-唐联艳-我可以告诉你》 原创,欢迎转载!转载请注明本文地址,谢谢。

分享本文至:

扫描二维码,在手机上阅读

评论

取消